Esempio n. 1
0
        public void TestCopyFromMultipleColumns()
        {
            var buffer = new LogBufferArray(2,
                                            Core.Columns.Index,
                                            Core.Columns.Timestamp);

            buffer.CopyFrom(Core.Columns.Index, new LogLineIndex[] { 1, 42 });
            buffer.CopyFrom(Core.Columns.Timestamp, new DateTime?[] { DateTime.MinValue, DateTime.MaxValue });

            buffer[0].Index.Should().Be(1);
            buffer[0].Timestamp.Should().Be(DateTime.MinValue);

            buffer[1].Index.Should().Be(42);
            buffer[1].Timestamp.Should().Be(DateTime.MaxValue);
        }
Esempio n. 2
0
        public void TestCopyFromUnknownColumn()
        {
            var buffer = new LogBufferArray(2, Core.Columns.Timestamp);

            new Action(() => buffer.CopyFrom(Core.Columns.RawContent, 0, new string[0], 0, 0))
            .Should().Throw <NoSuchColumnException>();
        }
Esempio n. 3
0
        public void TestCopyFromNullColumn()
        {
            var buffer = new LogBufferArray(2, Core.Columns.Timestamp);

            new Action(() => buffer.CopyFrom(null, 0, new string[0], 0, 0))
            .Should().Throw <ArgumentNullException>();
        }
Esempio n. 4
0
        public void TestCopyFrom()
        {
            var buffer    = new LogBufferArray(1, Core.Columns.Timestamp);
            var timestamp = new DateTime(2017, 12, 11, 21, 41, 0);

            buffer.CopyFrom(Core.Columns.Timestamp, new DateTime?[] { timestamp });
            buffer[0].Timestamp.Should().Be(timestamp, "Because we've just copied this timestamp to the buffer");
        }
Esempio n. 5
0
        public void TestCopyFromPartial3()
        {
            var buffer = new LogBufferArray(2, Core.Columns.Timestamp);

            var timestamp = new DateTime(2017, 12, 11, 21, 41, 0);

            buffer.CopyFrom(Core.Columns.Timestamp, 1, new DateTime?[] { timestamp }, 0, 1);
            buffer[0].Timestamp.Should().BeNull("because we didn't copy any data for this timestamp");
            buffer[1].Timestamp.Should().Be(timestamp, "Because we've just copied this timestamp to the buffer");
        }
Esempio n. 6
0
        public void TestCopyFromOverwrite()
        {
            var buffer = new LogBufferArray(2, Core.Columns.RawContent);

            buffer[0].RawContent.Should().BeNull();
            buffer[1].RawContent.Should().BeNull();

            buffer.CopyFrom(Core.Columns.RawContent, new [] { "foo", "bar" });
            buffer[0].RawContent.Should().Be("foo");
            buffer[1].RawContent.Should().Be("bar");
        }
Esempio n. 7
0
        public void TestCopyFromManyRows()
        {
            const int count  = 1000;
            var       buffer = new LogBufferArray(count, Core.Columns.OriginalIndex);

            buffer.CopyFrom(Core.Columns.OriginalIndex, Enumerable.Range(0, count).Select(i => (LogLineIndex)i).ToArray());
            for (int i = 0; i < count; ++i)
            {
                buffer[i].OriginalIndex.Should().Be(i);
            }
        }
