public void InsertBook_NotPresent_InsertsInEmptyList() { var infoNew = new BookInfo("book11", true); var state = new List<BookInfo>(); var collection = new BookCollection(state); collection.InsertBookInfo(infoNew); Assert.That(state[0], Is.EqualTo(infoNew), "book info should be inserted between book10 and book20"); }
public void InsertBook_NotPresent_InsertsInCorrectOrder() { var info1 = new BookInfo("book1", true); var info2 = new BookInfo("book2", true); var info3 = new BookInfo("book10", true); var info4 = new BookInfo("book20", true); var infoNew = new BookInfo("book11", true); var state = new List<BookInfo>(new[] {info1, info2, info3, info4}); var collection = new BookCollection(state); collection.InsertBookInfo(infoNew); Assert.That(state[3], Is.EqualTo(infoNew), "book info should be inserted between book10 and book20"); var infoLast = new BookInfo("book30", true); collection.InsertBookInfo(infoLast); Assert.That(state[5], Is.EqualTo(infoLast), "book info should be inserted at end"); var infoFirst = new BookInfo("abc", true); collection.InsertBookInfo(infoFirst); Assert.That(state[0], Is.EqualTo(infoFirst), "book info should be inserted at start"); }
public void InsertBook_Present_Replaces() { var info1 = new BookInfo("book1", true); var info2 = new BookInfo("book2", true); var info3 = new BookInfo("book10", true); var info4 = new BookInfo("book20", true); var infoNew = new BookInfo("book10", true); var state = new List<BookInfo>(new[] { info1, info2, info3, info4 }); var collection = new BookCollection(state); collection.InsertBookInfo(infoNew); Assert.That(state[2], Is.EqualTo(infoNew), "book info should replace existing book"); Assert.That(state, Has.Count.EqualTo(4)); }