public void MultipleOrderNotEnoughInventoryTest() { //test data var order = new Dictionary <string, int> { { "apple", 2 }, { "banana", 2 }, { "orange", 2 } }; var inventoryDistribution = new List <Warehouse> { new Warehouse { Name = "owd", Inventory = new Dictionary <string, int> { { "apple", 0 }, { "banana", 1 }, { "orange", 1 } } }, new Warehouse { Name = "dm", Inventory = new Dictionary <string, int> { { "apple", 1 }, { "banana", 1 }, { "orange", 1 } } } }; var ia = new InventoryAllocator(); var result = ia.FulfillOrder(order, inventoryDistribution); var expected = new List <Warehouse>(); //assertions //should be just zero Assert.AreEqual(expected.Count, result.Count); }
public void ExactMatchTest() { //test data var order = new Dictionary <string, int> { { "apple", 1 } }; var inventoryDistribution = new List <Warehouse> { new Warehouse { Name = "owd", Inventory = new Dictionary <string, int> { { "apple", 1 } } } }; var ia = new InventoryAllocator(); var result = ia.FulfillOrder(order, inventoryDistribution); var expected = new List <Warehouse> { new Warehouse { Name = "owd", Inventory = new Dictionary <string, int> { { "apple", 1 } } } }; //assertions //should be just one Assert.AreEqual(expected.Count, result.Count); Assert.AreEqual(expected[0].Name, result[0].Name); CollectionAssert.AreEquivalent(expected[0].Inventory, result[0].Inventory); }
public void InventoryIsLessThanAmountOfTheOrder() { //Assign orderList = new Dictionary <string, int>(); orderList.Add("Apples", 10); orderList.Add("Pears", 10); orders = new Orders(orderList); wareHouse = new WareHouse("owd"); locations = new Locations(); locations.setWareHouse(wareHouse); wareHouse.SetInventoryAmount("Apples", 5); wareHouse.SetInventoryAmount("Pears", 5); InventoryAllocator inventoryAllocator = new InventoryAllocator(); //Act inventoryAllocator.AllocateOrderAmongLocations(orders, locations); //Assert Assert.IsTrue(inventoryAllocator.OrderAmount > 0); }
public void OrderHasNegativeAmount() { //Assign orderList = new Dictionary <string, int>(); orderList.Add("Apples", -1); orderList.Add("Pears", 5); orders = new Orders(orderList); wareHouse = new WareHouse("owd"); locations = new Locations(); locations.setWareHouse(wareHouse); wareHouse.SetInventoryAmount("Apples", 5); wareHouse.SetInventoryAmount("Watermelon", 5); InventoryAllocator inventoryAllocator = new InventoryAllocator(); //Act //Assert Assert.IsTrue(inventoryAllocator.AllocateOrderAmongLocations(orders, locations) == null); }
public void InventoryMatchTheOrder() { //Assign orderList = new Dictionary <string, int>(); orderList.Add("Apples", 5); orderList.Add("Pears", 5); orders = new Orders(orderList); wareHouse = new WareHouse("owd"); locations = new Locations(); locations.setWareHouse(wareHouse); wareHouse.SetInventoryAmount("Apples", 5); wareHouse.SetInventoryAmount("Pears", 5); InventoryAllocator inventoryAllocator = new InventoryAllocator(); //Act inventoryAllocator.AllocateOrderAmongLocations(orders, locations); //Assert Assert.IsTrue(wareHouse.InventoryAmounts["Apples"] == 0); Assert.IsTrue(wareHouse.StoredInventory["Apples"] == 5); Assert.IsTrue(wareHouse.InventoryAmounts["Pears"] == 0); Assert.IsTrue(wareHouse.StoredInventory["Pears"] == 5); }