public async void Get_null_record() { var mock = new ServiceMockFacade <IProductModelIllustrationRepository>(); mock.RepositoryMock.Setup(x => x.Get(It.IsAny <int>())).Returns(Task.FromResult <ProductModelIllustration>(null)); var service = new ProductModelIllustrationService(mock.LoggerMock.Object, mock.RepositoryMock.Object, mock.ModelValidatorMockFactory.ProductModelIllustrationModelValidatorMock.Object, mock.BOLMapperMockFactory.BOLProductModelIllustrationMapperMock, mock.DALMapperMockFactory.DALProductModelIllustrationMapperMock); ApiProductModelIllustrationResponseModel 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 <IProductModelIllustrationRepository>(); var model = new ApiProductModelIllustrationRequestModel(); mock.RepositoryMock.Setup(x => x.Create(It.IsAny <ProductModelIllustration>())).Returns(Task.FromResult(new ProductModelIllustration())); var service = new ProductModelIllustrationService(mock.LoggerMock.Object, mock.RepositoryMock.Object, mock.ModelValidatorMockFactory.ProductModelIllustrationModelValidatorMock.Object, mock.BOLMapperMockFactory.BOLProductModelIllustrationMapperMock, mock.DALMapperMockFactory.DALProductModelIllustrationMapperMock); CreateResponse <ApiProductModelIllustrationResponseModel> response = await service.Create(model); response.Should().NotBeNull(); mock.ModelValidatorMockFactory.ProductModelIllustrationModelValidatorMock.Verify(x => x.ValidateCreateAsync(It.IsAny <ApiProductModelIllustrationRequestModel>())); mock.RepositoryMock.Verify(x => x.Create(It.IsAny <ProductModelIllustration>())); }
public async void All() { var mock = new ServiceMockFacade <IProductModelIllustrationRepository>(); var records = new List <ProductModelIllustration>(); records.Add(new ProductModelIllustration()); mock.RepositoryMock.Setup(x => x.All(It.IsAny <int>(), It.IsAny <int>())).Returns(Task.FromResult(records)); var service = new ProductModelIllustrationService(mock.LoggerMock.Object, mock.RepositoryMock.Object, mock.ModelValidatorMockFactory.ProductModelIllustrationModelValidatorMock.Object, mock.BOLMapperMockFactory.BOLProductModelIllustrationMapperMock, mock.DALMapperMockFactory.DALProductModelIllustrationMapperMock); List <ApiProductModelIllustrationResponseModel> 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 <IProductModelIllustrationRepository>(); var model = new ApiProductModelIllustrationRequestModel(); mock.RepositoryMock.Setup(x => x.Delete(It.IsAny <int>())).Returns(Task.CompletedTask); var service = new ProductModelIllustrationService(mock.LoggerMock.Object, mock.RepositoryMock.Object, mock.ModelValidatorMockFactory.ProductModelIllustrationModelValidatorMock.Object, mock.BOLMapperMockFactory.BOLProductModelIllustrationMapperMock, mock.DALMapperMockFactory.DALProductModelIllustrationMapperMock); ActionResponse response = await service.Delete(default(int)); response.Should().NotBeNull(); mock.RepositoryMock.Verify(x => x.Delete(It.IsAny <int>())); mock.ModelValidatorMockFactory.ProductModelIllustrationModelValidatorMock.Verify(x => x.ValidateDeleteAsync(It.IsAny <int>())); }