Browse Source

Add leak test to make sure the method accessor doesn't leak memory.

pull/1179/head
Jeremy Koritzinsky 9 years ago
parent
commit
6dc6ec84e9
  1. 22
      tests/Avalonia.LeakTests/ExpressionObserverTests.cs

22
tests/Avalonia.LeakTests/ExpressionObserverTests.cs

@ -71,6 +71,28 @@ namespace Avalonia.LeakTests
Assert.Equal(0, memory.GetObjects(where => where.Type.Is<NonIntegerIndexer>()).ObjectsCount));
}
[Fact]
public void Should_Not_Keep_Source_Alive_MethodBinding()
{
Func<ExpressionObserver> run = () =>
{
var source = new { Foo = new MethodBound() };
var target = new ExpressionObserver(source, "Foo.A");
target.Subscribe(_ => { });
return target;
};
var result = run();
dotMemory.Check(memory =>
Assert.Equal(0, memory.GetObjects(where => where.Type.Is<MethodBound>()).ObjectsCount));
}
private class MethodBound
{
public void A() { }
}
private class NonIntegerIndexer : NotifyingBase
{
private readonly Dictionary<string, string> _storage = new Dictionary<string, string>();

Loading…
Cancel
Save