Skip to content

Commit

Permalink
Add code for #759
Browse files Browse the repository at this point in the history
  • Loading branch information
alexandrnikitin committed Dec 23, 2023
1 parent 3ce2d66 commit d88804d
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions tests/NSubstitute.Acceptance.Specs/FieldReports/Issue759_Event.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
using NUnit.Framework;
using System;

namespace NSubstitute.Acceptance.Specs.FieldReports
{
public class Issue759_Event
{
public interface IChild
{
event EventHandler<EventArgs> Changed;
void Change();
}
public class Parent : IDisposable
{
private IChild m_Child;
public Parent(IChild child)
{
m_Child = child;
m_Child.Changed += Child_Changed;
}
public void Dispose()
{
m_Child.Changed -= Child_Changed;
m_Child = null;
}
private void Child_Changed(object sender, EventArgs args) { }
public void Change()
{
m_Child.Change();
}
}

[Test]
public void Test()
{
for (int i = 0; i < 10000000; i++)
{
var child = Substitute.For<IChild>();
var sut = new Parent(child);
sut.Dispose();
}
}
}
}

0 comments on commit d88804d

Please sign in to comment.