public void Make_Beverage_When_The_Minimum_Amount_Is_Set(string orderType, int sugarCount, decimal amount, bool extraHot, string expected) { // Arrange Command order; if (orderType == "T") { order = new TeaCommand(sugarCount, sugarCount > 0, extraHot); } else if (orderType == "C") { order = new CoffeeCommand(sugarCount, sugarCount > 0, extraHot); } else if (orderType == "H") { order = new ChocolateCommand(sugarCount, sugarCount > 0, extraHot); } else if (orderType == "H") { order = new ChocolateCommand(sugarCount, sugarCount > 0, extraHot); } else //if (orderType == "O") { order = new OrangeCommand(); } // Act string actual = _coffeeMachine.Instruct(order, amount); // Assert Assert.Equal(expected, actual); }
public void ProtocolMessages() { //"T:1:0"(Drink maker makes 1 tea with 1 sugar and a stick) //"H::"(Drink maker makes 1 chocolate with no sugar - and therefore no stick) //"C:2:0"(Drink maker makes 1 coffee with 2 sugars and a stick) //"M:message-content"(Drink maker forwards any message received // onto the coffee machine interface for the customer to see) var cm = new CoffeeMachine(); var coffee = new CoffeeCommand(); var tea = new TeaCommand(3); var hotChocolate = new ExtraHotChocolateCommand(1); var orangeJuice = new OrangeJuiceCommand(); var message = new MessageCommand("HelloWorld!"); var c = cm.Order(coffee, 1); var t = cm.Order(tea, 1); var h = cm.Order(hotChocolate, 1); var o = cm.Order(orangeJuice, 1); var msg = cm.Order(message); var fail = cm.Order(null, 1); Assert.AreEqual(c, "C::"); Assert.AreEqual(t, "T:2:0"); Assert.AreEqual(h, "Hh:1:0"); Assert.AreEqual(o, "O::"); Assert.AreEqual(msg, "M:HelloWorld!"); Assert.That(fail, Is.Null); }
public void CommandPrices() { var coffee = new CoffeeCommand(); var chocolate = new ChocolateCommand(); var tea = new TeaCommand(); var oj = new OrangeJuiceCommand(); Assert.AreEqual(coffee.Price, 0.6); Assert.AreEqual(chocolate.Price, 0.5); Assert.AreEqual(tea.Price, 0.4); Assert.AreEqual(oj.Price, 0.6); }
public void Notify_User_About_A_Tea_Shortage_And_Send_An_Email() { // Arrange _mockedBeverageQuantityChecker .Setup(x => x.IsEmpty(It.IsAny <string>())) .Returns(true); string expectedMessage = "M:There's a shortage with 'Tea'. A notification was sent to our customer service."; // Act BeverageCommand command = new TeaCommand(0, false, false); string instruction = _coffeeMachine.Instruct(command, command.Price); // Assert Assert.Equal(instruction, expectedMessage); _mockedEmailNotifier.Verify(x => x.NotifyMissingDrink("T"), Times.Once); }
public void RegisteredReport() { var cm = new CoffeeMachine(); var coffee = new CoffeeCommand(); var tea = new TeaCommand(); cm.Order(coffee); cm.Order(tea, 1); cm.Order(tea, 1); cm.Order(tea, 1); cm.Order(tea, 1); cm.Order(tea, 1); Assert.That(cm.Report, Is.Not.Null); Assert.AreEqual(cm.Report.CoffeeSold, 0); Assert.AreEqual(cm.Report.TeaSold, 5); Assert.AreEqual(cm.Report.Credits, 2); }