public void CalAmountTest_一二集各買了一本_第三集買了兩本_價格應為370() { //arrange ShoppingCart target = new ShoppingCart(); target.Add(new ProductModel() { ID = 1, Price = 100m }); target.Add(new ProductModel() { ID = 2, Price = 100m }); target.Add(new ProductModel() { ID = 3, Price = 100m }); target.Add(new ProductModel() { ID = 3, Price = 100m }); decimal expected = 370; //act decimal actual; actual = target.CalAmount(); //assert Assert.AreEqual(expected, actual); }
public void CalAmountTest_第一集買了一本_其他都沒買_價格應為100() { //arrange ShoppingCart target = new ShoppingCart(); target.Add(new ProductModel() { ID = 1, Price = 100m }); decimal expected = 100m; //act decimal actual; actual = target.CalAmount(); //assert Assert.AreEqual(expected, actual); }