Exemplo n.º 1
0
        public void GetPrice_一二三四集各買了一本_價格應為100_乘_4_乘_0_點_8_等於_320()
        {
            //arrange
            var books = new List <Book>
            {
                new Book {
                    Name = "第一集", Price = 100
                },
                new Book {
                    Name = "第二集", Price = 100
                },
                new Book {
                    Name = "第三集", Price = 100
                },
                new Book {
                    Name = "第四集", Price = 100
                }
            };

            var target = new ShoppingCart();

            target.SetBooks(books);

            var expected = 320;

            //act
            var actual = target.GetPrice();

            //assert

            Assert.AreEqual(expected, actual);
        }
Exemplo n.º 2
0
        public void GetPrice_第一集買了一本_第二集也買了一本_價格應為100_乘_2_乘_0_點_95_等於_190()
        {
            //arrange
            var books = new List <Book>
            {
                new Book {
                    Name = "第一集", Price = 100
                },
                new Book {
                    Name = "第二集", Price = 100
                }
            };

            var target = new ShoppingCart();

            target.SetBooks(books);

            var expected = 190;

            //act
            var actual = target.GetPrice();

            //assert

            Assert.AreEqual(expected, actual);
        }
Exemplo n.º 3
0
        public void GetPriceTest_Volume1x1_Volume2x0_Volume3x0_Volume4x0_Volume5x0_ShouldBe_100()
        {
            // arrange
            ShoppingCart target = new ShoppingCart();

            target.AddBook(new Book("PoterVolume1"));

            int expectedPrice = 100;

            // act
            int actualPrice = target.GetPrice();

            // assert
            Assert.AreEqual(expectedPrice, actualPrice);
        }
Exemplo n.º 4
0
        public void GetPrice_一二三集各買了一本_價格應為100_乘_3_乘_0_點_9_等於_270()
        {
            //arrange
            var books = new List<Book>
            {
                new Book{ Name = "第一集", Price = 100 },
                new Book{ Name = "第二集", Price = 100 },
                new Book{ Name = "第三集", Price = 100 }
            };

            var target = new ShoppingCart();
            target.SetBooks(books);

            var expected = 270;

            //act
            var actual = target.GetPrice();

            //assert

            Assert.AreEqual(expected, actual);
        }
Exemplo n.º 5
0
        public void GetPrice_一次買了整套_一二三四五集各買了一本_價格應為100_乘_5_乘_0_點_75_等於_375()
        {
            //arrange
            var books = new List<Book>
            {
                new Book{ Name = "第一集", Price = 100 },
                new Book{ Name = "第二集", Price = 100 },
                new Book{ Name = "第三集", Price = 100 },
                new Book{ Name = "第四集", Price = 100 },
                new Book{ Name = "第五集", Price = 100 }
            };

            var target = new ShoppingCart();
            target.SetBooks(books);

            var expected = 375;

            //act
            var actual = target.GetPrice();

            //assert

            Assert.AreEqual(expected, actual);
        }
Exemplo n.º 6
0
        public void GetPrice_第一集買了一本_其他都沒買_價格應為100_乘_1_等於_100元()
        {
            //arrange
            var books = new List<Book>
            {
                new Book{ Name = "第一集", Price = 100}
            };

            var target = new ShoppingCart();
            target.SetBooks(books);

            var expected = 100;

            //act
            var actual = target.GetPrice();

            //assert

            Assert.AreEqual(expected, actual);
        }