Browse Source

Add unit test and fix #2149.

pull/2206/head
Jeremy Koritzinsky 7 years ago
parent
commit
44bf2ee721
  1. 1
      src/Avalonia.Base/Data/Core/ExpressionNode.cs
  2. 13
      tests/Avalonia.Base.UnitTests/Data/Core/ExpressionObserverTests_Property.cs

1
src/Avalonia.Base/Data/Core/ExpressionNode.cs

@ -147,6 +147,7 @@ namespace Avalonia.Data.Core
private void StopListening()
{
StopListeningCore();
_listening = false;
}
private BindingNotification TargetNullNotification()

13
tests/Avalonia.Base.UnitTests/Data/Core/ExpressionObserverTests_Property.cs

@ -563,6 +563,19 @@ namespace Avalonia.Base.UnitTests.Data.Core
Assert.Null(result.Item2.Target);
}
[Fact]
public void Should_Not_Throw_Exception_On_Unsubscribe_When_Already_Unsubscribed()
{
var source = new Class1 { Foo = "foo" };
var target = new PropertyAccessorNode("Foo", false);
Assert.NotNull(target);
target.Target = new WeakReference(source);
target.Subscribe(_ => { });
target.Unsubscribe();
target.Unsubscribe();
Assert.True(true);
}
private interface INext
{
int PropertyChangedSubscriptionCount { get; }

Loading…
Cancel
Save