Exemple #1
0
        static void Main(string[] args)
        {
            List <Person> persons = new List <Person>();

            persons.Add(new Person("Bob", "Male", "Single"));
            persons.Add(new Person("Bobbie", "Female", "Single"));
            persons.Add(new Person("Jim", "Male", "Married"));
            persons.Add(new Person("Jenny", "Female", "Single"));
            persons.Add(new Person("Chris", "Male", "Single"));
            persons.Add(new Person("Heather", "Female", "Married"));
            persons.Add(new Person("Kim", "Female", "Single"));

            ICriteria male         = new CriteriaMale();
            ICriteria female       = new CriteriaFemale();
            ICriteria single       = new SingleCriteria();
            ICriteria singleMale   = new AndCriteria(single, male);
            ICriteria singleFemale = new AndCriteria(single, female);

            Console.WriteLine("Males: ");
            PrintPersons(male.MeetCriteria(persons));

            Console.WriteLine("\nFemales: ");
            PrintPersons(female.MeetCriteria(persons));

            Console.WriteLine("\nSingle Males: ");
            PrintPersons(singleMale.MeetCriteria(persons));

            Console.WriteLine("\nSingle Females: ");
            PrintPersons(singleFemale.MeetCriteria(persons));
        }
        public void CombineWithSingleCriteriaReturnsThatCriteria()
        {
            var rangeCriteria = new RangeCriteria("field", memberInfo, RangeComparison.LessThan, 1);
            var andCriteria   = AndCriteria.Combine(rangeCriteria);

            Assert.Same(rangeCriteria, andCriteria);
        }
        private void btFilterPattern_Click(object sender, EventArgs e)
        {
            string        str     = "";
            List <Person> persons = new List <Person>();

            persons.Add(new Person("Robert", "Male", "Single"));
            persons.Add(new Person("John", "Male", "Married"));
            persons.Add(new Person("Laura", "Female", "Married"));
            persons.Add(new Person("Diana", "Female", "Single"));
            persons.Add(new Person("Mike", "Male", "Single"));
            persons.Add(new Person("Bobby", "Male", "Single"));

            ICriteria male           = new CriteriaMale();
            ICriteria female         = new CriteriaFemale();
            ICriteria single         = new CriteriaSingle();
            ICriteria singleMale     = new AndCriteria(single, male);
            ICriteria singleOrFemale = new OrCriteria(single, female);

            str += "Males:\r\n ";
            str += printPersons(male.meetCriteria(persons)) + "\r\n";

            str += "Females:\r\n ";
            str += printPersons(female.meetCriteria(persons)) + "\r\n";

            str += "Single Males:\r\n ";
            str += printPersons(singleMale.meetCriteria(persons)) + "\r\n";

            str += "Single Or Females:\r\n ";
            str += printPersons(singleOrFemale.meetCriteria(persons)) + "\r\n";
            tbOutWindow.Text = str;
        }
        public void Setup()
        {
            var mockControlRepository = new MockControlRepository();
            _controlCollection = mockControlRepository.GetControlCollection();

            _coreCompetenceOnlyAudiologyCriteria =
                new CoreCompetenceCriteria(new[] {CoreCompetenceRole.Audiology});
            _coreCompetenceAudiologyOrDevEngCriteria =
                new CoreCompetenceCriteria(new[] {CoreCompetenceRole.Audiology, CoreCompetenceRole.DeviceEngineering,});

            _reviewCompetenceOnlyFirmwareCriteria =
                new ReviewCompetenceCriteria(new[] {ReviewCompetenceRole.FirmwareQa});

            _coreStateUnworkedOrResetCriteria =
                new CoreStateCriteria(new[] {CoreState.Unworked, CoreState.Reset});

            _reviewStateReleaseCandidateOrReleasedCriteria =
                new ReviewStateCriteria(new[] {ReviewState.ReleaseCandidate, ReviewState.Released,});

            _complexOrCriteria =
                new OrCriteria<ControlBase>(_coreCompetenceAudiologyOrDevEngCriteria,
                    _reviewCompetenceOnlyFirmwareCriteria);
            _complexAndCriteria =
                new AndCriteria<ControlBase>(new NotCriteria<ControlBase>(_coreStateUnworkedOrResetCriteria),
                    _reviewStateReleaseCandidateOrReleasedCriteria);
        }
        private JProperty Build(IFacet facet, ICriteria primaryFilter, long?defaultSize)
        {
            Argument.EnsureNotNull("facet", facet);

            var specificBody = Build(facet);

            if (facet is IOrderableFacet)
            {
                var facetSize = ((IOrderableFacet)facet).Size ?? defaultSize;
                if (facetSize.HasValue)
                {
                    specificBody["size"] = facetSize.Value.ToString(transportCulture);
                }
            }

            var namedBody = new JObject(new JProperty(facet.Type, specificBody));

            var combinedFilter = AndCriteria.Combine(primaryFilter, facet.Filter);

            if (combinedFilter != null)
            {
                namedBody[facet is FilterFacet ? "filter" : "facet_filter"] = Build(combinedFilter);
            }

            return(new JProperty(facet.Name, namedBody));
        }
