We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Authorize] [Route("[controller]")] [ApiController] public class BaseApiController : Controller { private IMediator _mediator; protected IMediator Mediator => _mediator ??= HttpContext.RequestServices.GetService<IMediator>(); }
I don't have constructor to mock mediator so i can't set my result value. Transactions in "GetBankImageQuery" return null or false.
[ApiController] public class BankImagesController : BaseApiController { [HttpGet("getByBankId")] public async Task<IActionResult> GetByBankId(long bankId) { var result = await Mediator.Send(new GetBankImageQuery { BankId = bankId }); if (!result.Success) { return BadRequest(result.Message); } return File(result.Data.Image, result.Data.ContentType); } }
Unit test example in architecture:
[Test] public async Task BankImages_GetByBankId_Success() { const string requestUri = "api/BankImages/getByBankId?bankId=1"; string token = MockJwtTokens.GenerateJwtToken(ClaimsData.GetClaims()); var requestMessage = new HttpRequestMessage(HttpMethod.Get, requestUri); requestMessage.Headers.Authorization = new AuthenticationHeaderValue("Bearer", token); var response = await HttpClient.SendAsync(requestMessage); Assert.AreEqual(HttpStatusCode.OK, response.StatusCode); }
How should I proceed here?
The text was updated successfully, but these errors were encountered:
No branches or pull requests
I don't have constructor to mock mediator so i can't set my result value.
Transactions in "GetBankImageQuery" return null or false.
Unit test example in architecture:
How should I proceed here?
The text was updated successfully, but these errors were encountered: