public void When_Receive_OrderCreated_Then_This_Order_Is_Added_In_Waiting_Orders() { var repository = new List <WaitingOrder>(); var pendingOrderEventHandler = new PendingOrderEventHandler(repository); pendingOrderEventHandler.Handle(new OrderStarted(new OrderId("1"), 1)); Assert.Single(repository); }
public void When_Receive_MarchandiseReceived_Then_This_Order_Is_Removed_of_WaitingOrders() { var repository = new List <WaitingOrder> { new WaitingOrder(new OrderId("1"), 1) }; var pendingOrderEventHandler = new PendingOrderEventHandler(repository); pendingOrderEventHandler.Handle(new MarchandiseReceived(new OrderId("1"), 1)); Assert.Empty(repository); }
Given_2_WaitingOrders_A_and_B_When_Receive_MarchandiseReceived_Of_Order_B_Then_I_Have_Only_Order_A_In_Waiting_Orders() { var repository = new List <WaitingOrder> { new WaitingOrder(new OrderId("A"), 1), new WaitingOrder(new OrderId("B"), 1) }; var pendingOrderEventHandler = new PendingOrderEventHandler(repository); pendingOrderEventHandler.Handle(new MarchandiseReceived(new OrderId("B"), 0)); Assert.Single(repository); Assert.Contains(repository, x => Equals(x.Id, new OrderId("A"))); }
public void Should_Call_Handlers_When_Publish_Event() { var repository = new List <WaitingOrder>(); var pendingOrderEventHandler = new PendingOrderEventHandler(repository); var eventHandlers = new List <IEventHandler> { pendingOrderEventHandler }; var eventStore = new EventStoreInMemory(); var eventPublisher = new EventPublisher(eventStore, eventHandlers); eventPublisher.Publish(new OrderStarted(new OrderId("1"), 1), 1); Assert.Single(repository); }
public void Should_Display_Updated_Projection_When_Send_Command() { var repository = new List <WaitingOrder>(); IEventHandler pendingOrderEventHandler = new PendingOrderEventHandler(repository); IList <IEventHandler> eventHandlers = new List <IEventHandler> { pendingOrderEventHandler }; var eventStore = new EventStoreInMemory(); var eventPublisher = new EventPublisher(eventStore, eventHandlers); var commandHandler = new CommandHandler(eventPublisher, eventStore); var colisList = new List <Colis> { new Colis() }; commandHandler.Handle(new StartOrder(new OrderId("1"), colisList)); Assert.Single(repository); Assert.Equal(new OrderId("1"), repository.First().Id); Assert.Equal(1, repository.First().NumberColis); }