示例#1
0
        public void When_recording_a_failure_for_a_message_it_should_not_be_treated_as_least_recently_used()
        {
            const int MaxElements = 50;
            var       storage     = new MsmqFailureInfoStorage(MaxElements);

            var lruMessageId = Guid.NewGuid().ToString("D");

            storage.RecordFailureInfoForMessage(lruMessageId, new Exception());

            var messageIds = new List <string>(MaxElements);

            for (var i = 0; i < MaxElements; ++i)
            {
                messageIds.Add(Guid.NewGuid().ToString("D"));
            }

            for (var i = 0; i < MaxElements - 1; ++i)
            {
                storage.RecordFailureInfoForMessage(messageIds[i], new Exception());
            }

            storage.RecordFailureInfoForMessage(lruMessageId, new Exception());

            storage.RecordFailureInfoForMessage(messageIds[MaxElements - 1], new Exception());

            storage.TryGetFailureInfoForMessage(lruMessageId, out var failureInfo);

            Assert.IsNotNull(failureInfo);
        }
示例#2
0
        public void When_recording_more_than_max_number_of_failures_should_remove_least_recently_used_entry()
        {
            const int MaxElements = 50;
            var       storage     = new MsmqFailureInfoStorage(maxElements: MaxElements);

            var lruMessageId = Guid.NewGuid().ToString("D");

            storage.RecordFailureInfoForMessage(lruMessageId, new Exception());

            for (var i = 0; i < MaxElements; ++i)
            {
                var messageId = Guid.NewGuid().ToString("D");
                var exception = new Exception();

                storage.RecordFailureInfoForMessage(messageId, exception);
            }

            storage.TryGetFailureInfoForMessage(lruMessageId, out var failureInfo);

            Assert.IsNull(failureInfo);
        }
        public void When_recording_more_than_max_number_of_failures_should_remove_least_recently_used_entry()
        {
            const int MaxElements = 50;
            var storage = new MsmqFailureInfoStorage(maxElements: MaxElements);

            var lruMessageId = Guid.NewGuid().ToString("D");

            storage.RecordFailureInfoForMessage(lruMessageId, new Exception());

            for (var i = 0; i < MaxElements; ++i)
            {
                var messageId = Guid.NewGuid().ToString("D");
                var exception = new Exception();

                storage.RecordFailureInfoForMessage(messageId, exception);
            }

            MsmqFailureInfoStorage.ProcessingFailureInfo failureInfo;
            storage.TryGetFailureInfoForMessage(lruMessageId, out failureInfo);

            Assert.IsNull(failureInfo);
        }
        public void When_recording_a_failure_for_a_message_it_should_not_be_treated_as_least_recently_used()
        {
            const int MaxElements = 50;
            var storage = new MsmqFailureInfoStorage(MaxElements);

            var lruMessageId = Guid.NewGuid().ToString("D");

            storage.RecordFailureInfoForMessage(lruMessageId, new Exception());

            var messageIds = new List<string>(MaxElements);
            for (var i = 0; i < MaxElements; ++i)
            {
                messageIds.Add(Guid.NewGuid().ToString("D"));
            }

            for (var i = 0; i < MaxElements - 1; ++i)
            {
                storage.RecordFailureInfoForMessage(messageIds[i], new Exception());
            }

            storage.RecordFailureInfoForMessage(lruMessageId, new Exception());

            storage.RecordFailureInfoForMessage(messageIds[MaxElements - 1], new Exception());

            MsmqFailureInfoStorage.ProcessingFailureInfo failureInfo;
            storage.TryGetFailureInfoForMessage(lruMessageId, out failureInfo);

            Assert.IsNotNull(failureInfo);
        }