public void TestMethod1() { IDictionary <string, object> src = new Dictionary <string, object>(); var dest = new List <ExpandoObject>(); src.Add(new KeyValuePair <string, object>("objectOne", "valueOne")); src.Add(new KeyValuePair <string, object>("objectTwo", "valueTwo")); src.Add(new KeyValuePair <string, object>("objectThree", "valueThree")); src.Add(new KeyValuePair <string, object>("objectFour", "valueFour")); var ruleList = new RuleList(); var ruleOne = new IncludeRule("!=", "string", "valueZero", true); var ruleSet = new RuleSet(); var iRules = new List <IRule> { ruleOne }; ruleList.RuleSets.Add(ruleSet); var ruleTwo = new IncludeRule("==", "string", "valueOne", true); var ruleThree = new IncludeRule("==", "string", "valueTwo", true); var ruleFour = new IncludeRule("==", "string", "valueThree", true); var ruleFive = new ExcludeRule("==", "string", "valueThree", true); var ruleSix = new ErrorCheckRule("!=", "string", "valueZero", true); //ruleList.RuleSets.Add(); ruleList.Execute(src, ref dest); }
public void SerializeRules() { var rule1 = new IncludeRule { ComparisonOperator = "==", ComparisonType = "int", CompareRuleObject = new KeyValuePair <string, object>("ShpId", "13"), ExpectedResult = false }; var rule2 = new IncludeRule { ComparisonOperator = "==", ComparisonType = "int", CompareRuleObject = new KeyValuePair <string, object>("ShpId", "14"), ExpectedResult = false }; var rule3 = new ExcludeRule { ComparisonOperator = "!=", ComparisonType = "int", CompareRuleObject = new KeyValuePair <string, object>("ShpId", "13"), ExpectedResult = false }; var rule4 = new ErrorCheckRule { ComparisonOperator = ">", ComparisonType = "int", CompareRuleObject = new KeyValuePair <string, object>("ShpId", "19"), ExpectedResult = false }; var ruleSet = new RuleSet(); ruleSet.RuleSets.Add(rule1); ruleSet.RuleSets.Add(rule2); var ruleSet2 = new RuleSet(); ruleSet2.RuleSets.Add(rule3); var ruleSet3 = new RuleSet(); ruleSet3.RuleSets.Add(rule4); var ruleSets = new List <RuleSet> { ruleSet, ruleSet2, ruleSet3 }; var json = JsonConvert.SerializeObject(ruleSets); }