Beispiel #1
0
        public void Checkout_WhenTwoOfTheSameBooksArePurchased_ReturnsPriceOf16()
        {
            var bookshop = new Bookshop();

            bookshop.AddToBasket("first");
            bookshop.AddToBasket("first");
            var checkoutTotal = bookshop.CheckoutBasket();

            var expected = 16M;

            Assert.Equal(expected, checkoutTotal.DiscountedPriceTotal);
        }
Beispiel #2
0
        public void Checkout_WhenTwoOfEveryBooksIsPurchased_ReturnsDiscountedPrice()
        {
            var bookshop = new Bookshop();

            bookshop.AddToBasket("first");
            bookshop.AddToBasket("second");
            bookshop.AddToBasket("third");
            bookshop.AddToBasket("fourth");
            bookshop.AddToBasket("fifth");
            bookshop.AddToBasket("first");
            bookshop.AddToBasket("second");
            bookshop.AddToBasket("third");
            bookshop.AddToBasket("fourth");
            bookshop.AddToBasket("fifth");
            var checkoutTotal = bookshop.CheckoutBasket();

            var expected = 60M;

            Assert.Equal(expected, checkoutTotal.DiscountedPriceTotal);
        }
Beispiel #3
0
        public void Checkout_WhenSinglePotterBookIsPurchased_ReturnsPriceOf8(string bookNumber)
        {
            var bookshop = new Bookshop();

            bookshop.AddToBasket(bookNumber);
            var checkoutTotal = bookshop.CheckoutBasket();

            var expected = 8M;

            Assert.Equal(expected, checkoutTotal.DiscountedPriceTotal);
        }
Beispiel #4
0
        public void Checkout_WhenNoBooksArePurchased_ReturnsPriceOf0()
        {
            var bookshop = new Bookshop();

            bookshop.AddToBasket("");
            var checkoutTotal = bookshop.CheckoutBasket();

            var expected = 0;

            Assert.Equal(expected, checkoutTotal.DiscountedPriceTotal);
        }
Beispiel #5
0
        public void Checkout_WhenOnlyDifferentBooksArePurchased_ReturnsCorrectDiscountedPrice(string[] purchasedBooks, decimal expected)
        {
            var bookshop = new Bookshop();

            foreach (string book in purchasedBooks)
            {
                bookshop.AddToBasket(book);
            }
            ;
            var checkoutTotal = bookshop.CheckoutBasket();

            Assert.Equal(expected, checkoutTotal.DiscountedPriceTotal);
        }
Beispiel #6
0
        public void Checkout_WhenMultipleDiscountsArePossible_ReturnsLowestDiscountedPrices(string[] purchasedBooks, decimal expected)
        {
            var bookshop = new Bookshop();

            foreach (string book in purchasedBooks)
            {
                bookshop.AddToBasket(book);
            }
            ;

            var checkoutTotal = bookshop.CheckoutBasket();

            Assert.Equal(expected, checkoutTotal.DiscountedPriceTotal);
        }