public async void Get_null_record() { var mock = new ServiceMockFacade <IProductProductPhotoRepository>(); mock.RepositoryMock.Setup(x => x.Get(It.IsAny <int>())).Returns(Task.FromResult <ProductProductPhoto>(null)); var service = new ProductProductPhotoService(mock.LoggerMock.Object, mock.RepositoryMock.Object, mock.ModelValidatorMockFactory.ProductProductPhotoModelValidatorMock.Object, mock.BOLMapperMockFactory.BOLProductProductPhotoMapperMock, mock.DALMapperMockFactory.DALProductProductPhotoMapperMock); ApiProductProductPhotoResponseModel response = await service.Get(default(int)); response.Should().BeNull(); mock.RepositoryMock.Verify(x => x.Get(It.IsAny <int>())); }
public async void Create() { var mock = new ServiceMockFacade <IProductProductPhotoRepository>(); var model = new ApiProductProductPhotoRequestModel(); mock.RepositoryMock.Setup(x => x.Create(It.IsAny <ProductProductPhoto>())).Returns(Task.FromResult(new ProductProductPhoto())); var service = new ProductProductPhotoService(mock.LoggerMock.Object, mock.RepositoryMock.Object, mock.ModelValidatorMockFactory.ProductProductPhotoModelValidatorMock.Object, mock.BOLMapperMockFactory.BOLProductProductPhotoMapperMock, mock.DALMapperMockFactory.DALProductProductPhotoMapperMock); CreateResponse <ApiProductProductPhotoResponseModel> response = await service.Create(model); response.Should().NotBeNull(); mock.ModelValidatorMockFactory.ProductProductPhotoModelValidatorMock.Verify(x => x.ValidateCreateAsync(It.IsAny <ApiProductProductPhotoRequestModel>())); mock.RepositoryMock.Verify(x => x.Create(It.IsAny <ProductProductPhoto>())); }
public async void All() { var mock = new ServiceMockFacade <IProductProductPhotoRepository>(); var records = new List <ProductProductPhoto>(); records.Add(new ProductProductPhoto()); mock.RepositoryMock.Setup(x => x.All(It.IsAny <int>(), It.IsAny <int>())).Returns(Task.FromResult(records)); var service = new ProductProductPhotoService(mock.LoggerMock.Object, mock.RepositoryMock.Object, mock.ModelValidatorMockFactory.ProductProductPhotoModelValidatorMock.Object, mock.BOLMapperMockFactory.BOLProductProductPhotoMapperMock, mock.DALMapperMockFactory.DALProductProductPhotoMapperMock); List <ApiProductProductPhotoResponseModel> 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 <IProductProductPhotoRepository>(); var model = new ApiProductProductPhotoRequestModel(); mock.RepositoryMock.Setup(x => x.Delete(It.IsAny <int>())).Returns(Task.CompletedTask); var service = new ProductProductPhotoService(mock.LoggerMock.Object, mock.RepositoryMock.Object, mock.ModelValidatorMockFactory.ProductProductPhotoModelValidatorMock.Object, mock.BOLMapperMockFactory.BOLProductProductPhotoMapperMock, mock.DALMapperMockFactory.DALProductProductPhotoMapperMock); ActionResponse response = await service.Delete(default(int)); response.Should().NotBeNull(); mock.RepositoryMock.Verify(x => x.Delete(It.IsAny <int>())); mock.ModelValidatorMockFactory.ProductProductPhotoModelValidatorMock.Verify(x => x.ValidateDeleteAsync(It.IsAny <int>())); }