File tree Expand file tree Collapse file tree 2 files changed +26
-8
lines changed
tests/UnityMvvmToolkit.Test.Integration Expand file tree Collapse file tree 2 files changed +26
-8
lines changed Original file line number Diff line number Diff line change @@ -268,6 +268,26 @@ public void RentProperty_ShouldThrow_WhenBindingDataIsNotValid()
268
268
. WithMessage ( nameof ( countPropertyBindingData . PropertyName ) ) ;
269
269
}
270
270
271
+ [ Fact ]
272
+ public void RentPropertyWithConverter_ShouldThrow_WhenPropertyIsReadOnly ( )
273
+ {
274
+ // Arrange
275
+ var objectProvider = new BindingContextObjectProvider ( new IValueConverter [ ]
276
+ {
277
+ new IntToStrConverter ( )
278
+ } ) ;
279
+
280
+ var bindingContext = new MyBindingContext ( ) ;
281
+
282
+ var intValueBindingData = nameof ( MyBindingContext . IntValue ) . ToPropertyBindingData ( ) ;
283
+
284
+ // Assert
285
+ objectProvider
286
+ . Invoking ( sut => sut . RentReadOnlyProperty < string > ( bindingContext , intValueBindingData ) )
287
+ . Should ( )
288
+ . Throw < InvalidCastException > ( ) ;
289
+ }
290
+
271
291
[ Fact ]
272
292
public void RentPropertyWithConverter_ShouldThrow_WhenConverterIsNotSet ( )
273
293
{
@@ -279,7 +299,7 @@ public void RentPropertyWithConverter_ShouldThrow_WhenConverterIsNotSet()
279
299
280
300
// Assert
281
301
objectProvider
282
- . Invoking ( objProvider => objProvider . RentProperty < string > ( bindingContext , countPropertyBindingData ) )
302
+ . Invoking ( sut => sut . RentProperty < string > ( bindingContext , countPropertyBindingData ) )
283
303
. Should ( )
284
304
. Throw < NullReferenceException > ( )
285
305
. WithMessage ( $ "Property value converter from '{ typeof ( int ) } ' to '{ typeof ( string ) } ' not found.") ;
Original file line number Diff line number Diff line change 1
1
using UnityMvvmToolkit . Core ;
2
+ using UnityMvvmToolkit . Core . Attributes ;
2
3
using UnityMvvmToolkit . Core . Interfaces ;
3
4
using UnityMvvmToolkit . Test . Unit . TestCommands ;
4
5
5
6
// ReSharper disable InconsistentNaming
6
- // ReSharper disable UnusedMember.Global
7
7
8
8
namespace UnityMvvmToolkit . Test . Integration . TestBindingContext ;
9
9
10
10
public class MyBindingContext : IBindingContext
11
11
{
12
12
private readonly IProperty < int > _count = new Property < int > ( ) ;
13
- private readonly IProperty < string > m_description = new Property < string > ( ) ;
13
+
14
+ [ Observable ( nameof ( IntValue ) ) ]
15
+ private readonly IReadOnlyProperty < int > m_intValue = new ReadOnlyProperty < int > ( 69 ) ;
14
16
15
17
public MyBindingContext ( string title = "Title" )
16
18
{
@@ -32,11 +34,7 @@ public int Count
32
34
set => _count . Value = value ;
33
35
}
34
36
35
- public string Description
36
- {
37
- get => m_description . Value ;
38
- set => m_description . Value = value ;
39
- }
37
+ public int IntValue => m_intValue . Value ;
40
38
41
39
public ICommand FieldCommand ;
42
40
public ICommand IncrementCommand { get ; }
You can’t perform that action at this time.
0 commit comments