Exemplo n.º 1
0
        public async Task Fail_UpdatesMessage()
        {
            var expectedRetries = (byte)(reader.MaxRetries - 1);
            var context         = new QueueContext
            {
                SourceQueue = "TestSourceQueue",
                MessageData = new QueueMessage
                {
                    Retries = (byte)(reader.MaxRetries - 2),
                },
                Headers = new Headers
                {
                },
            };

            await reader.Fail(context, new ApplicationException());

            Assert.AreEqual(expectedRetries, context.MessageData.Retries);
            Assert.IsTrue(context.MessageData.NotBefore >= clock.Object.UtcNow.AddSeconds(5)); //
            Assert.IsFalse(string.IsNullOrWhiteSpace(context.Headers.ExceptionDetails));
            perfCounters.Verify(c => c.RetryMessage(), Times.Once);
            dataAccess.Verify(c => c.Update(It.IsAny <QueueMessage>(), It.IsAny <string>()), Times.Once);
            Assert.IsTrue(ReferenceEquals(context.MessageData, UpdatedMessage));
            Assert.AreEqual("TestSourceQueue", UpdatedQueue);
        }