UpdateRollingMax() public method

Update a value and retain the max value.
public UpdateRollingMax ( HystrixRollingNumberEvent type, long value ) : void
type HystrixRollingNumberEvent Defining which counter to update, must be a "MaxUpdater" type (HystrixRollingNumberEvent.IsMaxUpdater() == true).
value long Value to be updated to the current bucket
return void
        public void RollingNumber_MaxValue()
        {
            MockedTime time = new MockedTime();
            try
            {
                HystrixRollingNumberEvent type = HystrixRollingNumberEvent.ThreadMaxActive;

                HystrixRollingNumber counter = new HystrixRollingNumber(time, 200, 10);

                counter.UpdateRollingMax(type, 10);

                // sleep to get to a new bucket
                time.Increment(counter.BucketSizeInMilliseconds);

                counter.UpdateRollingMax(type, 30);

                // sleep to get to a new bucket
                time.Increment(counter.BucketSizeInMilliseconds);

                counter.UpdateRollingMax(type, 40);

                // sleep to get to a new bucket
                time.Increment(counter.BucketSizeInMilliseconds);

                counter.UpdateRollingMax(type, 15);

                Assert.AreEqual(40, counter.GetRollingMaxValue(type));

            }
            catch (Exception e)
            {
                TestContext.WriteLine(e.ToString());
                Assert.Fail("Exception: " + e.Message);
            }
        }
        public void RollingNumber_UpdateMax2()
        {
            MockedTime time = new MockedTime();
            try
            {
                HystrixRollingNumber counter = new HystrixRollingNumber(time, 200, 10);

                // increment
                counter.UpdateRollingMax(HystrixRollingNumberEvent.ThreadMaxActive, 10);
                counter.UpdateRollingMax(HystrixRollingNumberEvent.ThreadMaxActive, 30);
                counter.UpdateRollingMax(HystrixRollingNumberEvent.ThreadMaxActive, 20);

                // we should have 1 bucket
                Assert.AreEqual(1, counter.Buckets.Size);

                // the count should be 30
                Assert.AreEqual(30, counter.Buckets.GetLast().GetMaxUpdater(HystrixRollingNumberEvent.ThreadMaxActive).Max());
                Assert.AreEqual(30, counter.GetRollingMaxValue(HystrixRollingNumberEvent.ThreadMaxActive));

                // sleep to get to a new bucket
                time.Increment(counter.BucketSizeInMilliseconds * 3);

                counter.UpdateRollingMax(HystrixRollingNumberEvent.ThreadMaxActive, 30);
                counter.UpdateRollingMax(HystrixRollingNumberEvent.ThreadMaxActive, 30);
                counter.UpdateRollingMax(HystrixRollingNumberEvent.ThreadMaxActive, 50);

                // we should have 4 buckets
                Assert.AreEqual(4, counter.Buckets.Size);

                // the count
                Assert.AreEqual(50, counter.Buckets.GetLast().GetMaxUpdater(HystrixRollingNumberEvent.ThreadMaxActive).Max());
                Assert.AreEqual(50, counter.GetValueOfLatestBucket(HystrixRollingNumberEvent.ThreadMaxActive));

                // values per bucket
                long[] values = counter.GetValues(HystrixRollingNumberEvent.ThreadMaxActive);
                Assert.AreEqual(30, values[0]); // oldest bucket
                Assert.AreEqual(0, values[1]);
                Assert.AreEqual(0, values[2]);
                Assert.AreEqual(50, values[3]); // latest bucket

            }
            catch (Exception e)
            {
                TestContext.WriteLine(e.ToString());
                Assert.Fail("Exception: " + e.Message);
            }
        }