public async Task EitherAOrB_should_return_bad_request_if_service_fails_validation() { // arrange var input = new CalculationInput(); var failedResponse = new CalculationResult { Validation = ValidationResult.Fail("FAIL") }; A.CallTo(() => _calculationService.EitherAOrB(input)) .Returns(failedResponse); // act var result = await GetSubject().EitherAOrB(input); // assert result.Should().BeOfType <BadRequestObjectResult>(); }
public async Task <IActionResult> EitherAOrB([FromBody] CalculationInput input) { var output = await _service.EitherAOrB(input); if (!output.Validation.IsValid) { return(BadRequest(output.Validation)); } return(Ok(output.Result)); }