Beispiel #1
0
        public void Calculate_ReturnsZeroDiscount_WhenNullProductsListIsPassed(string discountName, decimal discountAmount, string[] packageProductNames)
        {
            //Arrange
            var packageDiscount = new PackageDiscountRule(discountName, discountAmount, packageProductNames);

            //Act
            var appliedDiscount = packageDiscount.Calculate(null);

            //Assert
            appliedDiscount.Should().Be(0);
        }
Beispiel #2
0
        public void Calculate_ReturnsZeroDiscount_WhenDiscountConditionsAreNotMet(string discountName, decimal discountAmount, string[] packageProductNames)
        {
            //Arrange
            var packageDiscount     = new PackageDiscountRule(discountName, discountAmount, packageProductNames);
            var productsInTheBasket = GetProducts(packageProductNames.Take(packageProductNames.Length - 1));

            //Act
            var appliedDiscount = packageDiscount.Calculate(productsInTheBasket);

            //Assert
            appliedDiscount.Should().Be(0);
        }
Beispiel #3
0
        public void Calculate_ReturnsMultipleDiscounts_WhenDiscountConditionsAreMetMultipleTimes(string discountName, decimal discountAmount, string[] packageProductNames)
        {
            //Arrange
            var packageDiscount     = new PackageDiscountRule(discountName, discountAmount, packageProductNames);
            var productsInTheBasket = GetProducts(packageProductNames.Concat(packageProductNames));

            //Act
            var appliedDiscount = packageDiscount.Calculate(productsInTheBasket);

            //Assert
            appliedDiscount.Should().Be(2 * discountAmount);
        }