Exemplo n.º 1
0
        public void DistributeEventsToHandlers()
        {
            var movement       = "movement";
            var location       = "Mayfair";
            var item           = new StockItem("item", "1");
            var toLocation     = "toLocation";
            var eventHandlerId = $"{typeof(Movement).Name}\\{movement}";

            var @event = EventFactory.Default.CreateEvent <Location, MovedOut>(location, 1, "command1", "command1", new MovedOut(movement, location, item, toLocation));

            var eventHandler = new Mock <IEventHandler>();

            var distributionEngine = DomainFactory.CreateEventDispatcher(this.boundedContextModel, eventHandler.Object);

            distributionEngine.DispatchEvent(@event);

            eventHandler.Verify(x => x.Handle(@event, eventHandlerId, typeof(Movement)));
        }