public void TestAddRange_SingleColumn_NoSuchColumn() { var entries = new LogBufferList(Core.Columns.RawContent, Core.Columns.Index); entries.Add(new ReadOnlyLogEntry(new Dictionary <IColumnDescriptor, object> { { Core.Columns.RawContent, "I" }, { Core.Columns.Index, (LogLineIndex)42 } })); new Action(() => entries.AddRange(Core.Columns.Message, new[] { "A", "Speed" }, 2)).Should() .Throw <NoSuchColumnException>(); entries.Count.Should().Be(1); entries[0].RawContent.Should().Be("I"); entries[0].Index.Should().Be(42); }
public void TestAddRange() { var entries = new LogBufferList(Core.Columns.RawContent); var other = new LogBufferList(Core.Columns.RawContent); other.Add(new ReadOnlyLogEntry(new Dictionary <IColumnDescriptor, object> { { Core.Columns.RawContent, "rob" } })); other.Add(new ReadOnlyLogEntry(new Dictionary <IColumnDescriptor, object> { { Core.Columns.RawContent, "ert" } })); entries.AddRange(other); entries.Count.Should().Be(2, "because we've added all two entries from the other list"); entries[0].RawContent.Should().Be("rob"); entries[1].RawContent.Should().Be("ert"); }
public void TestAddRange_SingleColumn() { var entries = new LogBufferList(Core.Columns.RawContent, Core.Columns.Index); entries.Add(new ReadOnlyLogEntry(new Dictionary <IColumnDescriptor, object> { { Core.Columns.RawContent, "I" }, { Core.Columns.Index, (LogLineIndex)42 } })); entries.AddRange(Core.Columns.RawContent, new [] { "A", "Speed" }, 2); entries.Count.Should().Be(3); entries[0].RawContent.Should().Be("I"); entries[1].RawContent.Should().Be("A"); entries[2].RawContent.Should().Be("Speed"); entries[0].Index.Should().Be(42); entries[1].Index.Should().Be(LogLineIndex.Invalid); entries[2].Index.Should().Be(LogLineIndex.Invalid); }
protected override ILogBuffer Create(IEnumerable <IReadOnlyLogEntry> entries) { var columns = entries.SelectMany(x => x.Columns).Distinct().ToList(); // The base test can do all the heavy lifting for us. // Let us split up the source columns into their own buffers and make each source // buffer hold into the data from that single column var sources = columns.Select(x => { var buffer = new LogBufferList(x); buffer.AddRange(entries); return(buffer); }).ToList(); // And now we construct the combined view from the source again. // This way all source tests which operate on data from one more than one column // verify for us if our charade holds up. return(new CombinedLogBufferView(sources)); }
public void TestCacheRemovesEntriesWhenNeeded() { var buffer = new PagedLogBuffer(4, 2, Core.Columns.RawContent); buffer.ResizeTo(16); var data = new LogBufferList(Core.Columns.Index, Core.Columns.RawContent) { new LogEntry { RawContent = "A" }, new LogEntry { RawContent = "B" }, new LogEntry { RawContent = "C" }, new LogEntry { RawContent = "D" }, new LogEntry { RawContent = "E" }, new LogEntry { RawContent = "F" }, new LogEntry { RawContent = "G" }, new LogEntry { RawContent = "H" }, }; buffer.TryAdd(new LogSourceSection(0, 8), data, 0); var destination = new LogBufferArray(8, Core.Columns.Index, Core.Columns.RawContent, PageBufferedLogSource.RetrievalState); buffer.TryGetEntries(new[] { new LogLineIndex(3) }, destination, 0).Should().BeTrue("because the data is still in the cache"); destination[0].RawContent.Should().Be("D"); data.Clear(); data.AddRange(new [] { new LogEntry { RawContent = "I" }, new LogEntry { RawContent = "J" }, new LogEntry { RawContent = "K" }, new LogEntry { RawContent = "L" }, new LogEntry { RawContent = "M" }, new LogEntry { RawContent = "N" }, new LogEntry { RawContent = "O" }, new LogEntry { RawContent = "P" }, }); //< We deliberately add data that fills the entire cache because we don't want to verify the specific caching algorithm (i.e. which // data get's removed), we just want to make sure that it *does* get removed once the cache grows too big. buffer.TryAdd(new LogSourceSection(8, 8), data, 0); buffer.TryGetEntries(new LogSourceSection(0, 8), destination, 0).Should().BeFalse("because we've added so much data than none of the previously added data may still be part of the cache"); for (int i = 0; i < destination.Count; ++i) { destination[i].RawContent.Should().Be(Core.Columns.RawContent.DefaultValue); destination[i].GetValue(PageBufferedLogSource.RetrievalState).Should().Be(RetrievalState.NotCached); } }