Exemplo n.º 1
0
        public Program()
        {
            _bus = new SimpleBus();
//            _configuration = SqlLiteDatabase();
            _configuration   = SqlServerDatabase();
            _eventSerializer = new JsonEventSerializer();
            var query = new CustomerQuery(_configuration, _eventSerializer);

            _customerService = new CustomerService(_bus, query, SqliteSubscriber(_configuration));
            _bus.Register(new CustomerReadModelEventSubscriber(_configuration));
        }
Exemplo n.º 2
0
        public void GivenSubscriber_WhenPost_ShouldSendEventToSubscriber()
        {
            var @event     = new TestEvent("One");
            var subscriber = new TestEventSubscriber();

            var bus = new SimpleBus();

            bus.Register(subscriber);
            bus.Post(@event);

            Assert.Single(subscriber.Events);
        }
Exemplo n.º 3
0
        public void GivenMultipleSubscribers_WhenPost_ShouldSentEventToAllSubscribers()
        {
            var @event      = new TestEvent("One");
            var subscriber1 = new TestEventSubscriber();
            var subscriber2 = new TestEventSubscriber();

            var bus = new SimpleBus();

            bus.Register(subscriber1)
            .Register(subscriber2);
            bus.Post(@event);

            Assert.Single(subscriber1.Events);
            Assert.Single(subscriber2.Events);
        }
Exemplo n.º 4
0
        public void GivenSubscriber_WhenUnregister_ShouldNoLongerReceiveEvents()
        {
            var @event     = new TestEvent("One");
            var subscriber = new TestEventSubscriber();

            var bus = new SimpleBus();

            bus.Register(subscriber);
            bus.Post(@event);

            Assert.Single(subscriber.Events);

            bus.Unregister(subscriber);
            bus.Post(@event);

            Assert.Single(subscriber.Events);
        }