csharpc-sharpdotnetxamlavaloniauicross-platformcross-platform-xamlavaloniaguimulti-platformuser-interfacedotnetcore
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
73 lines
2.1 KiB
73 lines
2.1 KiB
// -----------------------------------------------------------------------
|
|
// <copyright file="PerspexObjectTests_GetValue.cs" company="Steven Kirk">
|
|
// Copyright 2015 MIT Licence. See licence.md for more information.
|
|
// </copyright>
|
|
// -----------------------------------------------------------------------
|
|
|
|
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<string> FooProperty =
|
|
PerspexProperty.Register<Class1, string>("Foo", "foodefault");
|
|
|
|
public static readonly PerspexProperty<string> BazProperty =
|
|
PerspexProperty.Register<Class1, string>("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; }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|