public void EventShouldBeRaised() { bool event1Raised = false; EventHandler event1Handler = (o, e) => { event1Raised = true; }; IServiceDispatcher serviceDispatcher = new ServiceDispatcher(new TestPlatformProvider()); serviceDispatcher.Initialize(); Service1 service1 = new Service1(); serviceDispatcher.Subscribe <IService1>(service1); serviceDispatcher.SubscribeEvent <IService1>(s => s.Event1 += event1Handler, s => s.Event1 -= event1Handler); service1.RaiseEvent1(); Assert.True(event1Raised); }
public void EventShouldNotBeRaisedAfterEventUnsubscribe() { bool event1Raised = false; EventHandler event1Handler = (o, e) => { event1Raised = true; }; IServiceDispatcher serviceDispatcher = new ServiceDispatcher(new TestPlatformProvider()); serviceDispatcher.Initialize(); Service1 service1 = new Service1(); serviceDispatcher.Subscribe <IService1>(service1); EventRegistration eventRegistration = serviceDispatcher.SubscribeEvent <IService1>(s => s.Event1 += event1Handler, s => s.Event1 -= event1Handler); serviceDispatcher.UnsubscribeEvent <IService1>(eventRegistration); service1.RaiseEvent1(); Assert.False(event1Raised); }