// Copyright (c) The Perspex Project. All rights reserved. // Licensed under the MIT license. See licence.md file in the project root for full license information. using System.Linq; using System.Reactive.Linq; using Xunit; namespace Perspex.Base.UnitTests { public class PerspexObjectTests_Metadata { public PerspexObjectTests_Metadata() { // Ensure properties are registered. PerspexProperty p; p = Class1.FooProperty; p = Class2.BarProperty; p = AttachedOwner.AttachedProperty; } [Fact] public void GetRegisteredProperties_Returns_Registered_Properties() { string[] names = PerspexObject.GetRegisteredProperties(typeof(Class1)).Select(x => x.Name).ToArray(); Assert.Equal(new[] { "Foo", "Baz", "Qux", "Attached" }, names); } [Fact] public void GetRegisteredProperties_Returns_Registered_Properties_For_Base_Types() { string[] names = PerspexObject.GetRegisteredProperties(typeof(Class2)).Select(x => x.Name).ToArray(); Assert.Equal(new[] { "Bar", "Flob", "Fred", "Foo", "Baz", "Qux", "Attached" }, names); } private class Class1 : PerspexObject { public static readonly PerspexProperty FooProperty = PerspexProperty.Register("Foo"); public static readonly PerspexProperty BazProperty = PerspexProperty.Register("Baz"); public static readonly PerspexProperty QuxProperty = PerspexProperty.Register("Qux"); } private class Class2 : Class1 { public static readonly PerspexProperty BarProperty = PerspexProperty.Register("Bar"); public static readonly PerspexProperty FlobProperty = PerspexProperty.Register("Flob"); public static readonly PerspexProperty FredProperty = PerspexProperty.Register("Fred"); } private class AttachedOwner { public static readonly PerspexProperty AttachedProperty = PerspexProperty.RegisterAttached("Attached"); } } }