public void ShouldFreeAndNotReuseCountersThatHaveCooldown() { int abc = _managerWithCooldown.Allocate("abc"); int def = _managerWithCooldown.Allocate("def"); int ghi = _managerWithCooldown.Allocate("ghi"); _managerWithCooldown.Free(def); _testClock.CurrentTimestamp += FREE_TO_REUSE_TIMEOUT - 1; Assert.That(_managerWithCooldown.Allocate("the next label"), Is.GreaterThan(ghi)); }
public void ShouldFreeAndReuseCounters() { var abc = _manager.Allocate("abc"); var def = _manager.Allocate("def"); var ghi = _manager.Allocate("ghi"); _manager.Free(def); _otherManager.ForEach(_consumer); A.CallTo(() => _consumer(abc, "abc")).MustHaveHappened() .Then(A.CallTo(() => _consumer(ghi, "ghi")).MustHaveHappened()); A.CallTo(() => _consumer(A <int> ._, A <string> ._)).MustHaveHappened(Repeated.Exactly.Twice); Assert.AreEqual(_manager.Allocate("the next label"), def); }
public void Dispose() { _countersManager?.Free(_counterId); }