예제 #1
0
        public void TestBasketWithMultipleQualifyingDistcountProductWithMultipleSameProductOddNumber()
        {
            // arrange
            decimal expectedValue = 3.05M;

            var products = new List <string>();

            products.Add("A99");
            products.Add("B15");
            products.Add("A99");
            products.Add("A99");
            products.Add("B15");
            products.Add("A99");
            products.Add("A99");
            products.Add("B15");

            var engine = new CheckoutEngine();

            // act
            var checkoutEngine = new CheckoutEngine();
            var result         = checkoutEngine.CalculateBasket(products);

            // assert
            Assert.AreEqual(expectedValue, result);
        }
예제 #2
0
        public void TestNullProductList()
        {
            // arrange
            var expectedError = "Products cannot be null or empty.";

            try
            {
                // act
                var checkoutEngine = new CheckoutEngine();
                var result         = checkoutEngine.CalculateBasket(null);
            }
            catch (ArgumentException ex)
            {
                // assert
                Assert.AreEqual(expectedError, ex.ParamName);
            }
        }
예제 #3
0
        public void TestBasketWithUnknownProduct()
        {
            // arrange
            decimal expectedValue = 0.00M;

            var products = new List <string>();

            products.Add("A88");

            var engine = new CheckoutEngine();

            // act
            var checkoutEngine = new CheckoutEngine();
            var result         = checkoutEngine.CalculateBasket(products);

            // assert
            Assert.AreEqual(expectedValue, result);
        }
예제 #4
0
        public void TestBasketWithNoQualifyingDiscountProduct()
        {
            // arrange
            decimal expectedValue = 3.29M;

            var products = new List <string>();

            products.Add("A99");
            products.Add("C40");
            products.Add("T23");

            var engine = new CheckoutEngine();

            // act
            var checkoutEngine = new CheckoutEngine();
            var result         = checkoutEngine.CalculateBasket(products);

            // assert
            Assert.AreEqual(expectedValue, result);
        }
예제 #5
0
        public async Task <decimal> CalculateBasket(List <string> products)
        {
            var checkoutEngine = new CheckoutEngine();

            return(await Task.FromResult(checkoutEngine.CalculateBasket(products)));
        }