コード例 #1
0
ファイル: FridgeTests.cs プロジェクト: kjelag/Fridge
            public void AddTwoIdenticalInventoryItem()
            {
                var fakeInventoryRepository = new FakeInventoryRepository();
                var fridge = new FridgeService(fakeInventoryRepository);

                var inventoryItem = new InventoryItem(inventoryName, 10);

                fridge.AddIngredientToFridge(inventoryItem);
                fridge.AddIngredientToFridge(inventoryItem);

                Assert.AreEqual(1, fakeInventoryRepository.InventoryItems.Count);
                Assert.AreEqual(inventoryName, fakeInventoryRepository.InventoryItems[0].Name);
                Assert.AreEqual(20, fakeInventoryRepository.InventoryItems[0].Quantity);
            }
コード例 #2
0
ファイル: FridgeTests.cs プロジェクト: kjelag/Fridge
            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));
            }
コード例 #3
0
ファイル: FridgeTests.cs プロジェクト: kjelag/Fridge
            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));
            }
コード例 #4
0
ファイル: FridgeTests.cs プロジェクト: kjelag/Fridge
            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));
            }
コード例 #5
0
ファイル: FridgeTests.cs プロジェクト: kjelag/Fridge
            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);
            }
コード例 #6
0
ファイル: FridgeTests.cs プロジェクト: kjelag/Fridge
            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);
            }
コード例 #7
0
ファイル: FridgeTests.cs プロジェクト: kjelag/Fridge
            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);
            }
コード例 #8
0
 public void AddIngredientToFridge(string name, double quantity)
 {
     _fridgeService.AddIngredientToFridge(new InventoryItem(name, quantity));
 }