Esempio n. 1
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. 2
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. 3
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. 4
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));
        }