public void ShouldSuccessfullySubscribeWithMultipleSubscribedServices()
        {
            EventHandler event1Handler = (o, e) => { };

            IServiceDispatcher serviceDispatcher = new ServiceDispatcher(new TestPlatformProvider());

            serviceDispatcher.Initialize();

            Service1 service1 = new Service1();
            Service2 service2 = new Service2();

            serviceDispatcher.Subscribe <IService1>(service1);
            serviceDispatcher.SubscribeEvent <IService1>(s => s.Event1 += event1Handler, s => s.Event1 -= event1Handler);
            serviceDispatcher.Subscribe <IService2>(service2);
        }
        public void EventShouldBeRaisedWithParameter()
        {
            string event2Raised = string.Empty;
            EventHandler <string> event2Handler = (o, e) => { event2Raised = e; };

            IServiceDispatcher serviceDispatcher = new ServiceDispatcher(new TestPlatformProvider());

            serviceDispatcher.Initialize();

            Service1 service1 = new Service1();

            serviceDispatcher.Subscribe <IService1>(service1);
            serviceDispatcher.SubscribeEvent <IService1>(s => s.Event2 += event2Handler, s => s.Event2 -= event2Handler);

            service1.RaiseEvent2("Event2");

            Assert.Equal("Event2", event2Raised);
        }
        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);
        }