File tree Expand file tree Collapse file tree 1 file changed +49
-0
lines changed
tests/UnityMvvmToolkit.Test.Integration Expand file tree Collapse file tree 1 file changed +49
-0
lines changed Original file line number Diff line number Diff line change @@ -149,6 +149,55 @@ public void WarmupValueConverter_ShouldThrow_WhenValueConverterWasWarmup()
149149 . WithMessage ( "Warm up only during the initialization phase." ) ;
150150 }
151151
152+ [ Fact ]
153+ public void TryRentProperty_ShouldReturnProperty_WhenDataIsValid ( )
154+ {
155+ // Arrange
156+ const int countValue = 69 ;
157+
158+ var objectProvider = new BindingContextObjectProvider ( Array . Empty < IValueConverter > ( ) ) ;
159+ var bindingContext = new MyBindingContext
160+ {
161+ Count = countValue ,
162+ } ;
163+
164+ var countPropertyBindingData = nameof ( MyBindingContext . Count ) . ToPropertyBindingData ( ) ;
165+
166+ // Act
167+ var result =
168+ objectProvider . TryRentProperty < int > ( bindingContext , countPropertyBindingData , out var countProperty ) ;
169+
170+ // Assert
171+ countProperty
172+ . Should ( )
173+ . NotBeNull ( )
174+ . And
175+ . BeAssignableTo < IProperty < int > > ( )
176+ . And
177+ . BeAssignableTo < IReadOnlyProperty < int > > ( ) ;
178+
179+ result . Should ( ) . BeTrue ( ) ;
180+ countProperty . Value . Should ( ) . Be ( countValue ) ;
181+ }
182+
183+ [ Fact ]
184+ public void TryRentProperty_ShouldNotReturnProperty_WhenPropertyIsReadOnly ( )
185+ {
186+ // Arrange
187+ var objectProvider = new BindingContextObjectProvider ( Array . Empty < IValueConverter > ( ) ) ;
188+ var bindingContext = new MyBindingContext ( ) ;
189+
190+ var readOnlyPropertyBindingData = nameof ( MyBindingContext . IntReadOnlyValue ) . ToPropertyBindingData ( ) ;
191+
192+ // Act
193+ var result =
194+ objectProvider . TryRentProperty < int > ( bindingContext , readOnlyPropertyBindingData , out var countProperty ) ;
195+
196+ // Assert
197+ result . Should ( ) . BeFalse ( ) ;
198+ countProperty . Should ( ) . BeNull ( ) ;
199+ }
200+
152201 [ Fact ]
153202 public void RentProperty_ShouldReturnProperty_WhenDataIsValid ( )
154203 {
You can’t perform that action at this time.
0 commit comments