public void TestCopyFromLogFile_Contiguous() { var entries = new LogBufferList(Core.Columns.RawContent); entries.Add(new ReadOnlyLogEntry(new Dictionary <IColumnDescriptor, object> { { Core.Columns.RawContent, "I" } })); entries.Add(new ReadOnlyLogEntry(new Dictionary <IColumnDescriptor, object> { { Core.Columns.RawContent, "want" } })); entries.Add(new ReadOnlyLogEntry(new Dictionary <IColumnDescriptor, object> { { Core.Columns.RawContent, "a" } })); entries.Add(new ReadOnlyLogEntry(new Dictionary <IColumnDescriptor, object> { { Core.Columns.RawContent, "Clondyke" } })); entries.Add(new ReadOnlyLogEntry(new Dictionary <IColumnDescriptor, object> { { Core.Columns.RawContent, "Bar" } })); var logFile = new InMemoryLogSource(); logFile.AddEntry("Hello", LevelFlags.Debug); logFile.AddEntry("World!", LevelFlags.Info); entries.CopyFrom(Core.Columns.RawContent, 3, logFile, new LogSourceSection(0, 2)); entries.Count.Should().Be(5, "because the count shouldn't have been modified"); entries[0].RawContent.Should().Be("I", "because the first entry's raw content should not have been overwritten"); entries[1].RawContent.Should().Be("want", "because the second entry's raw content should not have been overwritten"); entries[2].RawContent.Should().Be("a", "because the third entry's raw content should not have been overwritten"); entries[3].RawContent.Should().Be("Hello", "because the fourth entry's raw content should have been overwritten"); entries[4].RawContent.Should().Be("World!", "because the fifth entry's raw content should have been overwritten"); }
public void TestCopyFromArray_PartiallyFilled() { var entries = new LogBufferList(Core.Columns.LogLevel); entries.Add(new ReadOnlyLogEntry(new Dictionary <IColumnDescriptor, object> { { Core.Columns.LogLevel, LevelFlags.Info } })); entries.Add(new ReadOnlyLogEntry(new Dictionary <IColumnDescriptor, object> { { Core.Columns.LogLevel, LevelFlags.Trace } })); var buffer = new LevelFlags[] { LevelFlags.All, LevelFlags.Debug, LevelFlags.Error, LevelFlags.Warning }; entries.Resize(4); entries.Count.Should().Be(buffer.Length); entries.CopyFrom(Core.Columns.LogLevel, 0, buffer, 0, buffer.Length); entries[0].LogLevel.Should().Be(LevelFlags.All, "because the first entry's level should have been overwritten"); entries[1].LogLevel.Should().Be(LevelFlags.Debug, "because the second entry's level should have been overwritten"); entries[2].LogLevel.Should().Be(LevelFlags.Error, "because the third log entry should been added"); entries[3].LogLevel.Should().Be(LevelFlags.Warning, "because the third log entry should been added"); }
public void TestCopyFromArray_Empty() { var entries = new LogBufferList(Core.Columns.LogLevel); var buffer = new LevelFlags[] { LevelFlags.All, LevelFlags.Debug, LevelFlags.Error, LevelFlags.Warning }; entries.Resize(4); entries.Count.Should().Be(buffer.Length); entries.CopyFrom(Core.Columns.LogLevel, 0, buffer, 0, buffer.Length); entries[0].LogLevel.Should().Be(LevelFlags.All); entries[1].LogLevel.Should().Be(LevelFlags.Debug); entries[2].LogLevel.Should().Be(LevelFlags.Error); entries[3].LogLevel.Should().Be(LevelFlags.Warning); }
public void TestCopyFromArray_NoSuchColumn() { var entries = new LogBufferList(Core.Columns.LogLevel); entries.Add(new ReadOnlyLogEntry(new Dictionary <IColumnDescriptor, object> { { Core.Columns.LogLevel, LevelFlags.Info } })); entries.Add(new ReadOnlyLogEntry(new Dictionary <IColumnDescriptor, object> { { Core.Columns.LogLevel, LevelFlags.Trace } })); var buffer = new string[] { "Foo", "Bar" }; new Action(() => entries.CopyFrom(Core.Columns.RawContent, 0, buffer, 0, buffer.Length)) .Should().Throw <NoSuchColumnException>(); entries[0].LogLevel.Should().Be(LevelFlags.Info, "because the first entry's level should have been overwritten"); entries[1].LogLevel.Should().Be(LevelFlags.Trace, "because the second entry's level should have been overwritten"); }
public void TestCopyFromArray_PartiallyOutOfBounds2() { var entries = new LogBufferList(Core.Columns.LogLevel); entries.Add(new ReadOnlyLogEntry(new Dictionary <IColumnDescriptor, object> { { Core.Columns.LogLevel, LevelFlags.Info } })); entries.Add(new ReadOnlyLogEntry(new Dictionary <IColumnDescriptor, object> { { Core.Columns.LogLevel, LevelFlags.Trace } })); var buffer = new LevelFlags[] { LevelFlags.All, LevelFlags.Debug }; new Action(() => entries.CopyFrom(Core.Columns.LogLevel, -1, buffer, 0, buffer.Length)) .Should().Throw <ArgumentOutOfRangeException>(); entries[0].LogLevel.Should().Be(LevelFlags.Info, "because the first entry's level should have been overwritten"); entries[1].LogLevel.Should().Be(LevelFlags.Trace, "because the second entry's level should have been overwritten"); }