Exemple #6
0
    public static void CriteriaPatternDemo()
    {
        Person p1 = new Person("Aykut", 24, Gender.MALE);
        Person p2 = new Person("Yilmaz", 55, Gender.MALE);
        Person p3 = new Person("Esra", 50, Gender.FEMALE);
        Person p4 = new Person("Zeynep", 12, Gender.FEMALE);

        List <Person> family = new List <Person>()
        {
            p1, p2, p3, p4
        };

        ICriteria <Person> maleCriteria   = new MaleCriteria();
        ICriteria <Person> femaleCriteria = new FemaleCriteria();
        ICriteria <Person> teenCriteria   = new TeenCriteria();

        var males   = maleCriteria.Filter(family).ToList();
        var females = femaleCriteria.Filter(family).ToList();
        var teens   = teenCriteria.Filter(family).ToList();

        ICriteria <Person> maleAndTeenCriteria = new AndCriteria(maleCriteria, teenCriteria);
        var teenMales = maleAndTeenCriteria.Filter(family);

        ICriteria <Person> femaleAndTeenCriteria = new AndCriteria(femaleCriteria, teenCriteria);
        var teenFemales = femaleAndTeenCriteria.Filter(family);

        ICriteria <Person> maleOrTeenCriteria = new OrCriteria(maleCriteria, teenCriteria);
        var malesOrTeens = maleOrTeenCriteria.Filter(family);
    }
        public IItem GetPageIdByIshLogicalReference(int publicationId, string ishLogicalRefValue)
        {
            try
            {
                Criteria dateCriteria = new ItemLastPublishedDateCriteria(DefaultPublishData, Criteria.GreaterThanOrEqual);
                CustomMetaKeyCriteria metaKeyCriteria = new CustomMetaKeyCriteria(RefFieldName);
                Criteria refCriteria = new CustomMetaValueCriteria(metaKeyCriteria, ishLogicalRefValue);
                Criteria pubCriteria = new PublicationCriteria(publicationId);
                Criteria itemType    = new ItemTypeCriteria((int)ItemType.Page);
                Criteria composite   = new AndCriteria(new[] { dateCriteria, refCriteria, itemType, pubCriteria });

                Query   query = new Query(composite);
                IItem[] items = query.ExecuteEntityQuery();
                if (items == null || items.Length == 0)
                {
                    return(new ItemImpl());
                }

                if (items.Length > 1)
                {
                    throw new TridionDocsApiException($"Too many page Ids found in publication with logical ref value {ishLogicalRefValue}");
                }

                return(items[0]);
            }
            catch (Exception)
            {
                throw new DxaItemNotFoundException($"Page reference by ishlogicalref.object.id = {ishLogicalRefValue} not found in publication {publicationId}.");
            }
        }
        public static void Start()
        {
            List <Person> persons = new List <Person>();

            persons.Add(new Person("Robert", "Male", "Single"));
            persons.Add(new Person("John", "Male", "Married"));
            persons.Add(new Person("Laura", "Female", "Married"));
            persons.Add(new Person("Diana", "Female", "Single"));
            persons.Add(new Person("Mike", "Male", "Single"));
            persons.Add(new Person("Bobby", "Male", "Single"));

            Criteria male           = new CriteriaMale();
            Criteria female         = new CriteriaFemale();
            Criteria single         = new CriteriaSingle();
            Criteria singleMale     = new AndCriteria(single, male);
            Criteria singleOrFemale = new OrCriteria(single, female);

            Console.WriteLine("Males: ");
            PrintPersons(male.MeetCriteria(persons));

            Console.WriteLine("\nFemales: ");
            PrintPersons(female.MeetCriteria(persons));

            Console.WriteLine("\nSingle Males: ");
            PrintPersons(singleMale.MeetCriteria(persons));

            Console.WriteLine("\nSingle Or Females: ");
            PrintPersons(singleOrFemale.MeetCriteria(persons));
        }
        void ApplyTypeSelectionCriteria()
        {
            var typeCriteria = Mapping.GetTypeSelectionCriteria(SourceType);

            searchRequest.Query = searchRequest.Query == null || searchRequest.Query == ConstantCriteria.True
                ? typeCriteria
                : AndCriteria.Combine(typeCriteria, searchRequest.Query);
        }
        public void ConstructorSetsCriteria()
        {
            var criteria = new AndCriteria(sampleCriteria1, sampleCriteria2);

            Assert.Contains(sampleCriteria1, criteria.Criteria);
            Assert.Contains(sampleCriteria2, criteria.Criteria);
            Assert.Equal(2, criteria.Criteria.Count);
        }
