示例#1
0
        public async Task ProcessMessageContextAsync_Test()
        {
            //Arrange
            var message = CreateMessage();
            var context = new TestMessageContext(message, _messageReceiver, _messageSender);

            //Act
            await _sut.ProcessMessageContextAsync(context, CancellationToken.None).ConfigureAwait(false);

            //Assert
            await _messageProcessor.Received().ProcessMessageAsync(Arg.Is(message), Arg.Is(CancellationToken.None))
            .ConfigureAwait(false);

            await _messageReceiver.Received().CompleteAsync(Arg.Is(message.SystemProperties.LockToken)).ConfigureAwait(false);

            await _messageReceiver.DidNotReceiveWithAnyArgs().AbandonAsync(null).ConfigureAwait(false);
        }
        public async Task ProcessMessageContextAsync_Test()
        {
            //Arrange
            var message = CreateMessage();
            var context = new TestMessageContext(message, _messageReceiver, _messageSender);

            //Act
            await _sut.ProcessMessageContextAsync(context, CancellationToken.None).ConfigureAwait(false);

            //Assert
            await _messageProcessor.Received().ProcessMessageAsync(Arg.Is(message), Arg.Is(CancellationToken.None))
            .ConfigureAwait(false);

            await _messageReceiver.Received().CompleteAsync(Arg.Is(message.SystemProperties.LockToken)).ConfigureAwait(false);

            await _messageReceiver.DidNotReceiveWithAnyArgs().ReceiveDeferredMessageAsync(Arg.Any <long>()).ConfigureAwait(false);

            await _messageReceiver.DidNotReceiveWithAnyArgs().AbandonAsync(Arg.Any <string>()).ConfigureAwait(false);

            _failurePolicy.DidNotReceiveWithAnyArgs().CanHandle(Arg.Any <Exception>());
            await _failurePolicy.DidNotReceiveWithAnyArgs()
            .HandleFailureAsync(Arg.Any <MessageContext>(), Arg.Any <CancellationToken>()).ConfigureAwait(false);
        }