Exemple #1
0
        public async Task AcknowledgeThrowsIfHandledIsTrue()
        {
            var message = new FakeReceiverMessage("Hello, world!");

            await message.AcknowledgeAsync();

            Func <Task> act = () => message.AcknowledgeAsync();

            act.Should().Throw <InvalidOperationException>()
            .WithMessage($"Cannot {nameof(message.AcknowledgeAsync)} message: the message has already been handled by {nameof(message.AcknowledgeAsync)}.");
        }
Exemple #2
0
        public async Task HandledByIsAcknowledgeAfterAcknowledgeIsCalled()
        {
            var message = new FakeReceiverMessage("Hello, world!");

            await message.AcknowledgeAsync();

            message.HandledBy.Should().Be(nameof(message.AcknowledgeAsync));
        }
Exemple #3
0
        public async Task HandledIsTrueAfterAcknowledgeIsCalled()
        {
            var message = new FakeReceiverMessage("Hello, world!");

            await message.AcknowledgeAsync();

            message.Handled.Should().BeTrue();
        }
        public async Task RollbackThrowsIfHandledIsTrue()
        {
            using var message = new FakeReceiverMessage("Hello, world!");

            await message.AcknowledgeAsync().ConfigureAwait(false);

            Func <Task> act = () => message.RollbackAsync();

            await act.Should().ThrowAsync <InvalidOperationException>()
            .WithMessage($"Cannot {nameof(message.RollbackAsync)} message: the message has already been handled by {nameof(message.AcknowledgeAsync)}.").ConfigureAwait(false);
        }