public void DrinkService_Order_DrinkWithoutData_2() { // Arrange var drinkService = new DrinkService(); var drink = new Drink(); // Act BadParametersException exception = Assert.Throws <BadParametersException>( delegate { drinkService.OrderAsync(drink).GetAwaiter().GetResult(); }); // Assert Assert.That(exception.Message, Is.EqualTo("The drink type should be tea, coffee or chocolate.")); }
public void DrinkService_Order_BadNumberSugars(string drinkType, float money, int sugars, int extraHot) { // Arrange var drinkService = new DrinkService(); var drink = new Drink { DrinkType = drinkType, Money = money, Sugars = sugars, ExtraHot = extraHot, }; // Act BadParametersException exception = Assert.Throws <BadParametersException>( delegate { drinkService.OrderAsync(drink).GetAwaiter().GetResult(); }); // Assert Assert.AreEqual("The number of sugars should be between 0 and 2.", exception.Message); }
public void DrinkService_Order_InventedDrink() { // Arrange var drinkService = new DrinkService(); var drink = new Drink { DrinkType = "invented drink", Money = 0.8F, Sugars = 1, ExtraHot = 1, }; // Act BadParametersException exception = Assert.Throws <BadParametersException>( delegate { drinkService.OrderAsync(drink).GetAwaiter().GetResult(); }); // Assert Assert.AreEqual("The drink type should be tea, coffee or chocolate.", exception.Message); }
public void DrinkService_Order_MoneyNotEnought(string drinkType, float money, int sugars, int extraHot) { // Arrange var drinkService = new DrinkService(); var drink = new Drink { DrinkType = drinkType, Money = money, Sugars = sugars, ExtraHot = extraHot, }; // Act BadParametersException exception = Assert.Throws <BadParametersException>( delegate { drinkService.OrderAsync(drink).GetAwaiter().GetResult(); }); // Assert Assert.AreEqual( string.Format( "The {0} costs {1}.", drinkService.DrinkPrices.Single(x => x.Name.ToLower() == drink.DrinkType.ToLower()).Name, drinkService.DrinkPrices.Single(x => x.Name.ToLower() == drink.DrinkType.ToLower()).Price.ToString("N", new System.Globalization.CultureInfo("en-US"))), exception.Message); }