protected override void OnDispose() { foreach (var mi in ModelItemCollection) { var dto = mi.GetCurrentValue() as DataMergeDTO; CEventHelper.RemoveAllEventHandlers(dto); } base.OnDispose(); }
// ReSharper disable InconsistentNaming public void CEventHelper_RemoveAll_Static_ExpectNothingRemoved() // ReSharper restore InconsistentNaming { //------------Setup for test-------------------------- BobEvent.GloabalBuild += BobDomorebuilding; BobEvent.GloabalBuild += BobDobuilding; _i = 0; //------------Execute Test--------------------------- BobEvent.DoSomeThingElse(); Assert.AreEqual(_i, 2); var bob = new BobEvent(); CEventHelper.RemoveAllEventHandlers(bob); BobEvent.DoSomeThingElse(); //------------Assert Results------------------------- Assert.AreEqual(_i, 4); }
// ReSharper disable InconsistentNaming public void CEventHelper_RemoveAll_RemoveAll_ExpectRemoved() // ReSharper restore InconsistentNaming { //------------Setup for test-------------------------- var bob = new BobEvent(); _i = 0; bob.Dobuilding += BobDobuilding; bob.Dobuilding += BobDomorebuilding; //------------Execute Test--------------------------- bob.DoSomething(); Assert.AreEqual(_i, 2); CEventHelper.RemoveAllEventHandlers(bob); bob.DoSomething(); //------------Assert Results------------------------- Assert.AreEqual(_i, 2); }
// ReSharper disable InconsistentNaming public void CEventHelper_RemoveAll_Null() // ReSharper restore InconsistentNaming { CEventHelper.RemoveAllEventHandlers(null); }
public void CEventHelper_RemoveAll_Null() { CEventHelper.RemoveAllEventHandlers(null); }