InsertBookInfo() public method

Insert a book into the appropriate place. If there is already a book with the same FolderPath, replace it.
public InsertBookInfo ( BookInfo bookInfo ) : void
bookInfo Bloom.Book.BookInfo
return void
コード例 #1
0
 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");
 }
コード例 #2
0
        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");
        }
コード例 #3
0
 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));
 }