Exemple #11
0
        void ApplyTypeSelectionCriteria()
        {
            var typeCriteria = Mapping.GetTypeSelectionCriteria(SourceType);

            this.searchRequest.Filter = this.searchRequest.Filter == null || this.searchRequest.Filter == ConstantCriteria.True
                ? typeCriteria
                : AndCriteria.Combine(typeCriteria, this.searchRequest.Filter);
        }
        public static void AndCriteriaSample()
        {
            ICriteria        cr  = new AndCriteria(new[] { ICriteria.Empty, ICriteria.Empty });
            FormatedCriteria fCr = cr.Format(0);

            Console.WriteLine(fCr.Query);
            Console.WriteLine(fCr.Params.Length);
        }
Exemple #13
0
        private void ApplyTypeSelectionCriteria()
        {
            var typeCriteria = Mapping.GetTypeSelectionCriteria(sourceType);

            searchRequest.Filter = searchRequest.Filter == null || searchRequest.Filter == ConstantCriteria.True
                ? typeCriteria
                : AndCriteria.Combine(typeCriteria, searchRequest.Filter);
        }
Exemple #14
0
 /// <summary>
 /// 与连接,将传入的查询条件合并到当前对象
 /// </summary>
 /// <param name="predicate">谓词</param>
 public IQuery <TEntity, TKey> And(Expression <Func <TEntity, bool> > predicate)
 {
     if (Criteria == null)
     {
         Criteria = new Criteria <TEntity>(predicate);
         return(this);
     }
     Criteria = new AndCriteria <TEntity>(Criteria.GetPredicate(), predicate);
     return(this);
 }
Exemple #15
0
        public void AndWithFalseOptimizesToFalse()
        {
            var exists1  = new ExistsCriteria("1");
            var exists2  = new ExistsCriteria("2");
            var criteria = AndCriteria.Combine(exists1, ConstantCriteria.False, exists2);

            var actual = ConstantCriteriaFilterReducer.Reduce(criteria);

            Assert.Same(ConstantCriteria.False, actual);
        }
        public void CombineWithCriteriaCombinesIntoAndCriteria()
        {
            var criteria = AndCriteria.Combine(sampleCriteria1, sampleCriteria2);

            Assert.IsType <AndCriteria>(criteria);
            var andCriteria = (AndCriteria)criteria;

            Assert.Contains(sampleCriteria1, andCriteria.Criteria);
            Assert.Contains(sampleCriteria2, andCriteria.Criteria);
            Assert.Equal(2, andCriteria.Criteria.Count);
        }
Exemple #17
0
        Expression VisitQueryString(Expression source, Expression queryExpression, Expression fieldsExpression = null)
        {
            var constantQueryExpression = (ConstantExpression)queryExpression;
            var constantFieldExpression = fieldsExpression as ConstantExpression;
            var constantFields          = constantFieldExpression == null ? null : (string[])constantFieldExpression.Value;
            var criteriaExpression      = new CriteriaExpression(new QueryStringCriteria(constantQueryExpression.Value.ToString(), constantFields));

            searchRequest.Query = AndCriteria.Combine(searchRequest.Query, criteriaExpression.Criteria);

            return(Visit(source));
        }
        public void ToStringContainsSubfields()
        {
            var existsCriteria = new ExistsCriteria("thisIsAMissingField");
            var termCriteria   = TermsCriteria.Build("termField", memberInfo, "some value");

            var andCriteria = AndCriteria.Combine(existsCriteria, termCriteria);
            var result      = andCriteria.ToString();

            Assert.Contains(existsCriteria.ToString(), result);
            Assert.Contains(termCriteria.ToString(), result);
        }
