Ejemplo n.º 1
0
        public void ShouldListenToTopics()
        {
            //Given
            var message = new SecondMessage();

            _target.RegisterTopic <SecondMessage>(_topics.Add);
            _target.AddListener(_listeners.Add);

            //When
            _target.Send(message);


            //Then
            VerifyMessagesInDifferentQueues(message, _topics, _listeners);
        }
Ejemplo n.º 2
0
        public void ShouldSendDataViaBus()
        {
            //Given
            var          events  = new List <object>();
            Guid         id      = Guid.NewGuid();
            const string name    = "test";
            const string newName = "second";
            var          bus     = new E05.Test.Infrastructure.Bus();

            bus.AddListener(ob =>
            {
                events.Add(ob);
            });
            var eventStore = new EventStore(bus);
            var target     = new InventoryCommandHandler(bus, eventStore);

            //When
            bus.Send(new CreateInventoryItem(id, name));
            bus.Send(new ModifyItemName(id, newName, 0));


            //Then
            Assert.AreEqual(4, events.Count);
            var inventoryItemCreated = events[1] as InventoryItemCreated;

            Assert.AreEqual(id, inventoryItemCreated.Id);
            Assert.AreEqual(name, inventoryItemCreated.Name);

            var itemNameModified = events[3] as ItemNameModified;

            Assert.AreEqual(id, itemNameModified.Id);
            Assert.AreEqual(newName, itemNameModified.NewName);
        }