public void ShipOrder_Success() { //Arrange var order = new Order(Guid.NewGuid(), "Test order") { ItemsOrdered = new HashSet <InventoryItem>() { new InventoryItem(Product1InteriorDoor, 5), }, ItemsProduced = new HashSet <InventoryItem>() { InventoryItem.Empty(Product1InteriorDoor), } }; var shop = ProductStockpileShop.DeepCopy(); shop.Orders = new HashSet <Order>() { order }; order.Shop = shop; //Act OrderService.ShipOrder(order); //Assert Assert.That(order.Status, Is.EqualTo(OrderStatus.Shipped)); Assert.That(order.ShippedAt, Is.Not.Null); }
public void TransferInventory_Success() { decimal initialSource = 10; decimal initialTarget = 2; //arrange var source = ProductAssemblyShop.DeepCopy(); source.Inventory = new HashSet <InventoryItem>() { new InventoryItem(Product1InteriorDoor, initialSource) }; var target = ProductStockpileShop.DeepCopy(); target.Inventory = new HashSet <InventoryItem>() { new InventoryItem(Product1InteriorDoor, initialTarget) }; var item = new InventoryItem(Product1InteriorDoor, 2); //act InventoryService.Transfer(source, target, item); //assert var actualSource = source.Inventory.Of(Product1InteriorDoor).Amount; Assert.That(actualSource, Is.EqualTo(initialSource - item.Amount)); var actualTarget = target.Inventory.Of(Product1InteriorDoor).Amount; Assert.That(actualTarget, Is.EqualTo(initialTarget + item.Amount)); }
public void TransferInventory_FailFor_ArticleNotAllowedInShop() { //arrange var source = MaterialStockpileShop.DeepCopy(); var target = ProductStockpileShop.DeepCopy(); var item = new InventoryItem(Material1Timber, 1); //assert () => act var ex = Assert.Throws <DomainException>(() => InventoryService.Transfer(source, target, item)); Assert.That(ex.Message, Is.EqualTo(ArticleNotAllowedInShop(item.Article, target))); }
public void TransferInventory_FailFor_ArticleNotInStock() { //arrange var source = ProductAssemblyShop.DeepCopy(); source.Inventory = new HashSet <InventoryItem>(); var target = ProductStockpileShop.DeepCopy(); var item = new InventoryItem(Product1InteriorDoor, 2); //assert ()=> act var ex = Assert.Throws <DomainException>(() => InventoryService.Transfer(source, target, item)); Assert.That(ex.Message, Is.EqualTo(ArticleNotInStock(Product1InteriorDoor, source))); }
public void TransferInventory_FailFor_InsufficientInventory() { decimal initialP1 = 2; //arrange var source = ProductAssemblyShop.DeepCopy(); source.Inventory = new HashSet <InventoryItem>() { new InventoryItem(Product1InteriorDoor, initialP1) }; var target = ProductStockpileShop.DeepCopy(); var item = new InventoryItem(Product1InteriorDoor, 10); //assert ()=> act var ex = Assert.Throws <DomainException>(() => InventoryService.Transfer(source, target, item)); Assert.That(ex.Message, Is.EqualTo(InsufficientInventory(Product1InteriorDoor, item.Amount, initialP1))); }