コード例 #1
0
        public void EventDataSetSTream_HasDataAfterFrame_ReturnsTrueOnLastSampleNonZero()
        {
            EventDataSetStream testStream = new EventDataSetStream();

            testStream.AddSample(0, 1);
            testStream.AddSample(2, 1);
            Assert.AreEqual(true, testStream.HasDataAfterFrame(1), "HasDataAfterFrame returned false when there should be a sample with data following frame 1.");
        }
コード例 #2
0
        public void EventDataSetStream_AddSample_OutOfOrderFrameFails()
        {
            EventDataSetStream testStream = new EventDataSetStream();

            testStream.AddSample(5, 5);
            testStream.AddSample(0, 0);
            Assert.AreEqual(1, testStream.samples.Count, "Sample still added to stream despite the fact that the event should have been ignored.");
        }
コード例 #3
0
        public void EventDataSetStream_HasDataAfterFrame_ReturnsFalseOnLastSampleEmptyData()
        {
            EventDataSetStream testStream = new EventDataSetStream();

            testStream.AddSample(0, 1);
            testStream.AddSample(5, 0);
            Assert.AreEqual(false, testStream.HasDataAfterFrame(6), "HasDataAfterFrame returned true when last sample's data is empty and queried frame is past the last sample.");
        }
コード例 #4
0
        public void EventDataSetStream_AddSample_ReplaceValueOnDuplicateAdd()
        {
            EventDataSetStream testStream = new EventDataSetStream();

            testStream.AddSample(0, 5);
            testStream.AddSample(0, 6);
            Assert.AreEqual(6, testStream.GetValue(0), "Sample was not properly replaced. ");
            Assert.AreEqual(1, testStream.samples.Count, "Sample was not properly replaced.");
        }
コード例 #5
0
        public void EventDataSetStream_GetValue_ReturnsCorrectValueOnMultipleCalls()
        {
            EventDataSetStream testStream = new EventDataSetStream();

            testStream.AddSample(0, 0);
            testStream.AddSample(1, 1);
            testStream.AddSample(2, 2);
            Assert.AreEqual(2, testStream.GetValue(2), "Incorrect value retrieved by GetValue.");
            Assert.AreEqual(1, testStream.GetValue(1), "Incorrect value retrieved by GetValue.");
            Assert.AreEqual(0, testStream.GetValue(0), "Incorrect value retrieved by GetValue.");
        }
コード例 #6
0
        public void SegmentBeforeStartFrame_IsIgnored()
        {
            EventDataSetStream stream = new EventDataSetStream();

            stream.AddSample(0, 99);
            stream.AddSample(50, 0);
            GraphUtility.Segment[] segs = GraphUtility.IterateSegments(stream, 100, 200, IsContinuationOfSegment).ToArray();
            Assert.AreEqual(1, segs.Length);
            Assert.AreEqual(0, segs[0].data);
            Assert.AreEqual(100, segs[0].frameStart);
            Assert.AreEqual(200, segs[0].frameEnd);
        }
コード例 #7
0
        public void EventDataSetStream_GetValue_ReturnsLastValueOnTooLargeFrame()
        {
            EventDataSetStream testStream = new EventDataSetStream();

            testStream.AddSample(5, 5);
            Assert.AreEqual(5, testStream.GetValue(100), "Final contained sample was not returned on too large query frame.");
        }
コード例 #8
0
        public void EventDataSetStream_AddSample_SimpleAdd()
        {
            EventDataSetStream testStream = new EventDataSetStream();

            testStream.AddSample(0, 5);
            Assert.AreEqual(5, testStream.GetValue(0), "Value of added sample was not correctly retrieved. ");
        }
コード例 #9
0
        public void EventDataSetStream_GetValue_ReturnsZeroOnInvalidFrame()
        {
            EventDataSetStream testStream = new EventDataSetStream();

            Assert.AreEqual(0, testStream.GetValue(0), "Expected default value of 0 because there are no samples currently in EventDataStream.");
            testStream.AddSample(0, 1);
            Assert.AreEqual(0, testStream.GetValue(-1), "Expected default value because there is no sample with frame -1.");
        }
コード例 #10
0
 void AddAlternativeSegments(EventDataSetStream stream, int data1, int data2, int startFrame, int frameIncrement, int count)
 {
     for (int i = 0; i < count; i++)
     {
         int sample = (i % 2) == 0 ? data1 : data2;
         stream.AddSample(startFrame + i * frameIncrement, sample);
     }
 }
コード例 #11
0
        public void LastSampleBeforeLastEndFrame_LastSegmentSpansToEndOfFrame()
        {
            EventDataSetStream stream = new EventDataSetStream();

            stream.AddSample(50, 99);
            GraphUtility.Segment[] segs = GraphUtility.IterateSegments(stream, 0, 100, IsContinuationOfSegment).ToArray();
            Assert.AreEqual(1, segs.Length);
            Assert.AreEqual(50, segs[0].frameStart);
            Assert.AreEqual(100, segs[0].frameEnd);
            Assert.AreEqual(99, segs[0].data);
        }
コード例 #12
0
        public void FirstSampleBeforeStartFrame_IsFirstSegmentAndCropped()
        {
            EventDataSetStream stream = new EventDataSetStream();

            stream.AddSample(0, 99);
            GraphUtility.Segment[] segs = GraphUtility.IterateSegments(stream, 25, 100, IsContinuationOfSegment).ToArray();
            Assert.AreEqual(1, segs.Length);
            Assert.AreEqual(25, segs[0].frameStart);
            Assert.AreEqual(100, segs[0].frameEnd);
            Assert.AreEqual(99, segs[0].data);
        }