Exemple #1
0
        public void Given_Seven_Different_And_Five_Same_Books_I_Should_Get_EightyNine_Sixty()
        {
            // Arrange
            var harryPotterLogic = new HarryPotterLogic(); //start an instance of a class

            harryPotterLogic.Add("firstbook");
            harryPotterLogic.Add("secondbook");
            harryPotterLogic.Add("thirdbook");
            harryPotterLogic.Add("fourthbook");
            harryPotterLogic.Add("fifthbook");
            harryPotterLogic.Add("sixthbook");
            harryPotterLogic.Add("seventhbook");
            harryPotterLogic.Add("firstbook");
            harryPotterLogic.Add("firstbook");
            harryPotterLogic.Add("secondbook");
            harryPotterLogic.Add("thirdbook");
            harryPotterLogic.Add("thirdbook");
            harryPotterLogic.Add("thirdbook");
            harryPotterLogic.Add("fourthbook");


            // Act
            var result = harryPotterLogic.GetTotal();


            // Assert
            Assert.AreEqual(89.60, result);
        }
Exemple #2
0
        public void Given_One_Book_The_Total_Should_Be_Eight()
        {
            // Arrange
            var harryPotterLogic = new HarryPotterLogic(); //start an instance of a class

            harryPotterLogic.Add("firstbook");

            // Act
            var result = harryPotterLogic.GetTotal(); //function attached to a class instance


            // Assert
            Assert.AreEqual(8, result);    //state what it is expected to happen
        }
Exemple #3
0
        public void Given_A_Basket_Of_One_Book_I_Should_Receive_One_Title()
        {
            // Arrange
            var harryPotterLogic = new HarryPotterLogic(); //start an instance of a class

            // Act
            harryPotterLogic.Add("bookone");
            var result = harryPotterLogic.GetAllBooksInBasket();



            // Assert
            Assert.AreEqual(1, result.Count);
        }
Exemple #4
0
        public void Given_Two_Different_Books_The_Result_Should_Be_Fifteen_Twenty()
        {
            // Arrange
            var harryPotterLogic = new HarryPotterLogic(); //start an instance of a class

            harryPotterLogic.Add("firstbook");
            harryPotterLogic.Add("secondbook");

            // Act
            var result = harryPotterLogic.GetTotal(); //function attached to a class instance


            // Assert
            Assert.AreEqual(15.20, result);    //state what it is expected to happen
        }
Exemple #5
0
        public void Given_Two_Same_Books_There_Should_Be_No_Discount()
        {
            // Arrange
            var harryPotterLogic = new HarryPotterLogic(); //start an instance of a class

            harryPotterLogic.Add("firstbook");
            harryPotterLogic.Add("firstbook");

            // Act
            var result = harryPotterLogic.GetTotal();


            // Assert
            Assert.AreEqual(16, result);
        }
Exemple #6
0
        static void Main(string[] args)
        {
            var harryPotterLogic = new HarryPotterLogic();                                           //initiated instance of a class

            Console.WriteLine("What books would you like? Please select from the following list: "); //displaying book options

            Dictionary <string, string> bookRepo = new Dictionary <string, string>();

            bookRepo.Add("1", "Harry Potter and The Philosopher's Stone");
            bookRepo.Add("2", "Harry Potter and The Chamber of Secrets");
            bookRepo.Add("3", "Harry Potter and The Prisoner of Azkaban");
            bookRepo.Add("4", "Harry Potter and The Goblet of Fire");
            bookRepo.Add("5", "Harry Potter and The Order of the Phoenix");
            bookRepo.Add("6", "Harry Potter and The Half-Blood Prince");
            bookRepo.Add("7", "Harry Potter and The Deathly Hallows");
            var answer = "";

            foreach (KeyValuePair <string, string> bookPair in bookRepo)
            {
                Console.WriteLine("{0}, {1} ", bookPair.Key, bookPair.Value);
            }
            Console.WriteLine();

            do
            {
                var bookID   = Console.ReadLine();
                var bookName = bookRepo[bookID];
                harryPotterLogic.Add(bookName);
                Console.WriteLine(bookName);
                Console.WriteLine("Do you want another book? y/n");
                answer = Console.ReadLine();
            } while (answer != "n");

            var total    = harryPotterLogic.GetTotal();
            var allBooks = harryPotterLogic.GetAllBooksInBasket();

            Console.WriteLine("Your overall total is " + total + ", and your books are: ");

            foreach (var book in allBooks)
            {
                Console.WriteLine(book);
            }

            Console.ReadLine();
        }
Exemple #7
0
        public void Given_Three_Same_And_Two_Different_Books_The_Price_Should_Be_ThirtyEight_Forty()
        {
            // Arrange
            var harryPotterLogic = new HarryPotterLogic(); //start an instance of a class

            harryPotterLogic.Add("firstbook");
            harryPotterLogic.Add("secondbook");
            harryPotterLogic.Add("firstbook");
            harryPotterLogic.Add("firstbook");
            harryPotterLogic.Add("secondbook");

            // Act
            var result = harryPotterLogic.GetTotal();


            // Assert
            Assert.AreEqual(38.40, result);
        }
Exemple #8
0
        public void Given_Six_Different_Books_The_Result_Should_Be_Thirtysix()
        {
            // Arrange
            var harryPotterLogic = new HarryPotterLogic(); //start an instance of a class

            harryPotterLogic.Add("firstbook");
            harryPotterLogic.Add("secondbook");
            harryPotterLogic.Add("thirdbook");
            harryPotterLogic.Add("fourthbook");
            harryPotterLogic.Add("fifthbook");
            harryPotterLogic.Add("sixthbook");

            // Act
            var result = harryPotterLogic.GetTotal(); //function attached to a class instance


            // Assert
            Assert.AreEqual(36.00, result);    //state what it is expected to happen
        }
Exemple #9
0
        public void Given_Three_Four_And_Two_Same_Books_And_A_Single_One_I_Should_Get_SeventyTwo()
        {
            // Arrange
            var harryPotterLogic = new HarryPotterLogic(); //start an instance of a class

            harryPotterLogic.Add("firstbook");
            harryPotterLogic.Add("secondbook");
            harryPotterLogic.Add("thirdbook");
            harryPotterLogic.Add("fourthbook");
            harryPotterLogic.Add("firstbook");
            harryPotterLogic.Add("firstbook");
            harryPotterLogic.Add("secondbook");
            harryPotterLogic.Add("thirdbook");
            harryPotterLogic.Add("thirdbook");
            harryPotterLogic.Add("thirdbook");


            // Act
            var result = harryPotterLogic.GetTotal();


            // Assert
            Assert.AreEqual(72, result);
        }