public void ApplyingCorrectSortingShouldNotAddOrderByOrOrderByDescending() { flatparams = new SpecParams() { Sort = "priceAsc" }; spec = new FlatForCountingSpecification(flatparams); Assert.Null(spec.OrderBy); flatparams.Sort = "areaAsc"; spec = new FlatForCountingSpecification(flatparams); Assert.Null(spec.OrderBy); spec = new FlatForCountingSpecification(flatparams); Assert.Null(spec.OrderByDescending); flatparams.Sort = "areaDesc"; spec = new FlatForCountingSpecification(flatparams); Assert.Null(spec.OrderByDescending); flatparams.Sort = "offerData"; spec = new FlatForCountingSpecification(flatparams); Assert.Null(spec.OrderByDescending); }
public void NotApplyingSortingShouldNotAddAnyOrder() { flatparams = new SpecParams(); spec = new FlatForCountingSpecification(flatparams); Assert.True(spec.OrderByDescending == null || spec.OrderBy == null); }
public ProductWithFiltersForCountSpecificication(SpecParams specParams) : base(x => (string.IsNullOrEmpty(specParams.Search) || x.Name.ToLower().Contains(specParams.Search)) && (string.IsNullOrEmpty(specParams.Search) || x.MeasurementName.ToLower().Contains(specParams.Search)) && (string.IsNullOrEmpty(specParams.BrandId) || x.ProductBrandId == specParams.BrandId) && (string.IsNullOrEmpty(specParams.TypeId) || x.ProductTypeId == specParams.TypeId)) { }
public ProductsWithTypesAndBrandsSpecification(SpecParams specParams) : base(x => (string.IsNullOrEmpty(specParams.Search) || x.Name.ToLower().Contains(specParams.Search)) && (string.IsNullOrEmpty(specParams.Search) || x.MeasurementName.ToLower().Contains(specParams.Search)) && (string.IsNullOrEmpty(specParams.BrandId) || x.ProductBrandId == specParams.BrandId) && (string.IsNullOrEmpty(specParams.TypeId) || x.ProductTypeId == specParams.TypeId)) { AddInclude(x => x.ProductType); AddInclude(x => x.ProductBrand); AddOrderBy(x => x.Name); ApplyPaging(specParams.PageSize * (specParams.PageIndex - 1), specParams.PageSize); if (!string.IsNullOrEmpty(specParams.Sort)) { switch (specParams.Sort) { case "priceAsc": AddOrderBy(p => p.Price); break; case "priceDesc": AddOrderByDescending(p => p.Price); break; default: AddOrderBy(n => n.Name); break; } } }
public void ApplyPaginationValuesShouldNotAddSkipAndTake() { flatparams = new SpecParams() { PageIndex = 1, PageSize = 20 }; spec = new FlatForCountingSpecification(flatparams); Assert.Null(spec.Skip); Assert.Null(spec.Take); }