public void MapWithSideDispatcherTest() { var dispatcher = new Build1.PostMVC.Extensions.MVCS.Events.Impl.EventDispatcher(); var count00 = 0; var count01 = 0; var count02 = 0; var count03 = 0; void Listener00() => count00++; void Listener01(int p1) => count01++; void Listener02(int p1, string p2) => count02++; void Listener03(int p1, string p2, bool p3) => count03++; _map.Map(dispatcher, TestEvent.Event00, Listener00); _map.Map(dispatcher, TestEvent.Event01, Listener01); _map.Map(dispatcher, TestEvent.Event02, Listener02); _map.Map(dispatcher, TestEvent.Event03, Listener03); Assert.AreEqual(true, _map.ContainsMapInfo(dispatcher, TestEvent.Event00, Listener00)); Assert.AreEqual(true, _map.ContainsMapInfo(dispatcher, TestEvent.Event01, Listener01)); Assert.AreEqual(true, _map.ContainsMapInfo(dispatcher, TestEvent.Event02, Listener02)); Assert.AreEqual(true, _map.ContainsMapInfo(dispatcher, TestEvent.Event03, Listener03)); dispatcher.Dispatch(TestEvent.Event00); Assert.AreEqual(count00, 1); Assert.AreEqual(count01, 0); Assert.AreEqual(count02, 0); Assert.AreEqual(count03, 0); dispatcher.Dispatch(TestEvent.Event01, int.MinValue); Assert.AreEqual(count00, 1); Assert.AreEqual(count01, 1); Assert.AreEqual(count02, 0); Assert.AreEqual(count03, 0); dispatcher.Dispatch(TestEvent.Event02, int.MinValue, string.Empty); Assert.AreEqual(count00, 1); Assert.AreEqual(count01, 1); Assert.AreEqual(count02, 1); Assert.AreEqual(count03, 0); dispatcher.Dispatch(TestEvent.Event03, int.MinValue, string.Empty, false); Assert.AreEqual(count00, 1); Assert.AreEqual(count01, 1); Assert.AreEqual(count02, 1); Assert.AreEqual(count03, 1); }
/* * Dispatch. */ public void Dispatch(Event @event) { _dispatcher.Dispatch(@event); _commandBinder.ProcessEvent(@event); }