Exemple #19
0
        public void AndBecomesBoolWithMust()
        {
            ICriteria[] expected = { new RangeCriteria("fieldOne", memberInfo, RangeComparison.LessThan, 2), new RangeCriteria("fieldTwo", memberInfo, RangeComparison.GreaterThan, 4) };

            var actual = QueryCriteriaRewriter.Compensate(AndCriteria.Combine(expected));

            var boolActual = Assert.IsType <BoolCriteria>(actual);

            Assert.Equal(boolActual.Must.AsEnumerable(), expected);
            Assert.Empty(boolActual.Should);
            Assert.Empty(boolActual.MustNot);
        }
Exemple #20
0
        public void AndWithNotsBecomesBoolWithMustNots()
        {
            var expectedMustNots = new[] { new RangeCriteria("field1", memberInfo, RangeComparison.LessThan, 2), new RangeCriteria("field2", memberInfo, RangeComparison.GreaterThan, 4) };

            var actual = QueryCriteriaRewriter.Compensate(AndCriteria.Combine(expectedMustNots.Select(NotCriteria.Create).ToArray()));

            var boolActual = Assert.IsType <BoolCriteria>(actual);

            Assert.Equal(boolActual.MustNot.AsEnumerable(), expectedMustNots);
            Assert.Empty(boolActual.Should);
            Assert.Empty(boolActual.Must);
        }
        public void AndWithOrsBecomesBoolWithShould()
        {
            var expected1 = new[] { new RangeCriteria("field1", memberInfo, RangeComparison.LessThan, 2), new RangeCriteria("field2", memberInfo, RangeComparison.GreaterThan, 4) };
            var expected2 = new[] { new RangeCriteria("field3", memberInfo, RangeComparison.LessThan, 2), new RangeCriteria("field4", memberInfo, RangeComparison.GreaterThan, 4) };

            var actual = QueryCriteriaRewriter.Compensate(AndCriteria.Combine(OrCriteria.Combine(expected1), OrCriteria.Combine(expected2)));

            var boolActual = Assert.IsType <BoolCriteria>(actual);

            Assert.Equal(boolActual.Should.AsEnumerable(), expected1.Concat(expected2));
            Assert.Empty(boolActual.Must);
            Assert.Empty(boolActual.MustNot);
        }
Exemple #22
0
        public void AndWithTrueRemovesTrue()
        {
            var exists1  = new ExistsCriteria("1");
            var exists2  = new ExistsCriteria("2");
            var criteria = AndCriteria.Combine(exists1, ConstantCriteria.True, exists2);

            var actual = ConstantCriteriaFilterReducer.Reduce(criteria);

            var andActual = Assert.IsType <AndCriteria>(actual);

            Assert.DoesNotContain(andActual.Criteria, c => c == ConstantCriteria.True);
            Assert.Single(andActual.Criteria, exists1);
            Assert.Single(andActual.Criteria, exists2);
        }
Exemple #23
0
        Expression VisitWhere(Expression source, Expression lambdaPredicate)
        {
            var lambda             = lambdaPredicate.GetLambda();
            var criteriaExpression = lambda.Body as CriteriaExpression ?? BooleanMemberAccessBecomesEquals(lambda.Body) as CriteriaExpression;

            if (criteriaExpression == null)
            {
                throw new NotSupportedException($"Where expression '{lambda.Body}' could not be translated");
            }

            searchRequest.Criteria = AndCriteria.Combine(searchRequest.Criteria, criteriaExpression.Criteria);

            return(Visit(source));
        }
Exemple #24
0
        public List <GroupedExperienceAndCategory> GetEducations()
        {
            var educationCriteria      = new EducationCriteria();
            var orderByEndDateCriteria = new OrderByEndDateCriteria();
            var bothCriteria           = new AndCriteria(educationCriteria, orderByEndDateCriteria);
            var listOfEducations       = bothCriteria.MeetCriteria(Experience);

            var listofGroupedExperienceAndCategories = new List <GroupedExperienceAndCategory>()
            {
                new GroupedExperienceAndCategory("Uddannelse", listOfEducations.ToList())
            };

            return(listofGroupedExperienceAndCategories);
        }
