Beispiel #1
0
        public void OnEventAdd(IEventHandlerContractV2 handler)
        {
            EventHandler <string> adaptedEvent = EventHandlerAdapter.ContractToViewAdapter(handler);

            _eventHandlers.Add(handler, adaptedEvent);
            _view.OnEvent += adaptedEvent;
        }
Beispiel #2
0
        public void ProcessEventWithRehydrating()
        {
            var boundedContextModel = new BoundedContextModel().WithEventHandler <MovedOut, Movement, MoveIn>(e => e.EventBody.Movement, c => c.Location);

            var eventHandlerAdapter = new EventHandlerAdapter <Movement>(new Movement(), boundedContextModel).WithId("movement");

            var item = new StockItem("item", "123");

            var myHistoryEvent = EventFactory.Default.CreateEvent <Location, MovedOut>("sourceLocation", 2, "CommandId", "CoorrelationId", new MovedOut("movement", "sourceLocation", item, "destinationLocation"));

            eventHandlerAdapter.Rehydrate(new[] { myHistoryEvent });

            var myEvent = EventFactory.Default.CreateEvent <Location, MovedIn>("destinationLocation", 3, "CommandId2", "CoorrelationId2", new MovedIn("movement", "destinationLocation", item, "sourceLocation"));

            eventHandlerAdapter.ProcessEvent(myEvent);

            Assert.AreEqual(1, eventHandlerAdapter.UncommittedChanges.Count());
            Assert.AreEqual(2, eventHandlerAdapter.UncommittedChanges.First().AggregateVersion);
        }