Browse Source

Added failing test for #1568

pull/1575/head
Steven Kirk 9 years ago
parent
commit
7d8dcc02ec
  1. 19
      tests/Avalonia.Base.UnitTests/AvaloniaObjectTests_Attached.cs

19
tests/Avalonia.Base.UnitTests/AvaloniaObjectTests_Attached.cs

@ -24,10 +24,23 @@ namespace Avalonia.Base.UnitTests
Assert.Throws<IndexOutOfRangeException>(() => target.SetValue(Class2.FooProperty, "throw")); Assert.Throws<IndexOutOfRangeException>(() => target.SetValue(Class2.FooProperty, "throw"));
} }
[Fact]
public void AvaloniaProperty_Initialized_Is_Called_For_Attached_Property()
{
bool raised = false;
using (Class1.FooProperty.Initialized.Subscribe(x => raised = true))
{
new Class3();
}
Assert.True(raised);
}
private class Class1 : AvaloniaObject private class Class1 : AvaloniaObject
{ {
public static readonly AttachedProperty<string> FooProperty = public static readonly AttachedProperty<string> FooProperty =
AvaloniaProperty.RegisterAttached<Class1, Class2, string>( AvaloniaProperty.RegisterAttached<Class1, AvaloniaObject, string>(
"Foo", "Foo",
"foodefault", "foodefault",
validate: ValidateFoo); validate: ValidateFoo);
@ -48,5 +61,9 @@ namespace Avalonia.Base.UnitTests
public static readonly AttachedProperty<string> FooProperty = public static readonly AttachedProperty<string> FooProperty =
Class1.FooProperty.AddOwner<Class2>(); Class1.FooProperty.AddOwner<Class2>();
} }
private class Class3 : AvaloniaObject
{
}
} }
} }

Loading…
Cancel
Save