public async Task PutOrderEnactAsync(Guid id) { var command = new EnactOrder { OrderId = id, InitiatorId = Guid.NewGuid() }; await _commandInvoker.Execute(command); }
public async Task EnactOrder_Success() { //adhere var initialSuborder = Product1Order.SubOrders.DeepCopy(); //arrange var input = Product1InteriorDoor.PrimaryBillOfMaterial.Input; var amount = Product1Order.ItemsOrdered.Of(Product1InteriorDoor).Amount; Product1Order.SubOrders = new HashSet <Order>() { new Order(Guid.NewGuid(), "Door suborder") { Shop = ProductAssemblyShop, ItemsOrdered = Product1Order.ItemsOrdered, Status = OrderStatus.New, ShipmentDeadline = Product1Order.ShipmentDeadline.AddDays(-1) }, new Order(Guid.NewGuid(), "Vertical component suborder") { Shop = TimberComponentShop, ItemsOrdered = new HashSet <InventoryItem> { new InventoryItem(Component1Vertical, input.Of(Component1Vertical).Amount *amount) }, Status = OrderStatus.New, ShipmentDeadline = Product1Order.ShipmentDeadline.AddDays(-1) }, new Order(Guid.NewGuid(), "Horizontal component suborder") { Shop = TimberComponentShop, ItemsOrdered = new HashSet <InventoryItem> { new InventoryItem(Component2Horizontal, input.Of(Component2Horizontal).Amount *amount) }, Status = OrderStatus.New, ShipmentDeadline = Product1Order.ShipmentDeadline.AddDays(-1) }, new Order(Guid.NewGuid(), "Mdf component suborder") { Shop = MdfComponentShop, ItemsOrdered = new HashSet <InventoryItem> { new InventoryItem(Component3MdfFiller, input.Of(Component3MdfFiller).Amount *amount) }, Status = OrderStatus.New, ShipmentDeadline = Product1Order.ShipmentDeadline.AddDays(-1) } }; var command = new EnactOrder { OrderId = Product1Order.Id, InitiatorId = GlobalAdmin.Id }; var handler = new EnactOrderHandler(EntityRepository, InventoryService, EventTransmitter); //act await handler.HandleAsync(command); //assert Assert.True(Product1Order.SubOrders.All(o => o.Status == OrderStatus.InProduction)); Assert.True(Product1Order.SubOrders.All(o => o.EstimatedCompletionAt != null)); Assert.That(GetRecordedEvents <DomainEvent <Order> >().Count, Is.EqualTo(5)); Assert.That(GetRecordedEvents <OrderEnacted>().Count, Is.EqualTo(1)); //annul Product1Order.SubOrders = initialSuborder; }