public void NotApplyingAnyAttributesShouldNotAddCritiria() { flatparams = new SpecParams(); spec = new FlatSpecification(flatparams); Assert.Null(spec.Criteria); }
public void NotApplyingSortingShouldAddSomeOrder() { flatparams = new SpecParams(); spec = new FlatSpecification(flatparams); Assert.True(spec.OrderByDescending != null || spec.OrderBy != null); }
public void ApplyingManyAttributesShouldAddCritiria() { flatparams = new SpecParams() { IsAccepted = true, IsUsedInModel = false }; spec = new FlatSpecification(flatparams); Assert.NotNull(spec.Criteria); }
public ActionResult <Pagination <FlatDTO> > GetFlats( [FromQuery] SpecParams specParams) { var spec = new FlatSpecification(specParams); var countSpec = new FlatForCountingSpecification(specParams); var totalCount = flatRepository.Count(countSpec); var flats = flatRepository.GetFlats(spec); var data = mapper.Map <IReadOnlyList <Flat>, IReadOnlyList <FlatDTO> >(flats); return(Ok(new Pagination <FlatDTO>(specParams.PageIndex, specParams.PageSize, totalCount, data))); }
private IReadOnlyList <Flat> getOffersToFeedModel() { var specParams = new SpecParams() { IsAccepted = true, IsUsedInModel = false, PageSize = 10000 }; var spec = new FlatSpecification(specParams); return(flatRepository.GetFlats(spec)); }
public void ApplyingCorrectSortingShouldAddOrderBy() { flatparams = new SpecParams() { Sort = "priceAsc" }; spec = new FlatSpecification(flatparams); Assert.NotNull(spec.OrderBy); flatparams.Sort = "areaAsc"; spec = new FlatSpecification(flatparams); Assert.NotNull(spec.OrderBy); }
public void ApplyIncorectPaginationValuesShouldAddCorrectSkipAndTake() { flatparams = new SpecParams() { PageIndex = 1, PageSize = 20 }; flatparams.PageSize = 0; spec = new FlatSpecification(flatparams); Assert.True(spec.Skip == 0 && spec.Take == 20); flatparams.PageIndex = -1; spec = new FlatSpecification(flatparams); Assert.True(spec.Skip == 0 && spec.Take == 20); }
public void ApplyingCorrectSortingShouldAddOrderByDescending() { flatparams = new SpecParams() { Sort = "priceDesc" }; spec = new FlatSpecification(flatparams); Assert.NotNull(spec.OrderByDescending); flatparams.Sort = "areaDesc"; spec = new FlatSpecification(flatparams); Assert.NotNull(spec.OrderByDescending); flatparams.Sort = "offerData"; spec = new FlatSpecification(flatparams); Assert.NotNull(spec.OrderByDescending); }
public void ApplyPaginationValuesReturnCorrectSkipAndTake() { flatparams = new SpecParams() { PageIndex = 1, PageSize = 20 }; spec = new FlatSpecification(flatparams); Assert.True(spec.Skip == 0 && spec.Take == 20); flatparams.PageIndex = 2; spec = new FlatSpecification(flatparams); Assert.True(spec.Skip == 20 && spec.Take == 20); flatparams.PageSize = 4; spec = new FlatSpecification(flatparams); Assert.True(spec.Skip == 4 && spec.Take == 4); }