StyledPropertyTests.cs 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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. false,
  15. new StyledPropertyMetadata(null));
  16. var p2 = p1.AddOwner<Class2>();
  17. Assert.Equal(p1, p2);
  18. Assert.Equal(p1.GetHashCode(), p2.GetHashCode());
  19. Assert.True(p1 == p2);
  20. }
  21. [Fact]
  22. public void AddOwnered_Property_Should_Be_Same()
  23. {
  24. var p1 = new StyledProperty<string>(
  25. "p1",
  26. typeof(Class1),
  27. false,
  28. new StyledPropertyMetadata(null));
  29. var p2 = p1.AddOwner<Class2>();
  30. Assert.Same(p1, p2);
  31. }
  32. private class Class1 : PerspexObject
  33. {
  34. public static readonly PerspexProperty<string> FooProperty =
  35. PerspexProperty.Register<Class1, string>("Foo", "default");
  36. }
  37. private class Class2 : PerspexObject
  38. {
  39. }
  40. }
  41. }