Exemplo n.º 1
0
        public void NotApplyingAnyAttributesShouldNotAddCritiria()
        {
            flatparams = new SpecParams();

            spec = new FlatSpecification(flatparams);
            Assert.Null(spec.Criteria);
        }
Exemplo n.º 2
0
        public void NotApplyingSortingShouldAddSomeOrder()
        {
            flatparams = new SpecParams();

            spec = new FlatSpecification(flatparams);
            Assert.True(spec.OrderByDescending != null || spec.OrderBy != null);
        }
Exemplo n.º 3
0
        public void ApplyingManyAttributesShouldAddCritiria()
        {
            flatparams = new SpecParams()
            {
                IsAccepted    = true,
                IsUsedInModel = false
            };

            spec = new FlatSpecification(flatparams);
            Assert.NotNull(spec.Criteria);
        }
Exemplo n.º 4
0
        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)));
        }
Exemplo n.º 5
0
        private IReadOnlyList <Flat> getOffersToFeedModel()
        {
            var specParams = new SpecParams()
            {
                IsAccepted    = true,
                IsUsedInModel = false,
                PageSize      = 10000
            };
            var spec = new FlatSpecification(specParams);

            return(flatRepository.GetFlats(spec));
        }
Exemplo n.º 6
0
        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);
        }
Exemplo n.º 7
0
        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);
        }
Exemplo n.º 8
0
        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);
        }
Exemplo n.º 9
0
        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);
        }