-
Notifications
You must be signed in to change notification settings - Fork 264
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3ce2d66
commit d88804d
Showing
1 changed file
with
44 additions
and
0 deletions.
There are no files selected for viewing
44 changes: 44 additions & 0 deletions
44
tests/NSubstitute.Acceptance.Specs/FieldReports/Issue759_Event.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
} | ||
} | ||
} |