StyledPropertyTests.cs 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. // Copyright (c) The Perspex Project. All rights reserved.
  2. // Licensed under the MIT license. See licence.md file in the project root for full license information.
  3. using Xunit;
  4. namespace Perspex.Base.UnitTests
  5. {
  6. public class StyledPropertyTests
  7. {
  8. [Fact]
  9. public void AddOwnered_Property_Should_Equal_Original()
  10. {
  11. var p1 = new StyledProperty<string>(
  12. "p1",
  13. typeof(Class1),
  14. new StyledPropertyMetadata<string>());
  15. var p2 = p1.AddOwner<Class2>();
  16. Assert.Equal(p1, p2);
  17. Assert.Equal(p1.GetHashCode(), p2.GetHashCode());
  18. Assert.True(p1 == p2);
  19. }
  20. [Fact]
  21. public void AddOwnered_Property_Should_Be_Same()
  22. {
  23. var p1 = new StyledProperty<string>(
  24. "p1",
  25. typeof(Class1),
  26. new StyledPropertyMetadata<string>());
  27. var p2 = p1.AddOwner<Class2>();
  28. Assert.Same(p1, p2);
  29. }
  30. private class Class1 : PerspexObject
  31. {
  32. public static readonly PerspexProperty<string> FooProperty =
  33. PerspexProperty.Register<Class1, string>("Foo", "default");
  34. }
  35. private class Class2 : PerspexObject
  36. {
  37. }
  38. }
  39. }