public void AllDensitiesEqualOne()
        {
            var densities = DensityCalculationManager.GetDensities(_fixture.SampleEvents1, 31 * Durations.Second, 35 * Durations.Second - 1, Durations.Second);

            Assert.NotEmpty(densities);
            Assert.All(densities, d => Assert.Equal(1, d));
        }
        public void CalculateDensityForRangeWithNoEvents(long start, long end, long segmentSize, double expectedDensity)
        {
            var densities = DensityCalculationManager.GetDensities(_fixture.SampleEvents1, start, end, segmentSize);

            Assert.Single(densities);
            Assert.DensitiesEqual(expectedDensity, densities[0]);
        }
コード例 #3
0
 public void ShouldThrowWhenSegmentSizeIsTooBig()
 {
     Assert.Throws <ArgumentException>(() => {
         DensityCalculationManager.GetDensities(
             _fixture.SampleEvents1,
             24 * Durations.Second,
             24 * Durations.Second + 1000,
             Durations.Second);
     });
 }
コード例 #4
0
 public void ShouldThrowExceptionWhenEndEqualsStart()
 {
     Assert.Throws <ArgumentException>(() => {
         DensityCalculationManager.GetDensities(
             _fixture.SampleEvents1,
             24 * Durations.Second,
             24 * Durations.Second,
             Durations.Second);
     });
 }
コード例 #5
0
 public void ShouldThrowExceptionWhenTooMuchSegments(long start, long end, long segmentSize)
 {
     Assert.Throws <ArgumentException>(() => {
         DensityCalculationManager.GetDensities(
             _fixture.SampleEvents1,
             start,
             end,
             segmentSize);
     });
 }
        public void CalculateDensitiesForSeveralSegments(long start, long end, long segmentSize, double[] expectedDensities)
        {
            var densities = DensityCalculationManager.GetDensities(_fixture.SampleEvents2, start, end, segmentSize);

            Assert.Equal(densities.Length, expectedDensities.Length);
            for (var i = 0; i < densities.Length; i++)
            {
                Assert.Equal(expectedDensities[i], densities[i]);
            }
        }
        public void LastDensityIsZero()
        {
            var densities = DensityCalculationManager.GetDensities(
                _fixture.SampleEvents1,
                31 * Durations.Second,
                44 * Durations.Second,
                Durations.Second);

            Assert.NotEmpty(densities);
            Assert.True(densities.Last() == 0);
        }
コード例 #8
0
 /// <summary>
 /// Calculates densities for specific interval with specific segment size using pre-allocated buffer
 /// </summary>
 /// <param name="start">Start time (inclusive)</param>
 /// <param name="end">End time (inclusive)</param>
 /// <param name="segmentSize">Segment size</param>
 /// <param name="targetBuffer">Pre-allocated buffer</param>
 /// <returns>Part of the pre-allocated buffer where calculated densities were set</returns>
 public Span <double> GetDensities(long start, long end, long segmentSize, ref double[] targetBuffer)
 {
     return(DensityCalculationManager.GetDensities(this, start, end, segmentSize, ref targetBuffer));
 }
コード例 #9
0
 /// <summary>
 /// Calculates densities for specific interval with specific segment size
 /// </summary>
 /// <param name="start">Start time (inclusive)</param>
 /// <param name="end">End time (inclusive)</param>
 /// <param name="segmentSize">Segment size</param>
 /// <returns>All the densities that were calculated for the given interval</returns>
 public double[] GetDensities(long start, long end, long segmentSize)
 {
     return(DensityCalculationManager.GetDensities(this, start, end, segmentSize));
 }
        public void NoDensities()
        {
            var densities = DensityCalculationManager.GetDensities(_fixture.SampleEvents1, 255 * Durations.Second, 260 * Durations.Second - 1, Durations.Second);

            Assert.Empty(densities);
        }
        public void DensitiesCountShouldMatch(long start, long end, long segmentSize, int expectedDensitiesCount)
        {
            var densities = DensityCalculationManager.GetDensities(_fixture.SampleEvents1, start, end, segmentSize);

            Assert.Equal(densities.Length, expectedDensitiesCount);
        }
        public void CalculateDensityForRangeWithStartAndStopEvents(long start, long end, long segmentSize, double expectedDensity)
        {
            var densities = DensityCalculationManager.GetDensities(_fixture.SampleEvents1, start, end, segmentSize);

            Assert.All(densities, d => Assert.DensitiesEqual(expectedDensity, d));
        }