Esempio n. 1
0
        public void TestConstruction2()
        {
            var entry = new LogEntry2(LogFileColumns.RawContent, LogFileColumns.DeltaTime);

            entry.RawContent.Should().Be(LogFileColumns.RawContent.DefaultValue);
            entry.DeltaTime.Should().Be(LogFileColumns.DeltaTime.DefaultValue);
        }
Esempio n. 2
0
        public void TestSetValueWrongType()
        {
            var entry = new LogEntry2();

            new Action(() => entry.SetValue(LogFileColumns.RawContent, 42)).Should().Throw <ArgumentException>();
            entry.Columns.Should().BeEmpty();
            new Action(() => entry.GetValue(LogFileColumns.RawContent)).Should().Throw <ArgumentException>();
        }
Esempio n. 3
0
        public void TestConstruction3()
        {
            var entry = new LogEntry2(new List <ILogFileColumn> {
                LogFileColumns.Timestamp, LogFileColumns.LineNumber
            });

            entry.Timestamp.Should().Be(LogFileColumns.Timestamp.DefaultValue);
            entry.LineNumber.Should().Be(LogFileColumns.LineNumber.DefaultValue);
        }
Esempio n. 4
0
        private ILogEntry CreateIndex(IReadOnlyLogEntry logEntry)
        {
            int numLines;
            var width = EstimateWidth(logEntry.RawContent, out numLines);
            var index = new LogEntry2();

            index.SetValue(LogFileColumns.RawContentMaxPresentationWidth, width);
            index.SetValue(LogFileColumns.PresentationLineCount, numLines);
            return(index);
        }
Esempio n. 5
0
        public void TestSetElapsedTime()
        {
            var entry = new LogEntry2();

            entry.Columns.Should().BeEmpty();

            entry.ElapsedTime = TimeSpan.FromSeconds(23);
            entry.ElapsedTime.Should().Be(TimeSpan.FromSeconds(23));
            entry.Columns.Should().Equal(LogFileColumns.ElapsedTime);
            entry.GetValue(LogFileColumns.ElapsedTime).Should().Be(TimeSpan.FromSeconds(23));
        }
Esempio n. 6
0
        public void TestSetLogEntryIndex()
        {
            var entry = new LogEntry2();

            entry.Columns.Should().BeEmpty();

            entry.LogEntryIndex = 42;
            entry.LogEntryIndex.Should().Be(42);
            entry.Columns.Should().Equal(LogFileColumns.LogEntryIndex);
            entry.GetValue(LogFileColumns.LogEntryIndex).Should().Be(42);
        }
Esempio n. 7
0
        public void TestSetLogLevel()
        {
            var entry = new LogEntry2();

            entry.Columns.Should().BeEmpty();

            entry.LogLevel = LevelFlags.Fatal;
            entry.LogLevel.Should().Be(LevelFlags.Fatal);
            entry.Columns.Should().Equal(LogFileColumns.LogLevel);
            entry.GetValue(LogFileColumns.LogLevel).Should().Be(LevelFlags.Fatal);
        }
Esempio n. 8
0
        public void TestSetLineNumber()
        {
            var entry = new LogEntry2();

            entry.Columns.Should().BeEmpty();

            entry.LineNumber = 42;
            entry.LineNumber.Should().Be(42);
            entry.Columns.Should().Equal(LogFileColumns.LineNumber);
            entry.GetValue(LogFileColumns.LineNumber).Should().Be(42);
        }
Esempio n. 9
0
        public void TestSetOriginalLineNumber()
        {
            var entry = new LogEntry2();

            entry.Columns.Should().BeEmpty();

            entry.OriginalLineNumber = 1337;
            entry.OriginalLineNumber.Should().Be(1337);
            entry.Columns.Should().Equal(LogFileColumns.OriginalLineNumber);
            entry.GetValue(LogFileColumns.OriginalLineNumber).Should().Be(1337);
        }
Esempio n. 10
0
        public void TestSetOriginalIndex()
        {
            var entry = new LogEntry2();

            entry.Columns.Should().BeEmpty();

            entry.OriginalIndex = 8999;
            entry.OriginalIndex.Should().Be(8999);
            entry.Columns.Should().Equal(LogFileColumns.OriginalIndex);
            entry.GetValue(LogFileColumns.OriginalIndex).Should().Be(8999);
        }
