internal void AddBook(Book book) { var bookList = (from s in groupBookList where s.Any(b => b.Name == book.Name) == false select s).FirstOrDefault(); if (bookList != null) { bookList.Add(book); } else { groupBookList.Add(new List<Book>() { book }); } }
public void GetPrice_第一集買了一本_其他都沒買_價格應為100_乘_1_等於_100元() { //arrange var target = new ShoppingCart(); var potterBook = new Book { Name = "Potter第一集", Price = 100 }; var expected = 100; target.AddBook(potterBook); //act var actual = target.GetPrice(); //assert Assert.AreEqual(expected, actual); }