Skip to content

Commit

Permalink
Add a test for issue 771
Browse files Browse the repository at this point in the history
  • Loading branch information
alexandrnikitin committed Jan 30, 2024
1 parent c65e1d5 commit 5e34a59
Showing 1 changed file with 27 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using NSubstitute.Exceptions;
using NUnit.Framework;

namespace NSubstitute.Acceptance.Specs.FieldReports;


public class Issue771_NSubstituteLeakTests
{
public class Foo;

[Test]
public void NSubstituteDoesNotLeak()
{
WeakReference<Foo> weakFoo;
{
var foo = new Foo();
weakFoo = new WeakReference<Foo>(foo);
}

GC.Collect();
GC.WaitForPendingFinalizers();

Assert.False(weakFoo.TryGetTarget(out _));
}
}


0 comments on commit 5e34a59

Please sign in to comment.