// ----------------------------------------------------------------------- // // Copyright 2015 MIT Licence. See licence.md for more information. // // ----------------------------------------------------------------------- namespace Perspex.Base.UnitTests { using Xunit; public class PerspexObjectTests_GetValue { [Fact] public void GetValue_Returns_Default_Value() { Class1 target = new Class1(); Assert.Equal("foodefault", target.GetValue(Class1.FooProperty)); } [Fact] public void GetValue_Returns_Overridden_Default_Value() { Class2 target = new Class2(); Assert.Equal("foooverride", target.GetValue(Class1.FooProperty)); } [Fact] public void GetValue_Returns_Set_Value() { Class1 target = new Class1(); target.SetValue(Class1.FooProperty, "newvalue"); Assert.Equal("newvalue", target.GetValue(Class1.FooProperty)); } [Fact] public void GetValue_Returns_Inherited_Value() { Class1 parent = new Class1(); Class2 child = new Class2 { Parent = parent }; parent.SetValue(Class1.BazProperty, "changed"); Assert.Equal("changed", child.GetValue(Class1.BazProperty)); } private class Class1 : PerspexObject { public static readonly PerspexProperty FooProperty = PerspexProperty.Register("Foo", "foodefault"); public static readonly PerspexProperty BazProperty = PerspexProperty.Register("Baz", "bazdefault", true); } private class Class2 : Class1 { static Class2() { FooProperty.OverrideDefaultValue(typeof(Class2), "foooverride"); } public Class1 Parent { get { return (Class1)this.InheritanceParent; } set { this.InheritanceParent = value; } } } } }