Esempio n. 8
0
        public void TestFillAllColumns2()
        {
            var buffer = new LogBufferArray(4, Core.Columns.DeltaTime, Core.Columns.Timestamp);
            var deltas = new TimeSpan?[]
            {
                TimeSpan.FromMilliseconds(1),
                TimeSpan.FromMilliseconds(5),
                TimeSpan.FromSeconds(3),
                TimeSpan.FromSeconds(10)
            };

            buffer.CopyFrom(Core.Columns.DeltaTime, deltas);
            var timestamps = new DateTime?[]
            {
                new DateTime(2017, 12, 12, 19, 24, 0),
                new DateTime(2017, 12, 12, 19, 25, 0),
                new DateTime(2017, 12, 12, 19, 26, 0),
                new DateTime(2017, 12, 12, 19, 27, 0)
            };

            buffer.CopyFrom(Core.Columns.Timestamp, timestamps);

            buffer[0].DeltaTime.Should().Be(TimeSpan.FromMilliseconds(1));
            buffer[0].Timestamp.Should().Be(new DateTime(2017, 12, 12, 19, 24, 0));
            buffer[1].DeltaTime.Should().Be(TimeSpan.FromMilliseconds(5));
            buffer[1].Timestamp.Should().Be(new DateTime(2017, 12, 12, 19, 25, 0));
            buffer[2].DeltaTime.Should().Be(TimeSpan.FromSeconds(3));
            buffer[2].Timestamp.Should().Be(new DateTime(2017, 12, 12, 19, 26, 0));
            buffer[3].DeltaTime.Should().Be(TimeSpan.FromSeconds(10));
            buffer[3].Timestamp.Should().Be(new DateTime(2017, 12, 12, 19, 27, 0));

            buffer.FillDefault(1, 2);
            buffer[0].DeltaTime.Should().Be(TimeSpan.FromMilliseconds(1));
            buffer[0].Timestamp.Should().Be(new DateTime(2017, 12, 12, 19, 24, 0));
            buffer[1].DeltaTime.Should().BeNull();
            buffer[1].Timestamp.Should().BeNull();
            buffer[2].DeltaTime.Should().BeNull();
            buffer[2].Timestamp.Should().BeNull();
            buffer[3].DeltaTime.Should().Be(TimeSpan.FromSeconds(10));
            buffer[3].Timestamp.Should().Be(new DateTime(2017, 12, 12, 19, 27, 0));
        }
Esempio n. 9
0
        public void TestFillDefault3()
        {
            var buffer = new LogBufferArray(4, Core.Columns.DeltaTime);
            var data   = new TimeSpan?[]
            {
                TimeSpan.FromMilliseconds(1),
                TimeSpan.FromMilliseconds(5),
                TimeSpan.FromSeconds(3),
                TimeSpan.FromSeconds(10)
            };

            buffer.CopyFrom(Core.Columns.DeltaTime, data);
            buffer.FillDefault(Core.Columns.DeltaTime, 1, 2);

            buffer[0].DeltaTime.Should().Be(TimeSpan.FromMilliseconds(1));
            buffer[1].DeltaTime.Should().Be(null);
            buffer[2].DeltaTime.Should().Be(null);
            buffer[3].DeltaTime.Should().Be(TimeSpan.FromSeconds(10));
        }
Esempio n. 10
0
        public void TestFillDefault2([Range(0, 10)] int length)
        {
            var buffer = new LogBufferArray(length, Core.Columns.Timestamp);
            var data   = Enumerable.Range(0, length).Select(unused => (DateTime?)new DateTime(2017, 12, 12, 18, 58, 0)).ToArray();

            buffer.CopyFrom(Core.Columns.Timestamp, data);

            for (int i = 0; i < length; ++i)
            {
                buffer[i].Timestamp.Should().Be(new DateTime(2017, 12, 12, 18, 58, 0));
            }

            buffer.FillDefault(Core.Columns.Timestamp, 0, length);

            for (int i = 0; i < length; ++i)
            {
                buffer[i].Timestamp.Should().BeNull();
            }
        }
Esempio n. 11
0
        public void TestFillDefault1([Range(0, 10)] int length)
        {
            var buffer = new LogBufferArray(length, Core.Columns.RawContent);
            var data   = Enumerable.Range(0, length).Select(unused => "Foo").ToArray();

            buffer.CopyFrom(Core.Columns.RawContent, data);

            for (int i = 0; i < length; ++i)
            {
                buffer[i].RawContent.Should().Be("Foo");
            }

            buffer.FillDefault(Core.Columns.RawContent, 0, length);

            for (int i = 0; i < length; ++i)
            {
                buffer[i].RawContent.Should().BeNull();
            }
        }
Esempio n. 12
0
        public void TestColumn()
        {
            var buffer = new LogBufferArray(4, Core.Columns.DeltaTime, Core.Columns.Timestamp);

            buffer.Column(Core.Columns.DeltaTime).Should().Equal(new object[] { null, null, null, null });

            buffer.CopyFrom(Core.Columns.DeltaTime, 0, new TimeSpan?[]
            {
                TimeSpan.FromDays(1),
                TimeSpan.FromSeconds(42),
                null,
                TimeSpan.FromMinutes(-10)
            },
                            0, 4);
            buffer.Column(Core.Columns.DeltaTime).Should().Equal(new object[]
            {
                TimeSpan.FromDays(1),
                TimeSpan.FromSeconds(42),
                null,
                TimeSpan.FromMinutes(-10)
            });
        }