public void TestAddSameBookmarkTwice() { var collection = new BookmarkCollection(_bookmarks.Object, TimeSpan.Zero); collection.AddDataSource(_dataSource.Object); _logSource.AddEntry("", LevelFlags.Error); _logSource.AddEntry("", LevelFlags.Error); var bookmark = collection.TryAddBookmark(_dataSource.Object, 1); collection.TryAddBookmark(_dataSource.Object, 1).Should().BeNull(); collection.Count.Should().Be(1); collection.Bookmarks.Should().BeEquivalentTo(new object[] { bookmark }); }
public void TestAddTwoBookmarks() { var collection = new BookmarkCollection(_bookmarks.Object, TimeSpan.Zero); collection.AddDataSource(_dataSource.Object); _logSource.AddEntry("", LevelFlags.Error); _logSource.AddEntry("", LevelFlags.Error); var bookmark1 = collection.TryAddBookmark(_dataSource.Object, 1); var bookmark2 = collection.TryAddBookmark(_dataSource.Object, 0); bookmark2.Should().NotBeNull(); bookmark2.Index.Should().Be(new LogLineIndex(0)); collection.Count.Should().Be(2); collection.Bookmarks.Should().BeEquivalentTo(new object[] { bookmark1, bookmark2 }); }
public void TestClearBookmarks() { var collection = new BookmarkCollection(_bookmarks.Object, TimeSpan.Zero); collection.AddDataSource(_dataSource.Object); _logSource.AddEntry("", LevelFlags.Error); _logSource.AddEntry("", LevelFlags.Error); var bookmark1 = collection.TryAddBookmark(_dataSource.Object, 0); var bookmark2 = collection.TryAddBookmark(_dataSource.Object, 1); collection.Count.Should().Be(2); collection.Bookmarks.Should().Equal(new[] { bookmark1, bookmark2 }); _bookmarks.Verify(x => x.SaveAsync(), Times.Exactly(2)); collection.Clear(); collection.Count.Should().Be(0); collection.Bookmarks.Should().BeEmpty(); _bookmarks.Verify(x => x.SaveAsync(), Times.Exactly(3)); }
public void TestAddOneBookmark() { var collection = new BookmarkCollection(TimeSpan.Zero); collection.AddDataSource(_dataSource.Object); _logFile.AddEntry("", LevelFlags.Error); _logFile.AddEntry("", LevelFlags.Error); var bookmark = collection.TryAddBookmark(_dataSource.Object, 1); bookmark.Should().NotBeNull(); bookmark.Index.Should().Be(new LogLineIndex(1)); collection.Count.Should().Be(1); collection.Bookmarks.Should().BeEquivalentTo(new object[] { bookmark }); }
public void TestRemoveBookmark() { var collection = new BookmarkCollection(_bookmarks.Object, TimeSpan.Zero); collection.AddDataSource(_dataSource.Object); _logSource.AddEntry("", LevelFlags.Error); _logSource.AddEntry("", LevelFlags.Error); var bookmark = collection.TryAddBookmark(_dataSource.Object, 1); _bookmarks.Verify(x => x.SaveAsync(), Times.Once); collection.RemoveBookmark(bookmark); _bookmarks.Verify(x => x.SaveAsync(), Times.Exactly(2)); collection.Bookmarks.Should().BeEmpty(); }
/// <summary> /// /// </summary> /// <param name="dataSource"></param> /// <param name="orignalLogLineIndex"></param> /// <returns></returns> public Bookmark TryAddBookmark(IDataSource dataSource, LogLineIndex orignalLogLineIndex) { return(_bookmarks.TryAddBookmark(dataSource, orignalLogLineIndex)); }