Example #1
0
        public void BuyTwoSetsOfFiveAndTwoSetsOfThree()
        {
            var shoppingCart = new List <Book>();
            var calculator   = new ShoppingCartCalculator();

            for (int i = 0; i < 4; i++)
            {
                shoppingCart.Add(new Book(1));
            }

            for (int i = 0; i < 4; i++)
            {
                shoppingCart.Add(new Book(2));
            }
            for (int i = 0; i < 4; i++)
            {
                shoppingCart.Add(new Book(3));
            }
            for (int i = 0; i < 2; i++)
            {
                shoppingCart.Add(new Book(4));
            }
            for (int i = 0; i < 2; i++)
            {
                shoppingCart.Add(new Book(5));
            }

            var actual = calculator.Calculate(shoppingCart);

            Assert.AreEqual(102.4M, actual);
        }
Example #2
0
        public void BuyOneBook()
        {
            List <Book> shoppingCart = new List <Book>();
            var         book         = new Book(1);

            shoppingCart.Add(book);

            ShoppingCartCalculator calculator = new ShoppingCartCalculator();

            var actual = calculator.Calculate(shoppingCart);

            Assert.AreEqual(8M, actual);
        }
Example #3
0
        public void BuyOneBook()
        {
            List<Book> shoppingCart = new List<Book>();
            var book = new Book(1);

            shoppingCart.Add(book);

            ShoppingCartCalculator calculator = new ShoppingCartCalculator();

            var actual = calculator.Calculate(shoppingCart);

            Assert.AreEqual(8M, actual);
        }
Example #4
0
        public void BuyTwoBookOfSameType()
        {
            List <Book> shoppingCart = new List <Book>();
            var         book         = new Book(1);
            var         book2        = new Book(1);

            shoppingCart.Add(book);
            shoppingCart.Add(book2);

            ShoppingCartCalculator calculator = new ShoppingCartCalculator();

            var actual = calculator.Calculate(shoppingCart);

            Assert.AreEqual(16M, actual);
        }
Example #5
0
        public void BuyThreeBooksOfDifferentType()
        {
            List <Book> shoppingCart = new List <Book>();
            var         book         = new Book(1);
            var         book2        = new Book(2);
            var         book3        = new Book(3);

            shoppingCart.Add(book);
            shoppingCart.Add(book2);
            shoppingCart.Add(book3);

            ShoppingCartCalculator calculator = new ShoppingCartCalculator();

            var actual = calculator.Calculate(shoppingCart);

            Assert.AreEqual(21.6M, actual);
        }
Example #6
0
        public void BuyThreeBooksOfDifferentType()
        {
            List<Book> shoppingCart = new List<Book>();
            var book = new Book(1);
            var book2 = new Book(2);
            var book3 = new Book(3);

            shoppingCart.Add(book);
            shoppingCart.Add(book2);
            shoppingCart.Add(book3);

            ShoppingCartCalculator calculator = new ShoppingCartCalculator();

            var actual = calculator.Calculate(shoppingCart);

            Assert.AreEqual(21.6M, actual);
        }
Example #7
0
        public void Buy148()
        {
            List <Book> shoppingCart = new List <Book>();

            for (int i = 0; i < 100; i++)
            {
                shoppingCart.Add(new Book(1));
            }
            for (int i = 0; i < 48; i++)
            {
                shoppingCart.Add(new Book(2));
            }

            ShoppingCartCalculator calculator = new ShoppingCartCalculator();

            var actual = calculator.Calculate(shoppingCart);

            Assert.AreEqual(1145.6M, actual);
        }
Example #8
0
        public void Buy148()
        {
            List<Book> shoppingCart = new List<Book>();

            for (int i = 0; i < 100; i++)
            {
                shoppingCart.Add(new Book(1));
            }
            for (int i = 0; i < 48; i++)
            {
                shoppingCart.Add(new Book(2));
            }

            ShoppingCartCalculator calculator = new ShoppingCartCalculator();

            var actual = calculator.Calculate(shoppingCart);

            Assert.AreEqual(1145.6M, actual);
        }
Example #9
0
        public void BuyEightBooksVariousType()
        {
            List <Book> shoppingCart = new List <Book>()
            {
                new Book(1),
                new Book(1),
                new Book(2),
                new Book(2),
                new Book(3),
                new Book(3),
                new Book(4),
                new Book(5),
            };

            ShoppingCartCalculator calculator = new ShoppingCartCalculator();

            var actual = calculator.Calculate(shoppingCart);

            Assert.AreEqual(51.20M, actual);
        }
Example #10
0
        public void BuyEightBooksVariousType()
        {
            List<Book> shoppingCart = new List<Book>()
            {
                new Book(1),
                new Book(1),
                new Book(2),
                new Book(2),
                new Book(3),
                new Book(3),
                new Book(4),
                new Book(5),
            };

            ShoppingCartCalculator calculator = new ShoppingCartCalculator();

            var actual = calculator.Calculate(shoppingCart);

            Assert.AreEqual(51.20M, actual);
        }
Example #11
0
        public void BuyTwoSetsOfFiveAndTwoSetsOfThree()
        {
            var shoppingCart = new List<Book>();
            var calculator = new ShoppingCartCalculator();

            for (int i = 0; i < 4; i++)
            {
                shoppingCart.Add(new Book(1));
            }

            for (int i = 0; i < 4; i++)
            {
                shoppingCart.Add(new Book(2));
            }
            for (int i = 0; i < 4; i++)
            {
                shoppingCart.Add(new Book(3));
            }
            for (int i = 0; i < 2; i++)
            {
                shoppingCart.Add(new Book(4));
            }
            for (int i = 0; i < 2; i++)
            {
                shoppingCart.Add(new Book(5));
            }

            var actual = calculator.Calculate(shoppingCart);

            Assert.AreEqual(102.4M, actual);
        }
Example #12
0
        public void BuyTwoBookOfSameType()
        {
            List<Book> shoppingCart = new List<Book>();
            var book = new Book(1);
            var book2 = new Book(1);

            shoppingCart.Add(book);
            shoppingCart.Add(book2);

            ShoppingCartCalculator calculator = new ShoppingCartCalculator();

            var actual = calculator.Calculate(shoppingCart);

            Assert.AreEqual(16M, actual);
        }