public async Task ItShouldReturnNotFoundWhenThereIsNoDkimState() { A.CallTo(() => _dkimService.GetDkimForDomain(A <string> ._)) .Returns(Task.FromResult <EntityDkimEntityState>(null)); IActionResult response = await _sut.GetDkim(new DkimInfoRequest { Domain = "ncsc.gov.uk" }); Assert.That(response, Is.TypeOf(typeof(NotFoundObjectResult))); }
public async Task <IActionResult> GetDkim(DkimInfoRequest request) { EntityDkimEntityState dkimEntityState = await _dkimService.GetDkimForDomain(request.Domain); if (dkimEntityState == null) { return(new NotFoundObjectResult(new ErrorResponse($"No Dkim found for {request.Domain}", ErrorStatus.Information))); } DkimResponse response = _dkimEntityToApiMapper.ToDkimResponse(dkimEntityState); return(new ObjectResult(response)); }