public void Sets_Properties(int count, int interval) { using (var t = new TokenBucket(count, interval)) { Assert.Equal(count, t.Capacity); Assert.Equal(interval, t.GetProperty <System.Timers.Timer>("Clock").Interval); Assert.Equal(count, t.GetProperty <long>("CurrentCount")); } }
public async Task Return_Does_Not_Change_Count_Given_Negative() { using (var t = new TokenBucket(10, 1000000)) { await t.GetAsync(5); Assert.Equal(5, t.GetProperty <long>("CurrentCount")); t.Return(-5); Assert.Equal(5, t.GetProperty <long>("CurrentCount")); } }
public async Task Return_Adds_Given_Value() { using (var t = new TokenBucket(10, 1000000)) { await t.GetAsync(5); Assert.Equal(5, t.GetProperty <long>("CurrentCount")); t.Return(5); Assert.Equal(10, t.GetProperty <long>("CurrentCount")); } }
public async Task GetAsync_Decrements_Count_By_Requested_Count() { using (var t = new TokenBucket(10, 10000)) { await t.GetAsync(5); Assert.Equal(5, t.GetProperty <long>("CurrentCount")); } }