Esempio n. 1
0
        private static async Task PerformAnalysis(ProductFilterContext context)
        {
            var filterResults          = context.ApplyFilters().Take(MAX_PRINTED_RESULTS);
            var evaluatedFilterResults = filterResults.ToList();

            Console.WriteLine(JsonUtils.Convert(evaluatedFilterResults));

            var domains = await context.Domains();

            Console.WriteLine(JsonUtils.Convert(domains));
        }
        public async Task Should_Set_Filter_With_TrySet_JsonArray()
        {
            var filterContext = new ProductFilterContext(CreateTestProducts().AsQueryable());

            filterContext.TrySet(_allArrayObject);

            var filterResults = filterContext.ApplyFilters();

            filterResults.Should().NotContain(entity => entity.Rating < 1 || entity.Rating > 7);
            filterResults.Should().NotContain(entity => !_allowedNames.Contains(entity.Name));
            filterResults.Should().NotContain(entity => entity.Sold <= 600);

            var domains = await filterContext.Domains(CalculationStrategy.WithoutSelectableValues);

            domains.Should().HaveCount(3);
        }
        public async Task Should_Set_Filter_With_TrySet()
        {
            var filterContext = new ProductFilterContext(CreateTestProducts().AsQueryable());

            filterContext.RatingFilter.Set(1, 7);
            filterContext.NameFilter.Set("Piza", "Chicken", "Chese", "Fish", "Tun");
            filterContext.SoldFilter.Set(600);

            var filterResults = filterContext.ApplyFilters();

            filterResults.Should().NotContain(entity => entity.Rating < 1 || entity.Rating > 7);
            filterResults.Should().NotContain(entity => !_allowedNames.Contains(entity.Name));
            filterResults.Should().NotContain(entity => entity.Sold <= 600);

            var domains = await filterContext.Domains(CalculationStrategy.WithoutSelectableValues);

            domains.Should().HaveCount(3);
        }
        public async Task Should_Set_Filter_With_Resolver_Instance()
        {
            var filterContext = new ProductFilterContext(CreateTestProducts().AsQueryable());

            filterContext.TrySet("Rating", 1, 7);
            filterContext.TrySet("Name", _allowedNames);
            filterContext.TrySet("Sold", 600);

            var filterResults = filterContext.ApplyFilters();

            filterResults.Should().NotContain(entity => entity.Rating < 1 || entity.Rating > 7);
            filterResults.Should().NotContain(entity => !_allowedNames.Contains(entity.Name));
            filterResults.Should().NotContain(entity => entity.Sold <= 600);

            var domains = await filterContext.Domains();

            domains.Should().HaveCount(3);
        }
        public async Task Should_Set_Filter_With_TrySet_Json()
        {
            var filterContext = new ProductFilterContext(CreateTestProducts().AsQueryable());

            filterContext.TrySet(_rangeObject);
            filterContext.TrySet(_listObject);
            filterContext.TrySet(_greaterThanObject);

            var filterResults = filterContext.ApplyFilters();

            filterResults.Should().NotContain(entity => entity.Rating < 1 || entity.Rating > 7);
            filterResults.Should().NotContain(entity => !_allowedNames.Contains(entity.Name));
            filterResults.Should().NotContain(entity => entity.Sold <= 600);

            var domains = await filterContext.Domains();

            domains.Should().HaveCount(3);
        }