diff --git a/tests/NSubstitute.Acceptance.Specs/FieldReports/Issue759_Event.cs b/tests/NSubstitute.Acceptance.Specs/FieldReports/Issue759_Event.cs new file mode 100644 index 00000000..3a284412 --- /dev/null +++ b/tests/NSubstitute.Acceptance.Specs/FieldReports/Issue759_Event.cs @@ -0,0 +1,44 @@ +using NUnit.Framework; +using System; + +namespace NSubstitute.Acceptance.Specs.FieldReports +{ + public class Issue759_Event + { + public interface IChild + { + event EventHandler 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(); + var sut = new Parent(child); + sut.Dispose(); + } + } + } +} \ No newline at end of file