示例#1
0
        public void Test_SubgridSegmentCleaving_AdoptCellPassesFrom()
        {
            // Create the sub grid with lots of cell passes
            var subGrid  = MakeSubgridWith10240CellPassesAtOneSecondIntervals();
            var segment1 = subGrid.Cells.PassesData[0];

            // Get the time range
            segment1.PassesData.CalculateTimeRange(out DateTime startSegmentTime, out DateTime endSegmentTime);

            // Create a second segment specially and use the cell pass adopter to move cell passes
            var segment2 = new SubGridCellPassesDataSegment
            {
                Owner       = subGrid,
                SegmentInfo = new SubGridCellPassesDataSegmentInfo()
            };

            segment2.AllocateFullPassStacks();

            SegmentCellPassAdopter.AdoptCellPassesFrom(segment2.PassesData, segment1.PassesData, startSegmentTime + new TimeSpan((endSegmentTime.Ticks - startSegmentTime.Ticks) / 2));

            // Check the times of the adopted cells are correct
            Assert.True(segment1.VerifyComputedAndRecordedSegmentTimeRangeBounds(), "Segment1 has inappropriate cell pass time range compared to segment time range");
            Assert.True(segment2.VerifyComputedAndRecordedSegmentTimeRangeBounds(), "Segment2 has inappropriate cell pass time range compared to segment time range");

            segment1.PassesData.CalculateTotalPasses(out int totalPassCount1, out _, out int maximumPassCount1);
            segment2.PassesData.CalculateTotalPasses(out int totalPassCount2, out _, out int maximumPassCount2);

            Assert.True(10240 == (totalPassCount1 + totalPassCount2), $"Totals ({totalPassCount1} and {totalPassCount2} don't add up to 10240 after cleaving");
            Assert.True(5 == maximumPassCount1, $"Maximum pass count 1 {maximumPassCount1}, is not 5");
            Assert.True(5 == maximumPassCount2, $"Maximum pass count 2 {maximumPassCount2}, is not 5");

            // Check the segment pass count in the segment is correct
            Assert.True(totalPassCount1 == segment1.PassesData.SegmentPassCount, $"Total passes for segment 1 {totalPassCount1} is not equal to segmentPassCount in that segment {segment1.PassesData.SegmentPassCount}");
            Assert.True(totalPassCount2 == segment2.PassesData.SegmentPassCount, $"Total passes for segment 2 {totalPassCount2} is not equal to segmentPassCount in that segment {segment2.PassesData.SegmentPassCount}");
        }
示例#2
0
 /// <summary>
 /// Causes this segment to adopt all cell passes from sourceSegment where those cell passes were
 /// recorded at or later than a specific date
 /// </summary>
 /// <param name="sourceSegment"></param>
 /// <param name="atAndAfterTime"></param>
 public void AdoptCellPassesFrom(ISubGridCellSegmentPassesDataWrapper sourceSegment, DateTime atAndAfterTime)
 {
     SegmentCellPassAdopter.AdoptCellPassesFrom(this, sourceSegment, atAndAfterTime);
 }