コード例 #1
0
        public void Test1_第一集買一本_其他都沒買_價格應為100乘以1等於100元()
        {
            // arrange
            var bought_books = new List<Book>
            {
                new Book { volume = 1, price = 100 }
            };
            var target = new ShoppingCart(bought_books);
            var expected = 100;

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

            // assert
            Assert.AreEqual(expected, actual);
        }
コード例 #2
0
        public void Test2_第一集買一本_第二集也買一本_價格應為100乘以2乘以95percent等於190元()
        {
            // arrange
            var bought_books = new List<Book>
            {
                new Book { volume = 1, price = 100 },
                new Book { volume = 2, price = 100 }
            };
            var target = new ShoppingCart(bought_books);
            var expected = 190;

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

            // assert
            Assert.AreEqual(expected, actual);
        }
コード例 #3
0
        public void Test_第一集買一本其他都沒買_價格應為100元()
        {
            //arrange
            var target = new ShoppingCart();
            var products = new List<Product>()
            {
                new Product{ ProductId=1,ProductName="哈利波特第一集",Price=100}
            };
            target.AddProducts(products);

            var expected = 100;

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

            //assert
            Assert.AreEqual(expected, actual);
        }
コード例 #4
0
        public void Test3_一二三集各買了一本_價格應為100乘以3乘以90percent等於270元()
        {
            // arrange
            var bought_books = new List<Book>
            {
                new Book { volume = 1, price = 100 },
                new Book { volume = 2, price = 100 },
                new Book { volume = 3, price = 100 }
            };
            var target = new ShoppingCart(bought_books);
            var expected = 270;

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

            // assert
            Assert.AreEqual(expected, actual);
        }
コード例 #5
0
        public void Test_一二三集各買了一本_價格應為270()
        {
            //arrange
            var target = new ShoppingCart();
            var products = new List<Product>()
            {
                new Product{ ProductId=1,ProductName="哈利波特第一集",Price=100},
                new Product{ ProductId=2,ProductName="哈利波特第二集",Price=100},
                new Product{ ProductId=3,ProductName="哈利波特第三集",Price=100}
            };
            target.AddProducts(products);

            var expected = 270;

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

            //assert
            Assert.AreEqual(expected, actual);
        }
コード例 #6
0
        public void Test5_一二三四五集各買了一本_價格應為100乘以5乘以75percent等於375元()
        {
            // arrange
            var bought_books = new List<Book>
            {
                new Book { volume = 1, price = 100 },
                new Book { volume = 2, price = 100 },
                new Book { volume = 3, price = 100 },
                new Book { volume = 4, price = 100 },
                new Book { volume = 5, price = 100 }
            };
            var target = new ShoppingCart(bought_books);
            var expected = 375;

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

            // assert
            Assert.AreEqual(expected, actual);
        }