コード例 #1
0
        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));
        }
コード例 #2
0
        public async Task ItShouldReturnTheFirstResultWhenTheDkimStateExists()
        {
            EntityDkimEntityState state = new EntityDkimEntityState(null, EntityDkimState.Created, 0, DateTime.MinValue, null, null, null);

            A.CallTo(() => _dkimService.GetDkimForDomain(A <string> ._))
            .Returns(Task.FromResult(state));

            DkimResponse dkimResponse = new DkimResponse("", State.Created, null, null);

            A.CallTo(() => _entityToApiMapper.ToDkimResponse(state))
            .Returns(dkimResponse);

            ObjectResult response = (ObjectResult)await _sut.GetDkim(new DkimInfoRequest { Domain = "ncsc.gov.uk" });

            Assert.AreSame(dkimResponse, response.Value);
        }