public void Calculate_ReturnsZeroDiscount_WhenNullProductsListIsPassed(string discountName, int priceThreshold, int discountPercentage) { //Arrange var priceThresholdDiscount = new PriceThresholdDiscountRule(discountName, priceThreshold, discountPercentage); //Act var appliedDiscount = priceThresholdDiscount.Calculate(null); //Assert appliedDiscount.Should().Be(0); }
public void Calculate_ReturnsZeroDiscount_WhenTotalPriceIsBelowThreshold(string discountName, int priceThreshold, int discountPercentage) { //Arrange var packageDiscount = new PriceThresholdDiscountRule(discountName, priceThreshold, discountPercentage); var productsInTheBasket = GetProducts(priceThreshold - 1); //Act var appliedDiscount = packageDiscount.Calculate(productsInTheBasket); //Assert appliedDiscount.Should().Be(0); }
public void Calculate_ReturnsSingleDiscount_WhenDiscountConditionsAreMetMultipleTimes(string discountName, int priceThreshold, int discountPercentage) { //Arrange var priceThresholdDiscount = new PriceThresholdDiscountRule(discountName, priceThreshold, discountPercentage); var productsInTheBasket = GetProducts(5 * priceThreshold).ToList(); //Act var appliedDiscount = priceThresholdDiscount.Calculate(productsInTheBasket); var productsSum = productsInTheBasket.Sum(m => m.Price); //Assert appliedDiscount.Should().Be(-(discountPercentage * productsSum) / 100); }