public void CanGetCappInMenuWhenIngredientsAreAvailable() { var coffeeMachine = new CoffeeMachine.CoffeeMachine(true, 22, 3, 4, 5, _refiller); Assert.Contains(BeverageType.Capp, coffeeMachine.GetMenu()); }
static void Main(string[] args) { CoffeeMachine machine = new CoffeeMachine(); while (true) { string input = Console.ReadLine(); if (input.Equals("End")) { break; } string[] inputArg = input.Split(); if (inputArg.Length == 1) { string coin = inputArg[0]; machine.InsertCoin(coin); } else { string coffeeQuantity = inputArg[0]; string coffeeType = inputArg[1]; machine.BuyCoffee(coffeeQuantity, coffeeType); } } foreach (var soldCoffee in machine.CoffeesSold) { Console.WriteLine(soldCoffee); } }
public void CanGetMenuWhenThereIsPower() { var coffeeMachine = new CoffeeMachine.CoffeeMachine(true, 2, 3, 4, 5, _refiller); Assert.IsNotNull(coffeeMachine.GetMenu()); }
public void CanResistABadRefillerThatChangesIngredientsIntoNegatives() { IRefiller.IRefiller newRefiller = new BadRefillerStub(); var coffeeMachine = new CoffeeMachine.CoffeeMachine(true, 24, 3, 4, 1, newRefiller); Assert.Throws <Exception>(() => coffeeMachine.RefillMachine()); }
public void CanNotGetMenuWhenThereIsNoPower() { var coffeeMachine = new CoffeeMachine.CoffeeMachine(false, 2, 3, 4, 5, new ElectricRefiller.ElectricRefiller()); Assert.Throws <Exception>(() => coffeeMachine.GetMenu()); }
public static void TestCase_NotEnoughResources() { var cm = new CoffeeMachine("Nescafe", 10, 10, 10, 10); float cash = 50.0F; cash = cm.MakeDrink(Drink.Americano, cash); Require.That(cash == 50); }
static void Main(string[] args) { CoffeeMachine coffeeMachine = new CoffeeMachine(); coffeeMachine.Start(); coffeeMachine.WaterAmount = 1000; coffeeMachine.BoilWater(); Console.ReadKey(); }
private static CoffeeMachine CreateFilledCoffeeMachine() { var cm = new CoffeeMachine("Nescafe", 10, 10, 10, 10); cm.FillCoffeeTank(); cm.FillMilkTank(); cm.FillWaterTank(); cm.FillSugarTank(); return(cm); }
public void CanNotRefillWhenIngredientsAreNegativeNumbers() { IRefiller.IRefiller newRefiller = new RefillerMock(); var coffeeMachine = new CoffeeMachine.CoffeeMachine(true, 10, 3, 4, 1, newRefiller); coffeeMachine.RefillMachine(); Assert.IsFalse(coffeeMachine.GetMenu().Contains(BeverageType.Capp)); }
public void CanSubstractFromCoffeeMachingWhenCapIsMAde() { var coffeeMachine = new CoffeeMachine.CoffeeMachine(true, 14, 20, 4, 10, _refiller); coffeeMachine.MakeBeverage(BeverageType.Capp); global::Ingredients.Ingredients remainingIngredients = new global::Ingredients.Ingredients(2, 19.7, 3.9, 9); Assert.IsTrue(coffeeMachine.hasIngredients(remainingIngredients)); }
public static void TestCase_EmptyTanks() { // Preparation: var cm = new CoffeeMachine("Nescafe", 10, 10, 10, 10); // Expectation: Require.That(cm.Coffee == 0, "Coffee tank is not empty."); Require.That(cm.Milk == 0, "Milk tank is not empty."); Require.That(cm.Water == 0, "Water tank is not empty."); Require.That(cm.Sugar == 0, "Sugar tank is not empty."); }
public void GivenARefillerWithNegativeNumbersMachineShouldNotRefill() { var refiller = new Mock <IRefiller.IRefiller>(); refiller.Setup(s => s.Refill(It.IsAny <double>(), It.IsAny <double>(), It.IsAny <int>(), It.IsAny <int>())) .Returns(new Ingredients.Ingredients(10, 10, 10, 10)); var coffeeMachine = new CoffeeMachine.CoffeeMachine(true, 10, 10, 10, 10, refiller.Object); Assert.Throws <Exception>(() => coffeeMachine.RefillMachine()); }
static void Main(string[] args) { var refiller = new Refiller.SolarRefiller(); var firstCoffeeMachine = new CoffeeMachine(true, 12, 10, 10, 0, refiller); var consoleServices = new ConsoleOperations(); var coffeeMachineScreen = new CofeeMachineScreen(consoleServices, firstCoffeeMachine); coffeeMachineScreen.Interact(); }
public void CanGetLatteWhenCantMakeCap() { var coffeeMachine = new CoffeeMachine.CoffeeMachine(true, 24, 3, 4, 1, _refiller); Assert.Contains(BeverageType.Latte, coffeeMachine.GetMenu()); Assert.Contains(BeverageType.Capp, coffeeMachine.GetMenu()); Assert.IsNotNull(coffeeMachine.MakeBeverage(BeverageType.Capp)); Assert.Contains(BeverageType.Latte, coffeeMachine.GetMenu()); Assert.IsFalse(coffeeMachine.GetMenu().Contains(BeverageType.Capp)); Assert.IsNotNull(coffeeMachine.MakeBeverage(BeverageType.Latte)); }
public static void TestCase_ModelNameWithSpace() { bool catched = false; try { var cm = new CoffeeMachine("Mama Mia", 10, 10, 10, 10); } catch (Exception) { catched = true; } Require.That(catched); }
public static void TestCase_FilledTanks() { var cm = new CoffeeMachine("Nescafe", 10, 10, 10, 10); cm.FillCoffeeTank(); Require.That(cm.Coffee == 10, "Coffee tank is not filled."); cm.FillMilkTank(); Require.That(cm.Milk == 10, "Milk tank is not filled."); cm.FillWaterTank(); Require.That(cm.Water == 10, "Water tank is not filled."); cm.FillSugarTank(); Require.That(cm.Sugar == 10, "Sugar tank is not filled."); }
public void DoesntShowNotAvailableAtTheMomentWhenAllDrinksAreAvailable() { //Arrange IRefiller.IRefiller newRefiller = new RefillerMock(); CoffeeMachine.CoffeeMachine testCoffeMachine = new CoffeeMachine.CoffeeMachine(true, 20, 20, 20, 20, newRefiller); var consoleOperationsMock = new Mock <IOConsoleService>(); CofeeMachineScreen testScreen = new CofeeMachineScreen(consoleOperationsMock.Object, testCoffeMachine); //act testScreen.HandleChoice("m"); //Assert consoleOperationsMock.Verify(m => m.Write("Not available at the moment: "), Times.Never()); }
static void Main(string[] args) { CoffeePowder coffe = new CoffeePowder(100); GalonAir water = new GalonAir(1000); Milk milk = new Milk(300); CoffeeMachine yummyCoffe = new CoffeeMachine(coffe, water, milk); //1st cup coffe Console.WriteLine("check " + yummyCoffe.checkAvailability()); String result = yummyCoffe.makeCappucino(); Console.WriteLine("result " + result); //2nd cup coffe Console.WriteLine("check " + yummyCoffe.checkAvailability()); result = yummyCoffe.makeEsspresso(); Console.WriteLine("result " + result); //3nd cup coffe Console.WriteLine("check " + yummyCoffe.checkAvailability()); result = yummyCoffe.makeEsspresso(); Console.WriteLine("result " + result); //4nd cup coffe Console.WriteLine("check " + yummyCoffe.checkAvailability()); result = yummyCoffe.makeCappucino(); Console.WriteLine("result " + result); //5nd cup coffe Console.WriteLine("check " + yummyCoffe.checkAvailability()); result = yummyCoffe.makeCappucino(); Console.WriteLine("result " + result); //6nd cup coffe Console.WriteLine("check " + yummyCoffe.checkAvailability()); result = yummyCoffe.makeEsspresso(); Console.WriteLine("result " + result); Console.WriteLine("check " + yummyCoffe.checkAvailability()); }
//TODO: 1. Hæld vand i en beholder alt afhængig af hvor mange kopper man ønsker //TODO: 2. indsæt filter //TODO: 3. hæld kaffebønner i maskinen //TODO: 4. Tænd kaffemaskinen //TODO: Change how watertank works static void Main(string[] args) { Console.WriteLine("Hello World!"); CoffeeMachine coffee = new CoffeeMachine(2, "Coffee", "CoffeeBeans", 2); coffee.TurnMachineOn(); coffee.TurnMachineOff(); TeaMachine tea = new TeaMachine(2, "Tea", "Tealeaves", 4); tea.TurnMachineOn(); tea.TurnMachineOff(); EspressoMachine espresso = new EspressoMachine("Espresso", "Coffebeans", EspressoMachine.EspressoShotsInGram.Two); espresso.TurnMachineOn(); espresso.TurnMachineOff(); }
public void CanShowMenu() { //Arrange IRefiller.IRefiller newRefiller = new RefillerMock(); CoffeeMachine.CoffeeMachine testCoffeMachine = new CoffeeMachine.CoffeeMachine(true, 10, 10, 10, 10, newRefiller); var consoleOperationsMock = new Mock <IOConsoleService>(); CofeeMachineScreen testScreen = new CofeeMachineScreen(consoleOperationsMock.Object, testCoffeMachine); //act testScreen.HandleChoice("m"); //Assert consoleOperationsMock.Verify( m => m.Write(It.Is <string>(c => c == "Here is your menu:"))); consoleOperationsMock.Verify( m => m.Write(It.Is <string>(c => c == "1: HotChoc"))); consoleOperationsMock.Verify( m => m.Write(It.Is <string>(c => c == "2: Tea"))); consoleOperationsMock.Verify( m => m.Write(It.Is <string>(c => c == "Not available at the moment: "))); consoleOperationsMock.Verify( m => m.Write(It.Is <string>(c => c == "Capp"))); consoleOperationsMock.Verify( m => m.Write(It.Is <string>(c => c == "Latte"))); consoleOperationsMock.Verify( m => m.Write(It.Is <string>(c => c == "LongBlack"))); consoleOperationsMock.Verify( m => m.Write(It.Is <string>(c => c == "Espresso"))); consoleOperationsMock.Verify( m => m.Write(It.Is <string>(c => c == "Mocca"))); consoleOperationsMock.Verify( m => m.Write(It.Is <string>(c => c == "Choose a drink, type 'm' to see menu or 'r' to refill or 'e' to exit."))); }
public void CanRefillWithRefillerThatSupportsRefilling() { // Arrange: // Create the fake Refiller: IRefiller.IRefiller newRefiller = new RefillerStub(); var coffeeMachine = new CoffeeMachine.CoffeeMachine(true, 24, 3, 4, 1, newRefiller); Assert.Contains(BeverageType.Latte, coffeeMachine.GetMenu()); Assert.Contains(BeverageType.Capp, coffeeMachine.GetMenu()); Assert.IsNotNull(coffeeMachine.MakeBeverage(BeverageType.Capp)); Assert.Contains(BeverageType.Latte, coffeeMachine.GetMenu()); Assert.IsFalse(coffeeMachine.GetMenu().Contains(BeverageType.Capp)); Assert.IsNotNull(coffeeMachine.MakeBeverage(BeverageType.Latte)); coffeeMachine.RefillMachine(); Assert.Contains(BeverageType.Latte, coffeeMachine.GetMenu()); Assert.Contains(BeverageType.Capp, coffeeMachine.GetMenu()); }
static void Main(string[] args) { CoffeeMachine machine = new CoffeeMachine(); string input; while ((input = Console.ReadLine()) != "End") { string[] inputArgs = input.Split(); if (inputArgs.Length == 1) { machine.InsertCoin(inputArgs[0]); } else { machine.BuyCoffee(inputArgs[0], inputArgs[1]); } } foreach (var coffeeType in machine.CoffeesSold) { Console.WriteLine(coffeeType); } Console.ReadLine(); }
public void CanNotMakeCappWithoutWater() { var coffeeMachine = new CoffeeMachine.CoffeeMachine(true, 14, 0, 4, 10, _refiller); Assert.IsNull(coffeeMachine.MakeBeverage(BeverageType.Capp)); }
public CofeeMachineScreen(IOConsoleService iOConsoleService, CoffeeMachine coffeeMachine) { _iOConsoleService = iOConsoleService; _coffeeMachine = coffeeMachine; }
static void Main(string[] args) { Console.SetCursorPosition(Console.WindowWidth / 3, 0); Console.ForegroundColor = ConsoleColor.Magenta; Console.WriteLine("----Welcome To The Coffee House----"); Console.ForegroundColor = ConsoleColor.Green; CoffeeMachine machine = new CoffeeMachine(); machine.PrintProducts(); Console.WriteLine(); do { Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine(); link1: Console.Write("Insert Your Coin => "); bool successMoney = false; while (!successMoney) { try { Console.ForegroundColor = ConsoleColor.Green; machine.Money = int.Parse(Console.ReadLine()); successMoney = true; } catch (Exception e) { Console.ForegroundColor = ConsoleColor.DarkRed; Console.Write("Insert Correct Coin! " + " => "); } } link2: Console.ForegroundColor = ConsoleColor.Green; Console.Write("Enter Number Of Coffee From 1 To 10 => "); bool successCoffeeNum = false; while (!successCoffeeNum) { try { Console.ForegroundColor = ConsoleColor.Green; machine.CoffeeNum = int.Parse(Console.ReadLine()); successCoffeeNum = true; } catch (Exception e) { Console.ForegroundColor = ConsoleColor.DarkRed; Console.Write("Enter Correct Number Of Coffee " + " => "); } } Coffee usersCoffee = new Coffee(); try { usersCoffee = machine.MakeCoffee(); } catch (IngridientException e) { Console.ForegroundColor = ConsoleColor.DarkRed; Console.WriteLine(e.Message); Console.WriteLine("Please Select Another Coffee"); goto link2; } catch (MoneyException eMoney) { Console.ForegroundColor = ConsoleColor.DarkRed; Console.WriteLine(eMoney.Message); machine.Money = 0; Console.WriteLine("Take Your Money Back And Try Again"); goto link1; } Console.ForegroundColor = ConsoleColor.DarkYellow; Console.WriteLine("Your " + usersCoffee.Name + " Is Ready!"); link3: Console.Write("Enter '0' To Finish..."); ConsoleKeyInfo info = Console.ReadKey(); if (info.Key == ConsoleKey.D0 || info.Key == ConsoleKey.NumPad0) { Console.WriteLine(); Console.ForegroundColor = ConsoleColor.DarkRed; int cashBack = machine.Money - usersCoffee.Price; if (cashBack == 0) { Console.WriteLine("You Don't Have Change..."); } else { Console.WriteLine("Your Change Is " + cashBack); } Console.ForegroundColor = ConsoleColor.Green; Console.Write("If You Want Another Coffee Press Enter"); } else { Console.WriteLine(); goto link3; } machine.SaveChangesInFile(); Console.WriteLine(); Console.WriteLine(); machine.Money = 0; }while (Console.ReadKey().Key == ConsoleKey.Enter); }
public void CanCreateCoffeeMachine() { var coffeeMachine = new CoffeeMachine.CoffeeMachine(true, 2, 3, 4, 5, _refiller); Assert.IsNotNull(coffeeMachine); }
public void CanNotGetCappInMenuWhenChockNotEnaugh() { var coffeeMachine = new CoffeeMachine.CoffeeMachine(true, 12, 3, 4, 0, _refiller); Assert.IsFalse(coffeeMachine.GetMenu().Contains(BeverageType.Capp)); }
public void CanMakeCapp() { var coffeeMachine = new CoffeeMachine.CoffeeMachine(true, 14, 3, 4, 10, _refiller); Assert.IsNotNull(coffeeMachine.MakeBeverage(BeverageType.Capp)); }
static void Main(string[] args) { CoffeeMachine coffeeMachine = new CoffeeMachine(); coffeeMachine.Start(); }