Esempio n. 11
0
        public void TestSetIndex()
        {
            var entry = new LogEntry2();

            entry.Columns.Should().BeEmpty();

            entry.Index = 9001;
            entry.Index.Should().Be(9001);
            entry.Columns.Should().Equal(LogFileColumns.Index);
            entry.GetValue(LogFileColumns.Index).Should().Be(9001);
        }
Esempio n. 12
0
        public void TestSetRawContent()
        {
            var entry = new LogEntry2();

            entry.Columns.Should().BeEmpty();

            entry.RawContent = "The last Jedi";
            entry.RawContent.Should().Be("The last Jedi");
            entry.Columns.Should().Equal(LogFileColumns.RawContent);
            entry.GetValue(LogFileColumns.RawContent).Should().Be("The last Jedi");
        }
Esempio n. 13
0
        public void TestSetTimestamp()
        {
            var entry = new LogEntry2();

            entry.Columns.Should().BeEmpty();

            entry.Timestamp = new DateTime(2017, 12, 20, 13, 33, 0);
            entry.Timestamp.Should().Be(new DateTime(2017, 12, 20, 13, 33, 0));
            entry.Columns.Should().Equal(LogFileColumns.Timestamp);
            entry.GetValue(LogFileColumns.Timestamp).Should().Be(new DateTime(2017, 12, 20, 13, 33, 0));
        }
Esempio n. 14
0
        public void TestAddEntry6()
        {
            var logFile = new InMemoryLogFile(LogFileColumns.LogLevel);

            var logEntry = new LogEntry2();

            logEntry.Add(LogFileColumns.LogLevel, LevelFlags.Error);
            logFile.Add(logEntry);

            var buffer = new LogEntryBuffer(1, LogFileColumns.LogLevel);

            logFile.GetEntries(new LogFileSection(0, 1), buffer);
            buffer[0].LogLevel.Should().Be(LevelFlags.Error);
        }
Esempio n. 15
0
        public void TestConstruction1()
        {
            var entry = new LogEntry2();

            entry.Columns.Should().BeEmpty();
            new Action(() => { var unused = entry.DeltaTime; }).Should().Throw <NoSuchColumnException>();
            new Action(() => { var unused = entry.ElapsedTime; }).Should().Throw <NoSuchColumnException>();
            new Action(() => { var unused = entry.Index; }).Should().Throw <NoSuchColumnException>();
            new Action(() => { var unused = entry.LineNumber; }).Should().Throw <NoSuchColumnException>();
            new Action(() => { var unused = entry.LogEntryIndex; }).Should().Throw <NoSuchColumnException>();
            new Action(() => { var unused = entry.LogLevel; }).Should().Throw <NoSuchColumnException>();
            new Action(() => { var unused = entry.OriginalIndex; }).Should().Throw <NoSuchColumnException>();
            new Action(() => { var unused = entry.OriginalLineNumber; }).Should().Throw <NoSuchColumnException>();
            new Action(() => { var unused = entry.RawContent; }).Should().Throw <NoSuchColumnException>();
            new Action(() => { var unused = entry.Timestamp; }).Should().Throw <NoSuchColumnException>();
        }
Esempio n. 16
0
        public void TestAddPartialEntry()
        {
            var entries = new LogEntryList(LogFileColumns.RawContent, LogFileColumns.Timestamp);

            var logEntry = new LogEntry2();

            logEntry.Add(LogFileColumns.RawContent, "Foobar");
            entries.Add(logEntry);

            logEntry = new LogEntry2();
            logEntry.Add(LogFileColumns.Timestamp, new DateTime(2017, 12, 19, 16, 08, 0));
            entries.Add(logEntry);

            entries[0].RawContent.Should().Be("Foobar");
            entries[0].Timestamp.Should().BeNull();

            entries[1].RawContent.Should().BeNull();
            entries[1].Timestamp.Should().Be(new DateTime(2017, 12, 19, 16, 08, 0));
        }