public void Restrict() { EventBroker eventBroker = new EventBroker(); Publisher p = new Publisher(); Subscriber s = new Subscriber(); eventBroker.Register(p); eventBroker.Register(s); CancelEventArgs e = new CancelEventArgs(false); p.Fire(e); Assert.AreEqual(1, s.NumberOfHandledEvents, "should be handled."); p.Fire(e); Assert.AreEqual(1, s.NumberOfHandledEvents, "should not be handled."); }
public void Restrict() { EventBroker eventBroker = new EventBroker(); Publisher p = new Publisher(); Subscriber s = new Subscriber(); eventBroker.Register(p); eventBroker.Register(s); CancelEventArgs e = new CancelEventArgs(false); p.Fire(e); Assert.AreEqual(1, s.NumberOfHandledEvents, "should be handled."); p.Fire(e); Assert.AreEqual(1, s.NumberOfHandledEvents, "should not be handled."); }
public void SeveralHandlers() { EventBroker eventBroker = new EventBroker(); Publisher p = new Publisher(); Subscriber s1 = new Subscriber(); Subscriber s2 = new Subscriber(); eventBroker.Register(p); eventBroker.Register(s1); eventBroker.Register(s2); CancelEventArgs e = new CancelEventArgs(false); p.Fire(e); Assert.AreEqual(1, s1.NumberOfHandledEvents, "s1 was not called"); Assert.AreEqual(0, s2.NumberOfHandledEvents, "s2 was called"); }
public void SeveralHandlers() { EventBroker eventBroker = new EventBroker(); Publisher p = new Publisher(); Subscriber s1 = new Subscriber(); Subscriber s2 = new Subscriber(); eventBroker.Register(p); eventBroker.Register(s1); eventBroker.Register(s2); CancelEventArgs e = new CancelEventArgs(false); p.Fire(e); Assert.AreEqual(1, s1.NumberOfHandledEvents, "s1 was not called"); Assert.AreEqual(0, s2.NumberOfHandledEvents, "s2 was called"); }