예제 #1
0
 public HttpResponseMessage Delete(HttpRequestMessage request, int id)
 {
     try
     {
         ApiKeyService.Delete(id);
         return(new HttpResponseMessage(HttpStatusCode.OK));
     }
     catch (Exception)
     {
         return(new HttpResponseMessage(HttpStatusCode.BadRequest));
     }
 }
예제 #2
0
        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>()));
        }