Beispiel #1
0
        public void TestSimpleIocAdapter()
        {
            var eventHandler = new DomainEvent1Handler3();

            var _bus =
                BusSetup.StartWith <Conservative>()
                .Apply <IoCSupport>(
                    s => s.SetAdapter(new MockIocAdapter(eventHandler)).SetHandlerInterface(typeof(IHandle <>)))
                .Construct();

            var publishedEvent = new DomainEvent1();

            Assert.AreEqual(eventHandler.EventCaptured, "NoEvent");
            _bus.Publish(publishedEvent);
            Assert.AreEqual(eventHandler.EventCaptured, publishedEvent.EventName);
        }
Beispiel #2
0
        public void TestChainedEvents()
        {
            var mockIocAdapter = new MockIocAdapter();
            var _bus           =
                BusSetup.StartWith <Conservative>()
                .Apply <IoCSupport>(
                    s => s.SetAdapter(mockIocAdapter).SetHandlerInterface(typeof(IHandle <>)))
                .Construct();
            var eventHandler4 = new DomainEvent1Handler4(_bus);
            var eventHandler5 = new DomainEvent1Handler5();

            mockIocAdapter.AddEventHandlers(eventHandler4, eventHandler5);

            var publishedEvent = new DomainEvent1();

            Assert.AreEqual(eventHandler4.EventCaptured, "NoEvent");
            Assert.AreEqual(eventHandler5.EventCaptured, "NoEvent");
            _bus.Publish(publishedEvent);
            Assert.AreEqual(eventHandler4.EventCaptured, publishedEvent.EventName);
            Assert.AreEqual(eventHandler5.EventCaptured, "Event 2");
            Assert.IsTrue(eventHandler4.DateTimeCaptured < eventHandler5.DateTimeCaptured);
        }