Exemple #25
0
        public void AndWithMixedContentBecomesBoolWithShouldMustAndMustNot()
        {
            ICriteria[] expectedShould  = { new RangeCriteria("field1", memberInfo, RangeComparison.LessThan, 2), new RangeCriteria("field2", memberInfo, RangeComparison.GreaterThan, 4) };
            var         expectedMust    = new RangeCriteria("field3", memberInfo, RangeComparison.LessThan, 2);
            var         expectedMustNot = new PrefixCriteria("field5", "prefix");

            var actual = QueryCriteriaRewriter.Compensate(AndCriteria.Combine(OrCriteria.Combine(expectedShould), expectedMust, NotCriteria.Create(expectedMustNot)));

            var boolActual = Assert.IsType <BoolCriteria>(actual);

            Assert.Equal(boolActual.Should.AsEnumerable(), expectedShould);
            Assert.Single(boolActual.Must, expectedMust);
            Assert.Single(boolActual.MustNot, expectedMustNot);
        }
        public void CombineWithTwoSameFieldRangeCriteriaCombinesIntoSingleRangeCriteria()
        {
            var lowerRangeCriteria = new RangeCriteria("first", memberInfo, RangeComparison.GreaterThan, "lower");
            var upperRangeCriteria = new RangeCriteria("first", memberInfo, RangeComparison.LessThanOrEqual, "upper");

            var andCriteria = AndCriteria.Combine(lowerRangeCriteria, upperRangeCriteria);

            Assert.IsType <RangeCriteria>(andCriteria);
            var rangeCriteria = (RangeCriteria)andCriteria;

            Assert.Equal(rangeCriteria.Field, lowerRangeCriteria.Field);
            Assert.Same(memberInfo, lowerRangeCriteria.Member);
            Assert.Single(rangeCriteria.Specifications, s => s.Comparison == lowerRangeCriteria.Specifications.First().Comparison);
            Assert.Single(rangeCriteria.Specifications, s => s.Comparison == upperRangeCriteria.Specifications.First().Comparison);
        }
        internal void CombineSameFieldRangeNotCombineIntoSingleRangeCriteriaIfConflictingComparisons(RangeComparison leftRangeComparison, RangeComparison rightRangeComparison)
        {
            var leftRangeCriteria  = new RangeCriteria("a", memberInfo, leftRangeComparison, "leftValue");
            var rightRangeCriteria = new RangeCriteria("a", memberInfo, rightRangeComparison, "rightValue");

            var criteria = AndCriteria.Combine(leftRangeCriteria, rightRangeCriteria);

            var rangeCriteria = Assert.IsType <AndCriteria>(criteria).Criteria.OfType <RangeCriteria>().ToList();

            Assert.Equal(2, rangeCriteria.Count());
            Assert.All(rangeCriteria, c => Assert.True(Assert.IsType <RangeCriteria>(c).Member == memberInfo));

            Assert.Single(rangeCriteria, leftRangeCriteria);
            Assert.Single(rangeCriteria, rightRangeCriteria);
        }
        public void NotWithAndBecomesBoolWithMustNotBool()
        {
            var expected = new[] { new RangeCriteria("fieldOne", memberInfo, RangeComparison.LessThan, 2), new RangeCriteria("fieldTwo", memberInfo, RangeComparison.GreaterThan, 4) };

            var actual = QueryCriteriaRewriter.Compensate(NotCriteria.Create(AndCriteria.Combine(expected)));

            var boolActual = Assert.IsType <BoolCriteria>(actual);

            Assert.Empty(boolActual.Should);
            Assert.Empty(boolActual.Must);
            Assert.Single(boolActual.MustNot);
            var subBoolActual = Assert.IsType <BoolCriteria>(boolActual.MustNot.First());

            Assert.Equal(subBoolActual.Must.AsEnumerable(), expected);
            Assert.Empty(subBoolActual.Should);
            Assert.Empty(subBoolActual.MustNot);
        }
Exemple #29
0
        public void TryRedirect(Object s, EventArgs e)
        {
            HttpContext context = HttpContext.Current;

            int    publicationId = int.Parse(ConfigurationManager.AppSettings["GlobalPubId"]);
            string redirectField = ConfigurationManager.AppSettings["RedirectUrlField"];

            string url = context.Request.Url.PathAndQuery;
            int    pos = url.IndexOf("?");

            if (pos > 0)
            {
                url = url.Substring(0, pos);
            }

            PublicationCriteria     publicationCriteria = new PublicationCriteria(publicationId);
            ItemTypeCriteria        itemCriteria        = new ItemTypeCriteria(64);
            CustomMetaValueCriteria cmvCriteria         = new CustomMetaValueCriteria(new CustomMetaKeyCriteria(redirectField), url);
            AndCriteria             andCriteria         = new AndCriteria(new Criteria[] { publicationCriteria, itemCriteria, cmvCriteria });

            Query query = new Query(andCriteria);

            string[] results = query.ExecuteQuery();

            if (results.Length > 0)
            {
                PageLink pageLink = new PageLink(publicationId);
                Link     link     = pageLink.GetLink(results[0]);

                if (link.IsResolved)
                {
                    // Redirect
                    HttpResponse response = context.Response;
                    response.Clear();
                    response.RedirectLocation  = link.Url;
                    response.StatusCode        = 301;
                    response.StatusDescription = "301 Moved Permanently";
                    response.Write("Page has moved to " + link.Url);
                    response.End();
                }
            }
        }
