public async void SaveChatMessage_Should_Return_Bad_Result_If_Invalid_Input() { var mediatorMock = new Mock <IMediator>(); var loggerMock = new Mock <ILogger>(); mediatorMock .Setup(x => x.Send(It.IsAny <CreateChatMessageCommand>(), It.IsAny <CancellationToken>())) .ReturnsAsync(new CommandResult <bool>() { Type = CommandResultTypeEnum.InvalidInput }); var controller = new ChatMessageController( loggerMock.Object, mediatorMock.Object ); var response = await controller.SaveChatMessage(new ChatMessage()); Assert.IsType <BadRequestResult>(response.Result); }
public async void SaveChatMessage_Should_Return_Ok_Result() { var mediatorMock = new Mock <IMediator>(); var loggerMock = new Mock <ILogger>(); mediatorMock .Setup(x => x.Send(It.IsAny <CreateChatMessageCommand>(), It.IsAny <CancellationToken>())) .ReturnsAsync(new CommandResult <bool>() { Type = CommandResultTypeEnum.Success }); var controller = new ChatMessageController( loggerMock.Object, mediatorMock.Object ); var response = await controller.SaveChatMessage(new ChatMessage()); Assert.IsType <OkObjectResult>(response.Result); mediatorMock.Verify(x => x.Send(It.IsAny <CreateChatMessageCommand>(), It.IsAny <CancellationToken>()), Times.Once()); }