/// <summary> /// <see cref="Microsoft.Samples.NLayerApp.Application.MainBoundedContext.ERPModule.Services.ISalesAppService"/> /// </summary> /// <param name="text"><see cref="Microsoft.Samples.NLayerApp.Application.MainBoundedContext.ERPModule.Services.ISalesAppService"/></param> /// <returns><see cref="Microsoft.Samples.NLayerApp.Application.MainBoundedContext.ERPModule.Services.ISalesAppService"/></returns> public List <ProductDTO> FindProducts(string text) { //create the specification ( howto find products for any string ) var spec = ProductSpecifications.ProductFullText(text); //recover products var products = _productRepository.AllMatching(spec); //adapt results return(products.ProjectedAsCollection <ProductDTO>()); }
public void ProductFullTextSpecificationEmptyDataReturnTrueSpecification() { //Arrange string productData = string.Empty; //Act var specification = ProductSpecifications.ProductFullText(productData); //Assert Assert.NotNull(specification); Assert.IsType <TrueSpecification <Product> >(specification); }
public void ProductFullTextSpecificationNonEmptyDataReturnAndSpecification() { //Arrange string productData = "the product title or product description data"; //Act var specification = ProductSpecifications.ProductFullText(productData); //Assert Assert.NotNull(specification); Assert.IsType <AndSpecification <Product> >(specification); }
public void ProductFullTextSpecificationNullDataReturnTrueSpecification() { //Arrange string productData = null; //Act var specification = ProductSpecifications.ProductFullText(productData); //Assert Assert.IsNotNull(specification); Assert.IsInstanceOfType(specification, typeof(TrueSpecification <Product>)); }
public void ProductFullTextSpecificationNonEmptyDataReturnAndSpecification() { //Arrange var productData = "the product title or product description data"; //Act var specification = ProductSpecifications.ProductFullText(productData); //Assert Assert.IsNotNull(specification); Assert.IsInstanceOfType(specification, typeof(AndSpecification <Product>)); }
public void ProductRepositoryAllMatchingMethodReturnEntitiesWithSatisfiedCriteria() { //Arrange IProductRepository productRepository = new ProductRepository(fixture.unitOfWork, fixture.productLogger); var spec = ProductSpecifications.ProductFullText("book"); //Act var result = productRepository.AllMatching(spec); //Assert Assert.NotNull(result.All(p => p.Title.Contains("book") || p.Description.Contains("book"))); }
public async Task <ActionResult <ProductDto> > GetProduct(Guid id) { var spec = new ProductSpecifications(id); var product = await _productsRepo.GetEntityWithSpec(spec); if (product == null) { return(NotFound(new ApiResponse(404))); } return(_mapper.Map <Product, ProductDto>(product)); }
public async Task <ActionResult <IReadOnlyList <Pagination <ProductDto> > > > GetProducts([FromQuery] ProductSpecParams productParams) { var spec = new ProductSpecifications(productParams); var products = await _productsRepo.ListAsync(spec); var countSpec = new ProductCountSpecification(productParams); var totalItems = await _productsRepo.CountAsync(countSpec); var data = _mapper.Map <IReadOnlyList <Product>, IReadOnlyList <ProductDto> >(products); return(Ok(new Pagination <ProductDto>(productParams.PageIndex, productParams.PageSize, totalItems, data))); }
public ProductIsValidToImportValidator( DomainModelValidatorBaseSpecifications <Product> domainModelValidatorBaseSpecifications, ProductSpecifications productSpecifications ) : base(domainModelValidatorBaseSpecifications) { AddSpecification(domainModelValidatorBaseSpecifications.DomainModelMustHaveIdSpecification); AddSpecificationsForTenantInfo(); AddSpecificationsForCreationInfo(); AddSpecificationsForActivationInfo(); AddSpecification(productSpecifications.ProductMustHaveCodeSpecification); AddSpecification(productSpecifications.ProductMustHaveCodeWithValidLengthSpecification); AddSpecification(productSpecifications.ProductMustHaveDescriptionWithValidLengthSpecification); AddSpecification(productSpecifications.ProductMustHaveNameSpecification); AddSpecification(productSpecifications.ProductMustHaveNameWithValidLengthSpecification); }