public void testCreatesBuckets()
{
var time = new MockedClock();
var counter = new RollingNumber(time, 200, 10);
// confirm the initial settings
Assert.Equal(200, counter.TimeInMs);
Assert.Equal(10, counter.NumberOfBuckets);
Assert.Equal(20, counter.BucketSizeInMs);
// add a Success in each interval which should result in all 10 buckets being created with 1 Success in each
for (int i = 0; i < counter.NumberOfBuckets; i++)
{
counter.Increment(RollingNumberEvent.SUCCESS);
time.Increment(counter.BucketSizeInMs);
}
// confirm we have all 10 buckets
var buckets = counter.GetBuckets().ToArray();
Assert.Equal(10, buckets.Length);
// add 1 more and we should still only have 10 buckets since that's the max
counter.Increment(RollingNumberEvent.SUCCESS);
buckets = counter.GetBuckets().ToArray();
Assert.Equal(10, buckets.Length);
}