public void testCumulativeCounterAfterRollingAndReset3()
{
MockedClock time = new MockedClock();
RollingNumberEvent type = RollingNumberEvent.SUCCESS;
RollingNumber counter = new RollingNumber(time, 20, 2);
Assert.Equal(0, counter.GetCumulativeSum(type));
counter.Increment(type);
counter.Increment(type);
counter.Increment(type);
// iterate over 20 buckets on a queue sized for 2
for (int i = 0; i < 20; i++)
{
try
{
time.Increment(counter.BucketSizeInMs);
}
catch (Exception)
{
// ignore
}
}
// since we are rolling over the buckets it should reset naturally
// no increments during the loop, just some before and after
counter.Increment(type);
counter.Increment(type);
// cumulative count should be 5 regardless of buckets rolling
Assert.Equal(5, counter.GetCumulativeSum(type));
}