AvaloniaObjectTests_Attached.cs 1023 B

12345678910111213141516171819202122232425262728293031323334353637
  1. // Copyright (c) The Avalonia Project. All rights reserved.
  2. // Licensed under the MIT license. See licence.md file in the project root for full license information.
  3. using System;
  4. using Xunit;
  5. namespace Avalonia.Base.UnitTests
  6. {
  7. public class AvaloniaObjectTests_Attached
  8. {
  9. [Fact]
  10. public void AddOwnered_Property_Retains_Default_Value()
  11. {
  12. var target = new Class2();
  13. Assert.Equal("foodefault", target.GetValue(Class2.FooProperty));
  14. }
  15. private class Base : AvaloniaObject
  16. {
  17. }
  18. private class Class1 : Base
  19. {
  20. public static readonly AttachedProperty<string> FooProperty =
  21. AvaloniaProperty.RegisterAttached<Class1, Base, string>(
  22. "Foo",
  23. "foodefault");
  24. }
  25. private class Class2 : Base
  26. {
  27. public static readonly AttachedProperty<string> FooProperty =
  28. Class1.FooProperty.AddOwner<Class2>();
  29. }
  30. }
  31. }