Ejemplo n.º 1
0
 public void Test2()
 {
     DataRuleContext context = new DataRuleContext(null, null) { ValueProvider = new NameValueCollectionValueProvider(new NameValueCollection()) };
     WhereClause[] clauses = new WhereClause[] {
         new WhereClause(){ FieldName="title", Operator = Operator.Contains, Value1= "title1",Logical = Logical.Or },
         new WhereClause(){ FieldName="title", Operator = Operator.Contains,Value1="title1",Logical = Logical.And },
         new WhereClause(){ FieldName="body", Operator = Operator.Contains,Value1="body1",Logical = Logical.Or },
         new WhereClause(){ FieldName="body", Operator = Operator.Contains,Value1="body2",Logical = Logical.Or },
         new WhereClause(){ FieldName="userkey", Operator = Operator.Contains,Value1="userkey1",Logical = Logical.Or }
     };
     var expression = WhereClauseToContentQueryHelper.Parse(clauses, context);
     var query = new TranslatedQueryMock();
     StringVisitor visitor = new StringVisitor(query);
     visitor.Visite(expression);
     Assert.AreEqual("((((((((title Conatins title1) OR (title Conatins title1))) AND (body Conatins body1))) OR (body Conatins body2))) OR (userkey Conatins userkey1))", query.ClauseText);
 }
Ejemplo n.º 2
0
        public void Test2()
        {
            DataRuleContext context = new DataRuleContext(null, null)
            {
                ValueProvider = new NameValueCollectionValueProvider(new NameValueCollection())
            };

            WhereClause[] clauses = new WhereClause[] {
                new WhereClause()
                {
                    FieldName = "title", Operator = Operator.Contains, Value1 = "title1", Logical = Logical.Or
                },
                new WhereClause()
                {
                    FieldName = "title", Operator = Operator.Contains, Value1 = "title1", Logical = Logical.And
                },
                new WhereClause()
                {
                    FieldName = "body", Operator = Operator.Contains, Value1 = "body1", Logical = Logical.Or
                },
                new WhereClause()
                {
                    FieldName = "body", Operator = Operator.Contains, Value1 = "body2", Logical = Logical.Or
                },
                new WhereClause()
                {
                    FieldName = "userkey", Operator = Operator.Contains, Value1 = "userkey1", Logical = Logical.Or
                }
            };
            var           expression = WhereClauseToContentQueryHelper.Parse(clauses, context);
            var           query      = new TranslatedQueryMock();
            StringVisitor visitor    = new StringVisitor(query);

            visitor.Visite(expression);
            Assert.AreEqual("((((((((title Conatins title1) OR (title Conatins title1))) AND (body Conatins body1))) OR (body Conatins body2))) OR (userkey Conatins userkey1))", query.ClauseText);
        }