public async Task PostReturnsBadRequestResultWhenAnErrorIsNotInternal()
        {
            var mediator = new Mock<IMediator>();
            var outReason = "anythingReally";
            var pid = "someIDValue";

            var error = new AddRequestError
            {
                ProviderId = pid,
                Reason = outReason
            };

            mediator.Setup(x => x.SendAsync(It.IsAny<AddRequestCommandAsync>())).ReturnsAsync(error);

            var sut = new RequestApiController(mediator.Object);
            var result = await sut.Post(new RequestViewModel()) as BadRequestObjectResult;

            Assert.NotNull(result);

            var resultObject = result.Value as AddRequestError;

            Assert.NotNull(resultObject);
            Assert.Equal(outReason, resultObject.Reason);
            Assert.Equal(pid, resultObject.ProviderId);
        }
 private IActionResult MapError(AddRequestError error)
 {
     //TODO mgmccarthy: I don't where .IsInternal is set set, so I commented it out
     //if (error.IsInternal)
     //{
     //    return StatusCode(500, error);
     //}
     return BadRequest(error);
 }
Exemplo n.º 3
0
 private IActionResult MapError(AddRequestError error)
 {
     if (error.IsInternal)
     {
         return StatusCode(500, error);
     }
     else
     {
         return BadRequest(error);
     }
 }