public void AppliesDiscount_ToReleventProduct_ForMoreThanOneOneProduct()
        {
            // Arrange
            var sut             = new BuyXGetPercentageFree("Bread", "Beans", 2, 0.50m);
            var _productsInCart = new List <ProductInCart>()
            {
                new ProductInCart()
                {
                    Product = new Product("Beans", 1.30M), Quantity = 2
                },
                new ProductInCart()
                {
                    Product = new Product("Bread", .80M), Quantity = 1
                },
                new ProductInCart()
                {
                    Product = new Product("Apples", 1.00M), Quantity = 1
                },
            };

            // Act
            var result = sut.ApplyDiscount(_productsInCart);

            // Assert
            Assert.Single(result);
            Assert.Equal(.40M, result.First().DiscountAmount);
        }
        public void AppliesNoDiscount_ForNonApplicableProduct()
        {
            // Arrange
            var sut             = new BuyXGetPercentageFree("Bread", "Beans", 2, 0.50m);
            var _productsInCart = new List <ProductInCart>()
            {
                new ProductInCart()
                {
                    Product = new Product("Milk", 1.30M), Quantity = 2
                },
                new ProductInCart()
                {
                    Product = new Product("Bread", .80M), Quantity = 1
                }
            };

            // Act
            var result = sut.ApplyDiscount(_productsInCart);

            // Assert
            Assert.False(result.Any());
        }
        public void AppliesDiscount_BuyXGetYPercentageFree(int x, int quantityX, int quantityY, decimal percentage, decimal expected)
        {
            // Arrange
            var sut             = new BuyXGetPercentageFree("Bread", "Beans", x, percentage);
            var _productsInCart = new List <ProductInCart>()
            {
                new ProductInCart()
                {
                    Product = new Product("Beans", 1.30M), Quantity = quantityX
                },
                new ProductInCart()
                {
                    Product = new Product("Bread", .80M), Quantity = quantityY
                }
            };

            // Act
            var result = sut.ApplyDiscount(_productsInCart);

            // Assert
            Assert.Single(result);
            Assert.Equal(expected, result.First().DiscountAmount);
        }