public void IsItemAvailable() { var fakeInventoryRepository = new FakeInventoryRepository(); var fridge = new FridgeService(fakeInventoryRepository); Assert.AreEqual(false, fridge.IsItemAvailable(inventoryName, 7)); }
public void UpdateItemInFridge() { var repository = new FakeItemRepository(); var flourItem = new Item { Name = "Egg", Quantity = new Quantity() { Unit = "P", Total = 8 } }; repository.Items.Add(flourItem); var worker = new FridgeService(repository); var eggItem = new Item { Name = "Egg", Quantity = new Quantity() { Unit = "P", Total = 8 } }; var result = worker.AddItem(eggItem); Assert.AreEqual(result.Unit, "P"); Assert.AreEqual(result.Total, 16); }
public void RemoveInventoryItem() { var fakeInventoryRepository = new FakeInventoryRepository(); var fridge = new FridgeService(fakeInventoryRepository); Assert.AreEqual(-5, fridge.TakeItemFromFridge(inventoryName, 5)); }
public ItemController(IItemRepository repository) { _repository = repository; var flourItem = new Item { Name = "Flour", Quantity = new Quantity() { Unit = "L", Total = 1 } }; _repository.Add(flourItem); var eggItem = new Item { Name = "Egg", Quantity = new Quantity() { Unit = "P", Total = 8 } }; _repository.Add(eggItem); _fridgeService = new FridgeService(_repository); }
public void IsItemAvailable() { var fakeInventoryRepository = new FakeInventoryRepository(); var fridge = new FridgeService(fakeInventoryRepository); var inventoryItem = new InventoryItem(inventoryName, 10); fridge.AddIngredientToFridge(inventoryItem); Assert.AreEqual(true, fridge.IsItemAvailable(inventoryName, 7)); }
public void ListAllInventoryItems() { var fakeInventoryRepository = new FakeInventoryRepository(); var fridge = new FridgeService(fakeInventoryRepository); var result = fridge.GetAllInventoryItems(); Assert.AreEqual(0, result.Count); }
public void GetItem() { var fakeInventoryRepository = new FakeInventoryRepository(); var fridge = new FridgeService(fakeInventoryRepository); var result = fridge.GetInventoryItem("Gorgonzola"); Assert.AreEqual(null, result); }
public void AddOneInventoryItem() { var fakeInventoryRepository = new FakeInventoryRepository(); var fridge = new FridgeService(fakeInventoryRepository); var inventoryItem = new InventoryItem(inventoryName, 10); fridge.AddIngredientToFridge(inventoryItem); Assert.AreEqual(1, fakeInventoryRepository.InventoryItems.Count); Assert.AreEqual(inventoryName, fakeInventoryRepository.InventoryItems[0].Name); Assert.AreEqual(10, fakeInventoryRepository.InventoryItems[0].Quantity); }
public void GetNonExistingItem() { var fakeInventoryRepository = new FakeInventoryRepository(); var fridge = new FridgeService(fakeInventoryRepository); var inventoryItem = new InventoryItem(inventoryName, 10); fridge.AddIngredientToFridge(inventoryItem); var result = fridge.GetInventoryItem("Gorgonzola"); Assert.AreEqual(null, result); }
public async Task CleanFridgeDoesNothingOnEmptyFridge() { var mockRepo = new Mock <IKitchenRepo>(); mockRepo.Setup(r => r.GetAllFridgeItemsAsync()) .ReturnsAsync(Enumerable.Empty <FridgeItem>()); var service = new FridgeService(mockRepo.Object); bool cleaned = await service.CleanFridgeAsync(); Assert.False(cleaned); }
public void GetExistingItem() { var fakeInventoryRepository = new FakeInventoryRepository(); var fridge = new FridgeService(fakeInventoryRepository); var inventoryItem = new InventoryItem(inventoryName, 10); fridge.AddIngredientToFridge(inventoryItem); var result = fridge.GetInventoryItem(inventoryName); Assert.AreEqual(inventoryName, result.Name); Assert.AreEqual(10, result.Quantity); }
public void ItemNotExistInFridge() { var repository = new FakeItemRepository(); repository.Items.Add(new Item() { Name = "Flour" }); var worker = new FridgeService(repository); var result = worker.IsAvailable("Egg"); Assert.IsFalse(result); }
public void RemoveNonExistingInventoryItem() { var invItem1 = "Meatballs"; var invItem2 = "Potato"; var invRemoveItem = "Sauce"; var fakeInventoryRepository = new FakeInventoryRepository(); var fridge = new FridgeService(fakeInventoryRepository); var inventoryItem = new InventoryItem(invItem1, 10); fridge.AddIngredientToFridge(inventoryItem); inventoryItem = new InventoryItem(invItem2, 50); fridge.AddIngredientToFridge(inventoryItem); Assert.AreEqual(-5, fridge.TakeItemFromFridge(invRemoveItem, 5)); }
public void RemoveExistingInventoryItem() { var invItem1 = "Meatballs"; var invItem2 = "Potato"; var invItem3 = "Pasta"; var fakeInventoryRepository = new FakeInventoryRepository(); var fridge = new FridgeService(fakeInventoryRepository); var inventoryItem = new InventoryItem(invItem1, 10); fridge.AddIngredientToFridge(inventoryItem); inventoryItem = new InventoryItem(invItem2, 50); fridge.AddIngredientToFridge(inventoryItem); inventoryItem = new InventoryItem(invItem3, 4); fridge.AddIngredientToFridge(inventoryItem); Assert.AreEqual(20, fridge.TakeItemFromFridge(invItem2, 30)); Assert.AreEqual(-10, fridge.TakeItemFromFridge(invItem2, 30)); }
public void RemoveItemInFridge() { var repository = new FakeItemRepository(); var flourItem = new Item { Name = "Flour", Quantity = new Quantity() { Unit = "L", Total = 1 } }; repository.Items.Add(flourItem); var eggItem = new Item { Name = "Egg", Quantity = new Quantity() { Unit = "P", Total = 8 } }; repository.Items.Add(eggItem); var worker = new FridgeService(repository); var eggsToRemove = new Item { Name = "Egg", Quantity = new Quantity() { Unit = "P", Total = 3 } }; var result = worker.RemoveItem(eggsToRemove); Assert.AreEqual(result.Total, 5); }
public void ListAllInventoryItems() { var invItem1 = "Meatballs"; var invItem2 = "Potato"; var invItem3 = "Pasta"; var fakeInventoryRepository = new FakeInventoryRepository(); var fridge = new FridgeService(fakeInventoryRepository); var inventoryItem = new InventoryItem(invItem1, 10); fridge.AddIngredientToFridge(inventoryItem); inventoryItem = new InventoryItem(invItem2, 50); fridge.AddIngredientToFridge(inventoryItem); inventoryItem = new InventoryItem(invItem3, 4); fridge.AddIngredientToFridge(inventoryItem); var result = fridge.GetAllInventoryItems(); Assert.AreEqual(3, result.Count); Assert.AreEqual(invItem1, result[0].Name); Assert.AreEqual(invItem2, result[1].Name); Assert.AreEqual(invItem3, result[2].Name); }
public FridgeController() { _fridgeService = new FridgeService(); }