예제 #1
0
        public async Task FetchCommandHandler_ShouldCallService()
        {
            var msgService = Substitute.For <IMessageService>();

            msgService.GetUserResponseAsync(Arg.Any <CancellationToken>())
            .Returns(Task.FromResult(_fixture.Create <MessageResponse>()));
            var fetchHandler = new FetchCommandHandler(msgService);
            await fetchHandler.ProcessCommand("hello world");

            await msgService
            .Received(1)
            .GetUserResponseAsync(Arg.Any <CancellationToken>());
        }
예제 #2
0
        public async Task SendCommandHandler_ShouldCallService()
        {
            var cannedResponse = _fixture.Create <MessageResponse>();
            var msgService     = Substitute.For <IMessageService>();

            msgService.WriteReplyAsync(Arg.Any <MessageResponse>(), Arg.Any <CancellationToken>())
            .Returns(Task.FromResult(cannedResponse));

            var fetchHandler = new FetchCommandHandler(msgService);
            await fetchHandler.ProcessCommand(string.Empty);

            await msgService
            .Received(1)
            .GetUserResponseAsync(Arg.Any <CancellationToken>());
        }