示例#1
0
        public void TestLogEntryIndex_ColumnAvailable()
        {
            var entry = new Mock <IReadOnlyLogEntry>();
            var view  = new ReadOnlyLogEntryView(entry.Object, Core.Columns.LogEntryIndex);

            entry.SetupGet(x => x.LogEntryIndex).Returns(new LogEntryIndex(101));
            view.LogEntryIndex.Should().Be(new LogEntryIndex(101));
        }
示例#2
0
        public void TestDeltaTime_ColumnAvailable()
        {
            var entry = new Mock <IReadOnlyLogEntry>();
            var view  = new ReadOnlyLogEntryView(entry.Object, Core.Columns.DeltaTime);

            entry.SetupGet(x => x.DeltaTime).Returns(TimeSpan.FromSeconds(42));
            view.DeltaTime.Should().Be(TimeSpan.FromSeconds(42));
        }
示例#3
0
        public void TestRawContent_ColumnAvailable()
        {
            var entry = new Mock <IReadOnlyLogEntry>();
            var view  = new ReadOnlyLogEntryView(entry.Object, Core.Columns.RawContent);

            entry.SetupGet(x => x.RawContent).Returns("I want a clondyke bar, I'm hungry");
            view.RawContent.Should().Be("I want a clondyke bar, I'm hungry");
        }
示例#4
0
        public void TestTimestamp_ColumnAvailable()
        {
            var entry = new Mock <IReadOnlyLogEntry>();
            var view  = new ReadOnlyLogEntryView(entry.Object, Core.Columns.Timestamp);

            entry.SetupGet(x => x.Timestamp).Returns(new DateTime(2021, 02, 11, 15, 42, 1));
            view.Timestamp.Should().Be(new DateTime(2021, 02, 11, 15, 42, 1));
        }
示例#5
0
        public void TestLogLevel_ColumnAvailable()
        {
            var entry = new Mock <IReadOnlyLogEntry>();
            var view  = new ReadOnlyLogEntryView(entry.Object, Core.Columns.LogLevel);

            entry.SetupGet(x => x.LogLevel).Returns(LevelFlags.Error);
            view.LogLevel.Should().Be(LevelFlags.Error);
        }
示例#6
0
        public void TestOriginalLineNumber_ColumnAvailable()
        {
            var entry = new Mock <IReadOnlyLogEntry>();
            var view  = new ReadOnlyLogEntryView(entry.Object, Core.Columns.OriginalLineNumber);

            entry.SetupGet(x => x.OriginalLineNumber).Returns(101);
            view.OriginalLineNumber.Should().Be(101);
        }
示例#7
0
        public void TestConstruction()
        {
            var entry = new Mock <IReadOnlyLogEntry>();
            var view  = new ReadOnlyLogEntryView(entry.Object, Core.Columns.RawContent, Core.Columns.Index);

            view.Columns.Should().Equal(new object[] { Core.Columns.RawContent, Core.Columns.Index });
            entry.VerifyGet(x => x.Columns, Times.Never);
        }
示例#8
0
        public void TestGetSetValueTyped_NoSuchColumn()
        {
            var column        = new Mock <IColumnDescriptor <long> >().Object;
            var anotherColumn = new Mock <IColumnDescriptor <long> >().Object;
            var entry         = new Mock <IReadOnlyLogEntry>();
            var view          = new ReadOnlyLogEntryView(entry.Object, column);

            new Action(() => view.GetValue(anotherColumn)).Should().Throw <NoSuchColumnException>();
            entry.Verify(x => x.GetValue <long>(It.IsAny <IColumnDescriptor <long> >()), Times.Never);
        }
示例#9
0
        public void TestGetSetValueTyped_ColumnAvailable()
        {
            var column = new Mock <IColumnDescriptor <long> >().Object;
            var entry  = new Mock <IReadOnlyLogEntry>();
            var view   = new ReadOnlyLogEntryView(entry.Object, column);

            entry.Setup(x => x.GetValue(column)).Returns(342L);
            view.GetValue(column).Should().Be(342L);
            entry.Verify(x => x.GetValue <long>(column), Times.Once);
        }
示例#10
0
        public void TestOriginalIndex_NoSuchColumn()
        {
            var entry = new Mock <IReadOnlyLogEntry>();
            var view  = new ReadOnlyLogEntryView(entry.Object, Core.Columns.Message);

            new Action(() =>
            {
                var unused = view.OriginalIndex;
            }).Should().Throw <NoSuchColumnException>();
            entry.VerifyGet(x => x.OriginalIndex, Times.Never);
        }
示例#11
0
        public void TestTryGetValueTyped_NoSuchColumn()
        {
            var column      = new Mock <IColumnDescriptor <string> >().Object;
            var otherColumn = new Mock <IColumnDescriptor <string> >();

            otherColumn.SetupGet(x => x.DefaultValue).Returns("<No Value>");
            var entry = new Mock <IReadOnlyLogEntry>();
            var view  = new ReadOnlyLogEntryView(entry.Object, column);

            view.TryGetValue(otherColumn.Object, out var actualValue).Should().BeFalse();
            actualValue.Should().Be(otherColumn.Object.DefaultValue);
        }
示例#12
0
        public void TestTryGetValueTyped_ColumnAvailable()
        {
            var column = new Mock <IColumnDescriptor <string> >().Object;
            var entry  = new Mock <IReadOnlyLogEntry>();
            var view   = new ReadOnlyLogEntryView(entry.Object, column);

            var expectedValue = "Hello";

            entry.Setup(x => x.TryGetValue(column, out expectedValue)).Returns(true);
            view.TryGetValue(column, out var actualValue).Should().BeTrue();
            actualValue.Should().Be(expectedValue);
        }