public void ReportSpoilage_Material_Success() { decimal initialC1 = 5; //arrange var shop = ProductAssemblyShop.DeepCopy(); shop.Inventory = new HashSet <InventoryItem>() { new InventoryItem(Component1Vertical, initialC1), }; var item = new InventoryItem(Component1VerticalSpoiled, 2); var order = Product1Order.DeepCopy(); //act InventoryService.ReportSpoilage(item, order, shop); //assert var actualS1 = shop.Inventory.Of(Component1VerticalSpoiled).Amount; Assert.That(actualS1, Is.EqualTo(item.Amount)); var actualC1 = shop.Inventory.Of(Component1Vertical).Amount; Assert.That(actualC1, Is.EqualTo(initialC1 - item.Amount)); }
public void IncreaseProduced_FailFor_OrderOverflow() { //arrange var order = Product1Order.DeepCopy(); var item = new InventoryItem(Product1InteriorDoor, 30); //assert ()=> act var ex = Assert.Throws <DomainException>(() => OrderService.IncreaseProduced(item, order)); Assert.That(ex.Message, Is.EqualTo(OrderOverflow(order, Product1InteriorDoor, item.Amount))); }
public void IncreaseProduced_FailFor_ArticleNotInOrder() { //arrange var order = Product1Order.DeepCopy(); var item = new InventoryItem(Product2InteriorDoor, 10); //assert ()=> act var ex = Assert.Throws <DomainException>(() => OrderService.IncreaseProduced(item, order)); Assert.That(ex.Message, Is.EqualTo(OrderNotContainArticle(order, item.Article))); }
public void IncreaseProduced_Success() { //arrange var order = Product1Order.DeepCopy(); var item = new InventoryItem(Product1InteriorDoor, 10); //act OrderService.IncreaseProduced(item, order); //assert var diff = order.ItemsProduced.Of(Product1InteriorDoor).Amount - Product1Order.ItemsProduced.Of(Product1InteriorDoor).Amount; Assert.That(diff, Is.EqualTo(item.Amount)); }
public void ReportSpoilage_Product_Success() { decimal initialC1 = 5; decimal initialC2 = 8; decimal initialC3 = 10; decimal initialP1 = 1; //arrange var shop = ProductAssemblyShop.DeepCopy(); shop.Inventory = new HashSet <InventoryItem>() { new InventoryItem(Component1Vertical, initialC1), new InventoryItem(Component2Horizontal, initialC2), new InventoryItem(Component3MdfFiller, initialC3), new InventoryItem(Product1InteriorDoor, initialP1), }; var item = new InventoryItem(Product1InteriorDoorSpoiled, 2); var order = Product1Order.DeepCopy(); //act InventoryService.ReportSpoilage(item, order, shop); //assert var actualP1 = shop.Inventory.Of(Product1InteriorDoor).Amount; Assert.That(actualP1, Is.EqualTo(initialP1)); var actualS1 = shop.Inventory.Of(Product1InteriorDoorSpoiled).Amount; Assert.That(actualS1, Is.EqualTo(0 + item.Amount)); AssertInput(initialC1, Component1Vertical); AssertInput(initialC2, Component2Horizontal); AssertInput(initialC3, Component3MdfFiller); void AssertInput(decimal initial, Article article) { var actual = shop.Inventory.Of(article).Amount; var input = Product1InteriorDoor.PrimaryBillOfMaterial.Input.Of(article).Amount; Assert.That(actual, Is.EqualTo(initial - (input * item.Amount))); } }