Skip to content

Commit 741eae3

Browse files
Test sample updated
1 parent 997a803 commit 741eae3

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

src/Controls/tests/Core.UnitTests/BindablePropertyUnitTests.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff 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
}

0 commit comments

Comments
 (0)