Example #1
0
 public void All_fields_match_one_rule()
 {
     var fields = EnumHelper.GetAllValues<SmartViewField>();
     foreach (SmartViewField field in fields)
     {
         SmartViewRule rule = SmartViewHelper.GetSupportedRule(field);
         Assert.IsNotNull(rule);
     }
 }
Example #2
0
        public static T AssertRule<T>(this SmartViewHandler handler, int block, int rule, int ruleCount, SmartViewMatchType type, SmartViewField field, SmartViewFilter filter, Func<T, bool> checkRule)
            where T : SmartViewRule
        {
            SmartViewBlockRule smartViewBlockRule = handler.Blocks[block];

            Assert.AreEqual(ruleCount, smartViewBlockRule.Rules.Count);
            Assert.AreEqual(type, smartViewBlockRule.Match);            

            SmartViewRule smartViewRule = smartViewBlockRule.Rules[rule];

            Assert.AreEqual(field, smartViewRule.Field);
            Assert.AreEqual(filter, smartViewRule.Filter);

            SmartViewRule item = smartViewRule;
            Assert.IsTrue(item is T);

            Assert.IsTrue(checkRule((T) item));

            return (T) item;
        }