File tree Expand file tree Collapse file tree 1 file changed +15
-0
lines changed
src/Controls/tests/Core.UnitTests Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -191,5 +191,20 @@ public void StructPropertyDefaultValue()
191191 Assert . Equal ( 1 , ( ( TestStruct ) bindable . GetValue ( prop ) ) . IntValue ) ;
192192 }
193193
194+ [ Fact ]
195+ public void SetValueThrowsExceptionWhenValidationFails ( )
196+ {
197+ var propertyName = "foo" ;
198+ var prop = BindableProperty . Create (
199+ propertyName ,
200+ typeof ( int ) ,
201+ typeof ( MockBindable ) ,
202+ defaultValue : 0 ,
203+ validateValue : ( b , v ) => ( int ) v >= 0 ) ;
204+
205+ var bindable = new MockBindable ( ) ;
206+ var exception = Assert . Throws < ArgumentException > ( ( ) => bindable . SetValue ( prop , - 1 ) ) ;
207+ Assert . Equal ( $ "Value is an invalid value for { propertyName } (Parameter 'value')", exception . Message ) ;
208+ }
194209 }
195210}
You can’t perform that action at this time.
0 commit comments