diff --git a/tests/Perspex.Base.UnitTests/PerspexObjectTests_Validation.cs b/tests/Perspex.Base.UnitTests/PerspexObjectTests_Validation.cs index cfbf31a764..8d0cf2794a 100644 --- a/tests/Perspex.Base.UnitTests/PerspexObjectTests_Validation.cs +++ b/tests/Perspex.Base.UnitTests/PerspexObjectTests_Validation.cs @@ -69,11 +69,23 @@ namespace Perspex.Base.UnitTests source.OnNext(PerspexProperty.UnsetValue); } + [Fact] + public void Attached_Property_Should_Be_Validated() + { + var target = new Class2(); + + target.SetValue(Class1.AttachedProperty, 15); + Assert.Equal(10, target.GetValue(Class1.AttachedProperty)); + } + private class Class1 : PerspexObject { public static readonly StyledProperty QuxProperty = PerspexProperty.Register("Qux", validate: Validate); + public static readonly AttachedProperty AttachedProperty = + PerspexProperty.RegisterAttached("Attached", validate: Validate); + public Class1() { MaxQux = 10; @@ -93,6 +105,11 @@ namespace Perspex.Base.UnitTests return Math.Min(Math.Max(value, 0), ((Class1)instance).MaxQux); } + + private static int Validate(Class2 instance, int value) + { + return Math.Min(value, 10); + } } private class Class2 : PerspexObject