public void DecreaseInventory_MultipleArticles_Success() { const decimal initialP1 = 30; const decimal initialP2 = 10; //arrange var shop = ProductAssemblyShop.DeepCopy(); shop.Inventory = new HashSet <InventoryItem>() { new InventoryItem(Product1InteriorDoor, initialP1), new InventoryItem(Product2InteriorDoor, initialP2), }; var items = new[] { new InventoryItem(Product1InteriorDoor, 5), new InventoryItem(Product2InteriorDoor, 6), }; //act InventoryService.DecreaseInventory(items, shop); //assert var actualP1 = shop.Inventory.Of(Product1InteriorDoor).Amount; var actualP2 = shop.Inventory.Of(Product2InteriorDoor).Amount; Assert.That(actualP1, Is.EqualTo(initialP1 - items[0].Amount)); Assert.That(actualP2, Is.EqualTo(initialP2 - items[1].Amount)); }
public void DecreaseInventory_FailFor_ArticleNotInStock() { //arrange var shop = ProductAssemblyShop.DeepCopy(); shop.Inventory = new HashSet <InventoryItem>(); var item = new InventoryItem(Product1InteriorDoor, 5); //assert () => act var ex = Assert.Throws <DomainException>(() => InventoryService.DecreaseInventory(item, shop)); Assert.That(ex.Message, Is.EqualTo(ArticleNotInStock(item.Article, shop))); }
public void DecreaseInventory_SingleArticle_Success() { const decimal initial = 15; //arrange var shop = ProductAssemblyShop.DeepCopy(); shop.Inventory = new HashSet <InventoryItem>() { new InventoryItem(Product1InteriorDoor, initial) }; var item = new InventoryItem(Product1InteriorDoor, 5); //act InventoryService.DecreaseInventory(item, shop); //assert var actual = shop.Inventory.Of(Product1InteriorDoor).Amount; Assert.That(actual, Is.EqualTo(initial - item.Amount)); }