public void buyFirst_1_Second_1_Third_1_Fourth_1_Five_1() { PotterShoppingCart target = new PotterShoppingCart(); List <Book> first = new List <Book> { new Book { name = "Harry Potter1", Cost = 100, count = 1 }, new Book { name = "Harry Potter2", Cost = 100, count = 1 }, new Book { name = "Harry Potter3", Cost = 100, count = 1 }, new Book { name = "Harry Potter4", Cost = 100, count = 1 }, new Book { name = "Harry Potter5", Cost = 100, count = 1 } }; int expected = 375; int actual = target.calculateFee(first); Assert.AreEqual(expected, actual); }
public void CheckOutTest_1本單價100元_第一到三集各買1本_共三本書_打9折_結帳總金額為270元() { //arrange var target = new PotterShoppingCart(); //每一本單價100元 target.addMerchandiseToCart(new List <Book>() { new Book() { series = SeriesOfBooks.one, name = "第一集", price = 100 }, new Book() { series = SeriesOfBooks.two, name = "第二集", price = 100 }, new Book() { series = SeriesOfBooks.three, name = "第三集", price = 100 } }); //預期折扣後總金額 var expected = 270m; //act var actual = target.CheckOut(); //assert Assert.AreEqual(expected, actual); }
public void GetPriceTest_Fst_1_Sec_2_Thi_2_price_must_be_460() { //arrange var target = new PotterShoppingCart(); //act var expected = 460; list.Add(new Book() { Version = 1, Num = 1, UnitPrice = 100 }); list.Add(new Book() { Version = 2, Num = 1, UnitPrice = 100 }); list.Add(new Book() { Version = 2, Num = 1, UnitPrice = 100 }); list.Add(new Book() { Version = 3, Num = 1, UnitPrice = 100 }); list.Add(new Book() { Version = 3, Num = 1, UnitPrice = 100 }); var actual = target.GetPrice(list); //assert Assert.AreEqual(expected, actual); }
public void GetTotalPriceTest_一二三四集各買了一本_should_be_320() { //arrange var expected = 320; var potterShoppingCart = new PotterShoppingCart(); var buyBooks = new List <PotterBookInfoModels> { new PotterBookInfoModels { BookID = "001" }, new PotterBookInfoModels { BookID = "002" }, new PotterBookInfoModels { BookID = "003" }, new PotterBookInfoModels { BookID = "004" } }; //act var actual = potterShoppingCart.GetTotalPrice(buyBooks); //assert Assert.AreEqual(expected, actual); }
public void getTotalAmountTest_第一集買了一本_其他都沒買_價格應為100元() { var target = new PotterShoppingCart(); target.addToCart(1); var actual = target.getTotalAmount(); var expected = 100; Assert.AreEqual(expected, actual); }
public void getTotalAmountTest_一二三集各買了一本_價格應為270() { var target = new PotterShoppingCart(); target.addToCart(1); target.addToCart(2); target.addToCart(3); var actual = target.getTotalAmount(); var expected = 270; Assert.AreEqual(expected, actual); }
public void getTotalAmountTest_一次買了整套_一二三四五集各買了一本_價格應為375() { var target = new PotterShoppingCart(); target.addToCart(1); target.addToCart(2); target.addToCart(3); target.addToCart(4); target.addToCart(5); var actual = target.getTotalAmount(); var expected = 375; Assert.AreEqual(expected, actual); }
public void buyFirst_1() { PotterShoppingCart target = new PotterShoppingCart(); List <Book> first = new List <Book> { new Book { name = "Harry Potter1", Cost = 100, count = 1 } }; //int[] first = new int[] { 1, 0, 0, 0, 0 }; int expected = 100; int actual = target.calculateFee(first); Assert.AreEqual(expected, actual); }
public void 一二三集各買了一本_價格應為270() { // Arrange books.Add(new Book { Name = "HarryPotter I", Price = 100 }); books.Add(new Book { Name = "HarryPotter II", Price = 100 }); books.Add(new Book { Name = "HarryPotter III", Price = 100 }); double expected = 270; var target = new PotterShoppingCart(); // Act double actual = target.Calculate_Price(books); // Assert Assert.AreEqual(expected, actual); }
public void 第一集買了一本_其他都沒買_價格應為100元() { //arrange var cart = new PotterShoppingCart(); var products = new List<PotterBook> { new PotterBook{Name = "Potter1", Price = 100} }; var expected = 100; //act var actual = cart.CalculatePrice(products); //assert Assert.AreEqual(expected, actual); }
public void GetTotalPriceTest_第一集買了一本其他都沒買_should_be_100() { //arrange var expected = 100; var potterShoppingCart = new PotterShoppingCart(); var buyBooks = new List <PotterBookInfoModels> { new PotterBookInfoModels { BookID = "001" } }; //act var actual = potterShoppingCart.GetTotalPrice(buyBooks); //assert Assert.AreEqual(expected, actual); }
public void 一二三集各買了一本_價格應為100X3X09_回傳270() { //arrange var cart = new PotterShoppingCart(); var products = new List<PotterBook> { new PotterBook{Name = "Potter1", Price = 100}, new PotterBook{Name = "Potter2", Price = 100}, new PotterBook{Name = "Potter3", Price = 100} }; var expected = 270; //act var actual = cart.CalculatePrice(products); //assert Assert.AreEqual(expected, actual); }
public void 一次買了整套_一二三四五集各買了一本_價格應為100X5X075_回傳375() { //arrange var cart = new PotterShoppingCart(); var products = new List<PotterBook> { new PotterBook{Name = "Potter1", Price = 100}, new PotterBook{Name = "Potter2", Price = 100}, new PotterBook{Name = "Potter3", Price = 100}, new PotterBook{Name = "Potter4", Price = 100}, new PotterBook{Name = "Potter5", Price = 100} }; var expected = 375; //act var actual = cart.CalculatePrice(products); //assert Assert.AreEqual(expected, actual); }
public void CheckOutTest_1本單價100元_只買第一集_數量為1本_結帳總金額為100元() { //arrange var target = new PotterShoppingCart(); target.addMerchandiseToCart(new List <Book>() { new Book() { series = SeriesOfBooks.one, name = "第一集", price = 100 } }); //每一本都是賣100元 var expected = 100m; //act var actual = target.CheckOut(); //assert Assert.AreEqual(expected, actual); }