Exemple #30
0
        Expression VisitQuery(Expression source, Expression predicate)
        {
            var lambda    = predicate.GetLambda();
            var wasWithin = within;

            within = CriteriaWithin.Query;
            var body = BooleanMemberAccessBecomesEquals(lambda.Body);

            var criteriaExpression = body as CriteriaExpression;

            if (criteriaExpression == null)
            {
                throw new NotSupportedException(string.Format("Query expression '{0}' could not be translated", body));
            }

            searchRequest.Query = AndCriteria.Combine(searchRequest.Query, criteriaExpression.Criteria);
            within = wasWithin;

            return(Visit(source));
        }
Exemple #31
0
        public void TryRedirect(Object s, EventArgs e)
        {
            HttpContext context = HttpContext.Current;

            int publicationId = int.Parse(ConfigurationManager.AppSettings["GlobalPubId"]);
            string redirectField = ConfigurationManager.AppSettings["RedirectUrlField"];

            string url = context.Request.Url.PathAndQuery;
            int pos = url.IndexOf("?");
            if (pos > 0) url = url.Substring(0, pos);

            PublicationCriteria publicationCriteria = new PublicationCriteria(publicationId);
            ItemTypeCriteria itemCriteria = new ItemTypeCriteria(64);
            CustomMetaValueCriteria cmvCriteria = new CustomMetaValueCriteria(new CustomMetaKeyCriteria(redirectField), url);
            AndCriteria andCriteria = new AndCriteria(new Criteria[] { publicationCriteria, itemCriteria, cmvCriteria });

            Query query = new Query(andCriteria);

            string[] results = query.ExecuteQuery();

            if (results.Length > 0)
            {
                PageLink pageLink = new PageLink(publicationId);
                Link link = pageLink.GetLink(results[0]);

                if (link.IsResolved)
                {
                    // Redirect
                    HttpResponse response = context.Response;
                    response.Clear();
                    response.RedirectLocation = link.Url;
                    response.StatusCode = 301;
                    response.StatusDescription = "301 Moved Permanently";
                    response.Write("Page has moved to " + link.Url);
                    response.End();
                }
            }
        }
        public void CombineWithDifferentFieldRangeCriteriaCombinesRangesIntoAndCriteria()
        {
            var firstMemberInfo  = typeof(string).GetProperty("Length");
            var secondMemberInfo = typeof(string).GetMethod("Clone");
            var lowerFirstRange  = new RangeCriteria("first", firstMemberInfo, RangeComparison.GreaterThan, "lower");
            var upperFirstRange  = new RangeCriteria("first", firstMemberInfo, RangeComparison.LessThanOrEqual, "upper");
            var secondRange      = new RangeCriteria("second", secondMemberInfo, RangeComparison.GreaterThanOrEqual, "lower2");

            var criteria = AndCriteria.Combine(lowerFirstRange, secondRange, upperFirstRange);

            Assert.IsType <AndCriteria>(criteria);
            var andCriteria = (AndCriteria)criteria;

            Assert.Equal(2, andCriteria.Criteria.Count);
            Assert.Contains(secondRange, andCriteria.Criteria);

            var combinedRange = andCriteria.Criteria.OfType <RangeCriteria>().FirstOrDefault(r => r.Specifications.Count == 2);

            Assert.NotNull(combinedRange);
            Assert.Equal(lowerFirstRange.Field, combinedRange.Field);
            Assert.Same(firstMemberInfo, combinedRange.Member);
            Assert.Single(combinedRange.Specifications, s => s.Comparison == lowerFirstRange.Specifications.First().Comparison);
            Assert.Single(combinedRange.Specifications, s => s.Comparison == upperFirstRange.Specifications.First().Comparison);
        }