GetMaxAddCount() public méthode

Because our bucket sizes our inconsistent (they are also dependant to time), we need to make sure that the cache doesn't take more messages than it can. see the function CalculateMessagesToAdd
public GetMaxAddCount ( ) : int
Résultat int
        public void MaxAddCountIsBucketSizeBecauseCacheIsFullTest()
        {
            Guid streamGuid = Guid.NewGuid();
            string streamNamespace = "TestTimedCache";

            Mock<IBatchContainer> batchMock1 = GenerateBatchContainerMock(streamGuid, streamNamespace, 1);
            Mock<IBatchContainer> batchMock2 = GenerateBatchContainerMock(streamGuid, streamNamespace, 2);
            Mock<IBatchContainer> batchMock3 = GenerateBatchContainerMock(streamGuid, streamNamespace, 3);
            Mock<IBatchContainer> batchMock4 = GenerateBatchContainerMock(streamGuid, streamNamespace, 4);
            Mock<IBatchContainer> batchMock5 = GenerateBatchContainerMock(streamGuid, streamNamespace, 5);
            Mock<IBatchContainer> batchMock6 = GenerateBatchContainerMock(streamGuid, streamNamespace, 6);

            List<IBatchContainer> msgs = new List<IBatchContainer>() { batchMock1.Object, batchMock2.Object, batchMock3.Object, batchMock4.Object, batchMock5.Object, batchMock6.Object };

            var cache = new TimedQueueCache(_defaultId, TimeSpan.FromSeconds(1), msgs.Count, msgs.Count / 2, _logger);
            cache.AddToCache(msgs);

            Task.Delay(TimeSpan.FromSeconds(2)).Wait();

            Assert.IsTrue(!cache.IsUnderPressure());
            Assert.AreEqual(2, cache.GetMaxAddCount());
        }
        public void CacheIsNotUnderPressureBecauseTimespanHasPassedAndNoSlowConsumersTest()
        {
            Guid streamGuid = Guid.NewGuid();
            string streamNamespace = "TestTimedCache";

            Mock<IBatchContainer> batchMock1 = GenerateBatchContainerMock(streamGuid, streamNamespace, 1);
            Mock<IBatchContainer> batchMock2 = GenerateBatchContainerMock(streamGuid, streamNamespace, 2);
            Mock<IBatchContainer> batchMock3 = GenerateBatchContainerMock(streamGuid, streamNamespace, 3);

            List<IBatchContainer> msgs = new List<IBatchContainer>() { batchMock1.Object, batchMock2.Object, batchMock3.Object };

            var cache = new TimedQueueCache(_defaultId, TimeSpan.FromSeconds(1), msgs.Count, _defaultCacheBucketNum, _logger);
            cache.AddToCache(msgs);

            Task.Delay(TimeSpan.FromSeconds(2)).Wait();

            Assert.IsTrue(!cache.IsUnderPressure());
            Assert.AreEqual(1, cache.GetMaxAddCount());
        }