Example #1
0
        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));
        }
Example #2
0
        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);
        }
Example #3
0
 public void Dispose()
 {
     _countersManager?.Free(_counterId);
 }