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); }
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); }