public async void SaveCall_Should_Return_Bad_Result_If_Invalid_Input() { var mediatorMock = new Mock <IMediator>(); var loggerMock = new Mock <ILogger>(); mediatorMock .Setup(x => x.Send(It.IsAny <CreateCallCommand>(), It.IsAny <CancellationToken>())) .ReturnsAsync(new CommandResult <bool>() { Type = CommandResultTypeEnum.InvalidInput }); var controller = new CallController( loggerMock.Object, mediatorMock.Object ); var response = await controller.SaveCall(new Call()); Assert.IsType <BadRequestResult>(response.Result); }
public async void SaveCall_Should_Return_Ok_Result() { var mediatorMock = new Mock <IMediator>(); var loggerMock = new Mock <ILogger>(); mediatorMock .Setup(x => x.Send(It.IsAny <CreateCallCommand>(), It.IsAny <CancellationToken>())) .ReturnsAsync(new CommandResult <bool>() { Type = CommandResultTypeEnum.Success }); var controller = new CallController( loggerMock.Object, mediatorMock.Object ); var response = await controller.SaveCall(new Call()); Assert.IsType <OkObjectResult>(response.Result); mediatorMock.Verify(x => x.Send(It.IsAny <CreateCallCommand>(), It.IsAny <CancellationToken>()), Times.Once()); }