public void Compran2LibrosIguales() { // Arrange var calc = new PriceCalculator(); var cart = new ShoppingCart(); float expectedPrice = pricePerBook * 2; // Act cart.AddBook(new Book("Libro 1", pricePerBook)); cart.AddBook(new Book("Libro 1", pricePerBook)); float totalPrice = calc.CalculatePrice(cart.Books); // Assert Assert.AreEqual(expectedPrice, totalPrice); }
public void Compran3LibrosDistintos() { // Arrange var calc = new PriceCalculator(); var cart = new ShoppingCart(); float discount = 0.1F; float expectedPrice = pricePerBook * 3 * (1 - discount); // Act cart.AddBook(new Book("Libro 1", pricePerBook)); cart.AddBook(new Book("Libro 2", pricePerBook)); cart.AddBook(new Book("Libro 3", pricePerBook)); float totalPrice = calc.CalculatePrice(cart.Books); // Assert Assert.AreEqual(expectedPrice, totalPrice); }
public void Compran5CopiasDeTodaLaColeccion() { // Arrange var calc = new PriceCalculator(); var cart = new ShoppingCart(); float discount = 0.45F; float expectedPrice = (pricePerBook * 7 * (1 - discount)) * 5; // Act CargarColeccionCompleta(cart); CargarColeccionCompleta(cart); CargarColeccionCompleta(cart); CargarColeccionCompleta(cart); CargarColeccionCompleta(cart); float totalPrice = calc.CalculatePrice(cart.Books); // Assert Assert.AreEqual(expectedPrice, totalPrice); }