public HttpResponseMessage Delete(HttpRequestMessage request, int id) { try { ApiKeyService.Delete(id); return(new HttpResponseMessage(HttpStatusCode.OK)); } catch (Exception) { return(new HttpResponseMessage(HttpStatusCode.BadRequest)); } }
public async void Delete() { var mock = new ServiceMockFacade <IApiKeyRepository>(); var model = new ApiApiKeyRequestModel(); mock.RepositoryMock.Setup(x => x.Delete(It.IsAny <string>())).Returns(Task.CompletedTask); var service = new ApiKeyService(mock.LoggerMock.Object, mock.RepositoryMock.Object, mock.ModelValidatorMockFactory.ApiKeyModelValidatorMock.Object, mock.BOLMapperMockFactory.BOLApiKeyMapperMock, mock.DALMapperMockFactory.DALApiKeyMapperMock); ActionResponse response = await service.Delete(default(string)); response.Should().NotBeNull(); mock.RepositoryMock.Verify(x => x.Delete(It.IsAny <string>())); mock.ModelValidatorMockFactory.ApiKeyModelValidatorMock.Verify(x => x.ValidateDeleteAsync(It.IsAny <string>())); }