public HttpResponseMessage Put(HttpRequestMessage request, ApiKeyDto dto) { try { var updatedApiKey = ApiKeyService.Update(dto); return(request.CreateResponse(HttpStatusCode.OK, updatedApiKey)); } catch (Exception) { return(new HttpResponseMessage(HttpStatusCode.BadRequest)); } }
public async void Update() { var mock = new ServiceMockFacade <IApiKeyRepository>(); var model = new ApiApiKeyRequestModel(); mock.RepositoryMock.Setup(x => x.Create(It.IsAny <ApiKey>())).Returns(Task.FromResult(new ApiKey())); mock.RepositoryMock.Setup(x => x.Get(It.IsAny <string>())).Returns(Task.FromResult(new ApiKey())); var service = new ApiKeyService(mock.LoggerMock.Object, mock.RepositoryMock.Object, mock.ModelValidatorMockFactory.ApiKeyModelValidatorMock.Object, mock.BOLMapperMockFactory.BOLApiKeyMapperMock, mock.DALMapperMockFactory.DALApiKeyMapperMock); UpdateResponse <ApiApiKeyResponseModel> response = await service.Update(default(string), model); response.Should().NotBeNull(); mock.ModelValidatorMockFactory.ApiKeyModelValidatorMock.Verify(x => x.ValidateUpdateAsync(It.IsAny <string>(), It.IsAny <ApiApiKeyRequestModel>())); mock.RepositoryMock.Verify(x => x.Update(It.IsAny <ApiKey>())); }