Beispiel #1
0
 public void EventAsDisposable()
 {
     var eventObject = new EventObject();
     var toTest = new Disposer();
     toTest.Event<Action<string>>(e => Assert.Fail("Unexpected"),
         e => eventObject.AEvent += e,
         e => eventObject.AEvent -= e);
     toTest.Event<Action<string, string>>((f, s) => Assert.Fail("Unexpected"),
         e => eventObject.OtherEvent += e,
         e => eventObject.OtherEvent -= e);
     toTest.Event<Action<string, string, string>>((f, s, t) => Assert.Fail("Unexpected"),
         e => eventObject.ThirdEvent += e,
         e => eventObject.ThirdEvent -= e);
     toTest.Dispose();
     eventObject.Raise();
 }
Beispiel #2
0
 public void EventAsDisposableRegisters()
 {
     var eventObject = new EventObject();
     var callCount = 0;
     var toTest = new Disposer();
     toTest.Event<Action<string>>(e => callCount++,
         e => eventObject.AEvent += e,
         e => eventObject.AEvent -= e);
     toTest.Event<Action<string, string>>((f, s) => callCount++,
         e => eventObject.OtherEvent += e,
         e => eventObject.OtherEvent -= e);
     toTest.Event<Action<string, string, string>>((f, s, t) => callCount++,
         e => eventObject.ThirdEvent += e,
         e => eventObject.ThirdEvent -= e);
     eventObject.Raise();
     Assert.AreEqual(3, callCount);
 }