public async void Get_null_record() { var mock = new ServiceMockFacade <IDeploymentHistoryRepository>(); mock.RepositoryMock.Setup(x => x.Get(It.IsAny <string>())).Returns(Task.FromResult <DeploymentHistory>(null)); var service = new DeploymentHistoryService(mock.LoggerMock.Object, mock.RepositoryMock.Object, mock.ModelValidatorMockFactory.DeploymentHistoryModelValidatorMock.Object, mock.BOLMapperMockFactory.BOLDeploymentHistoryMapperMock, mock.DALMapperMockFactory.DALDeploymentHistoryMapperMock); ApiDeploymentHistoryResponseModel response = await service.Get(default(string)); response.Should().BeNull(); mock.RepositoryMock.Verify(x => x.Get(It.IsAny <string>())); }
public async void ByCreated_Not_Exists() { var mock = new ServiceMockFacade <IDeploymentHistoryRepository>(); mock.RepositoryMock.Setup(x => x.ByCreated(It.IsAny <DateTimeOffset>())).Returns(Task.FromResult <List <DeploymentHistory> >(new List <DeploymentHistory>())); var service = new DeploymentHistoryService(mock.LoggerMock.Object, mock.RepositoryMock.Object, mock.ModelValidatorMockFactory.DeploymentHistoryModelValidatorMock.Object, mock.BOLMapperMockFactory.BOLDeploymentHistoryMapperMock, mock.DALMapperMockFactory.DALDeploymentHistoryMapperMock); List <ApiDeploymentHistoryResponseModel> response = await service.ByCreated(default(DateTimeOffset)); response.Should().BeEmpty(); mock.RepositoryMock.Verify(x => x.ByCreated(It.IsAny <DateTimeOffset>())); }
public async void Create() { var mock = new ServiceMockFacade <IDeploymentHistoryRepository>(); var model = new ApiDeploymentHistoryRequestModel(); mock.RepositoryMock.Setup(x => x.Create(It.IsAny <DeploymentHistory>())).Returns(Task.FromResult(new DeploymentHistory())); var service = new DeploymentHistoryService(mock.LoggerMock.Object, mock.RepositoryMock.Object, mock.ModelValidatorMockFactory.DeploymentHistoryModelValidatorMock.Object, mock.BOLMapperMockFactory.BOLDeploymentHistoryMapperMock, mock.DALMapperMockFactory.DALDeploymentHistoryMapperMock); CreateResponse <ApiDeploymentHistoryResponseModel> response = await service.Create(model); response.Should().NotBeNull(); mock.ModelValidatorMockFactory.DeploymentHistoryModelValidatorMock.Verify(x => x.ValidateCreateAsync(It.IsAny <ApiDeploymentHistoryRequestModel>())); mock.RepositoryMock.Verify(x => x.Create(It.IsAny <DeploymentHistory>())); }
public async void All() { var mock = new ServiceMockFacade <IDeploymentHistoryRepository>(); var records = new List <DeploymentHistory>(); records.Add(new DeploymentHistory()); mock.RepositoryMock.Setup(x => x.All(It.IsAny <int>(), It.IsAny <int>())).Returns(Task.FromResult(records)); var service = new DeploymentHistoryService(mock.LoggerMock.Object, mock.RepositoryMock.Object, mock.ModelValidatorMockFactory.DeploymentHistoryModelValidatorMock.Object, mock.BOLMapperMockFactory.BOLDeploymentHistoryMapperMock, mock.DALMapperMockFactory.DALDeploymentHistoryMapperMock); List <ApiDeploymentHistoryResponseModel> response = await service.All(); response.Should().HaveCount(1); mock.RepositoryMock.Verify(x => x.All(It.IsAny <int>(), It.IsAny <int>())); }
public async void Delete() { var mock = new ServiceMockFacade <IDeploymentHistoryRepository>(); var model = new ApiDeploymentHistoryRequestModel(); mock.RepositoryMock.Setup(x => x.Delete(It.IsAny <string>())).Returns(Task.CompletedTask); var service = new DeploymentHistoryService(mock.LoggerMock.Object, mock.RepositoryMock.Object, mock.ModelValidatorMockFactory.DeploymentHistoryModelValidatorMock.Object, mock.BOLMapperMockFactory.BOLDeploymentHistoryMapperMock, mock.DALMapperMockFactory.DALDeploymentHistoryMapperMock); ActionResponse response = await service.Delete(default(string)); response.Should().NotBeNull(); mock.RepositoryMock.Verify(x => x.Delete(It.IsAny <string>())); mock.ModelValidatorMockFactory.DeploymentHistoryModelValidatorMock.Verify(x => x.ValidateDeleteAsync(It.IsAny <string>())); }