public void AddToCard(PotterBook book, int count) { for (int i = 0; i < count; i++) { AddBook(book); } }
public void AddToCardTest_vol1_1_vol2_1_vol3_1_vol4_1_total_should_be_320() { // Arrange PotterBook vol1 = new PotterBook { Volumn = 1 }; PotterBook vol2 = new PotterBook { Volumn = 2 }; PotterBook vol4 = new PotterBook { Volumn = 4 }; PotterBook vol3 = new PotterBook { Volumn = 3 }; var target = new PotterShoppingCart(); var expected = 320; // Action target.AddToCard(vol1, 1); target.AddToCard(vol2, 1); target.AddToCard(vol3, 1); target.AddToCard(vol4, 1); // Assert Assert.AreEqual(expected, target.getTotal()); }
public void AddToCardTest_vol1_1_total_should_be_100() { // Arrange PotterBook vol1 = new PotterBook { Volumn = 1 }; var target = new PotterShoppingCart(); var expected = 100; // Action target.AddToCard(vol1,1); // Assert Assert.AreEqual(expected,target.getTotal()); }
public void AddToCardTest_vol1_1_total_should_be_100() { // Arrange PotterBook vol1 = new PotterBook { Volumn = 1 }; var target = new PotterShoppingCart(); var expected = 100; // Action target.AddToCard(vol1, 1); // Assert Assert.AreEqual(expected, target.getTotal()); }
private void AddBook(PotterBook book) { foreach (var bookSet in potterBookSets) { if (bookSet.CanAddBook(book)) { bookSet.AddBook(book); return; } } // Can't find any bookSet PotterBookSet pbookSet = new PotterBookSet(); pbookSet.AddBook(book); potterBookSets.Add(pbookSet); }
public void AddToCardTest_vol1_1_vol2_1_vol3_1_vol4_1_total_should_be_320() { // Arrange PotterBook vol1 = new PotterBook { Volumn = 1 }; PotterBook vol2 = new PotterBook { Volumn = 2 }; PotterBook vol4 = new PotterBook { Volumn = 4 }; PotterBook vol3 = new PotterBook { Volumn = 3 }; var target = new PotterShoppingCart(); var expected = 320; // Action target.AddToCard(vol1,1); target.AddToCard(vol2,1); target.AddToCard(vol3,1); target.AddToCard(vol4,1); // Assert Assert.AreEqual(expected, target.getTotal()); }
internal void AddBook(PotterBook book) { Items.Add(book); }
internal bool CanAddBook(PotterBook book) { var isExist = Items.Any(x => x.Volumn == book.Volumn); return(!isExist); }