public void TestFilterNotCondition()
        {
            TestCaseFilter filter = new TestCaseFilter();
            RuleGroup      group1 = new RuleGroup()
            {
                Name          = "Group1",
                Description   = "This is the first group.",
                RuleGroupType = RuleType.Selector
            };
            Rule rule11 = new Rule()
            {
                Name         = "Rule11",
                SelectStatus = RuleSelectStatus.Selected,
                CategoryList = new System.Collections.Generic.List <string>()
                {
                    "Cat1", "Cat2", "Cat3"
                }
            };
            Rule rule12 = new Rule()
            {
                Name         = "Rule12",
                SelectStatus = RuleSelectStatus.Selected,
                CategoryList = new System.Collections.Generic.List <string>()
                {
                    "Cat4", "Cat5", "Cat6"
                }
            };

            group1.Add(rule11);
            group1.Add(rule12);

            RuleGroup group2 = new RuleGroup()
            {
                Name          = "Group2",
                Description   = "This is the second group.",
                RuleGroupType = RuleType.Selector
            };
            Rule rule2 = new Rule()
            {
                Name         = "Rule2",
                SelectStatus = RuleSelectStatus.Selected,
                CategoryList = new System.Collections.Generic.List <string>()
                {
                    "!Cat1", "!Cat2", "Cat3"
                }
            };

            group2.Add(rule2);
            filter.Add(group1);
            filter.Add(group2);

            string filterExp = filter.GetFilterExpression();

            Assert.AreEqual(
                "(TestCategory=Cat4|TestCategory=Cat5|TestCategory=Cat6|TestCategory=Cat1|TestCategory=Cat2|TestCategory=Cat3)&(TestCategory!=Cat1|TestCategory!=Cat2|TestCategory=Cat3)",
                filterExp,
                "Verify filter expression with NOT condition.");
        }
        public void TestFilterNotCondition()
        {
            TestCaseFilter filter = new TestCaseFilter();
            RuleGroup group1 = new RuleGroup()
            {
                Name = "Group1",
                Description = "This is the first group.",
                RuleGroupType = RuleType.Selector
            };
            Rule rule11 = new Rule()
            {
                Name = "Rule11",
                SelectStatus = RuleSelectStatus.Selected,
                CategoryList = new System.Collections.Generic.List<string>() { "Cat1", "Cat2", "Cat3" }
            };
            Rule rule12 = new Rule()
            {
                Name = "Rule12",
                SelectStatus = RuleSelectStatus.Selected,
                CategoryList = new System.Collections.Generic.List<string>() { "Cat4", "Cat5", "Cat6" }
            };
            group1.Add(rule11);
            group1.Add(rule12);

            RuleGroup group2 = new RuleGroup()
            {
                Name = "Group2",
                Description = "This is the second group.",
                RuleGroupType = RuleType.Selector
            };
            Rule rule2 = new Rule()
            {
                Name = "Rule2",
                SelectStatus = RuleSelectStatus.Selected,
                CategoryList = new System.Collections.Generic.List<string>() { "!Cat1", "!Cat2", "Cat3" }
            };
            group2.Add(rule2);
            filter.Add(group1);
            filter.Add(group2);

            string filterExp = filter.GetFilterExpression();
            Assert.AreEqual(
                "(TestCategory=Cat4|TestCategory=Cat5|TestCategory=Cat6|TestCategory=Cat1|TestCategory=Cat2|TestCategory=Cat3)&(TestCategory!=Cat1|TestCategory!=Cat2|TestCategory=Cat3)",
                filterExp,
                "Verify filter expression with NOT condition.");
        }
        private TestCaseFilter CreateSampleTestFilter()
        {
            TestCaseFilter filter = new TestCaseFilter();
            RuleGroup      group1 = new RuleGroup()
            {
                Name          = "Group1",
                Description   = "This is the first group.",
                RuleGroupType = RuleType.Selector
            };
            Rule rule1 = new Rule()
            {
                Name         = "Rule1",
                SelectStatus = RuleSelectStatus.Selected
            };
            Rule rule11 = new Rule()
            {
                Name         = "Rule11",
                SelectStatus = RuleSelectStatus.Selected,
                CategoryList = new System.Collections.Generic.List <string>()
                {
                    "Cat1", "Cat2", "Cat3"
                }
            };
            Rule rule12 = new Rule()
            {
                Name         = "Rule12",
                SelectStatus = RuleSelectStatus.UnSelected,
                CategoryList = new System.Collections.Generic.List <string>()
                {
                    "Cat4", "Cat5", "Cat6"
                }
            };

            rule1.Add(rule11);
            rule1.Add(rule12);
            group1.Add(rule1);

            RuleGroup group2 = new RuleGroup()
            {
                Name          = "Group2",
                Description   = "This is the second group.",
                RuleGroupType = RuleType.Selector
            };
            Rule rule2 = new Rule()
            {
                Name         = "Rule2",
                SelectStatus = RuleSelectStatus.UnSelected,
                CategoryList = new System.Collections.Generic.List <string>()
                {
                    "Cat1", "Cat2", "Cat3"
                }
            };

            group2.Add(rule2);

            RuleGroup group3 = new RuleGroup()
            {
                Name          = "Group3",
                Description   = "This is the third group.",
                SelectStatus  = RuleSelectStatus.Selected,
                RuleGroupType = RuleType.Remover
            };
            Rule rule3 = new Rule()
            {
                Name         = "Rule3",
                SelectStatus = RuleSelectStatus.Selected,
                CategoryList = new System.Collections.Generic.List <string>()
                {
                    "Cat7", "Cat8"
                }
            };

            group3.Add(rule3);

            filter.Add(group1);
            filter.Add(group2);
            filter.Add(group3);

            rule11.SelectStatus = RuleSelectStatus.Selected;
            rule3.SelectStatus  = RuleSelectStatus.UnSelected;
            return(filter);
        }
        private TestCaseFilter CreateSampleTestFilter()
        {
            TestCaseFilter filter = new TestCaseFilter();
            RuleGroup group1 = new RuleGroup()
            {
                Name = "Group1",
                Description = "This is the first group.",
                RuleGroupType = RuleType.Selector
            };
            Rule rule1 = new Rule()
            {
                Name = "Rule1",
                SelectStatus = RuleSelectStatus.Selected
            };
            Rule rule11 = new Rule()
            {
                Name = "Rule11",
                SelectStatus = RuleSelectStatus.Selected,
                CategoryList = new System.Collections.Generic.List<string>() { "Cat1", "Cat2", "Cat3" }
            };
            Rule rule12 = new Rule()
            {
                Name = "Rule12",
                SelectStatus = RuleSelectStatus.NotSelected,
                CategoryList = new System.Collections.Generic.List<string>() { "Cat4", "Cat5", "Cat6" }
            };
            rule1.Add(rule11);
            rule1.Add(rule12);
            group1.Add(rule1);

            RuleGroup group2 = new RuleGroup()
            {
                Name = "Group2",
                Description = "This is the second group.",
                RuleGroupType = RuleType.Selector
            };
            Rule rule2 = new Rule()
            {
                Name = "Rule2",
                SelectStatus = RuleSelectStatus.NotSelected,
                CategoryList = new System.Collections.Generic.List<string>() { "Cat1", "Cat2", "Cat3" }
            };
            group2.Add(rule2);

            RuleGroup group3 = new RuleGroup()
            {
                Name = "Group3",
                Description = "This is the third group.",
                SelectStatus = RuleSelectStatus.Selected,
                RuleGroupType = RuleType.Remover
            };
            Rule rule3 = new Rule()
            {
                Name = "Rule3",
                SelectStatus = RuleSelectStatus.Selected,
                CategoryList = new System.Collections.Generic.List<string>() { "Cat7", "Cat8" }
            };
            group3.Add(rule3);

            filter.Add(group1);
            filter.Add(group2);
            filter.Add(group3);

            rule11.SelectStatus = RuleSelectStatus.Selected;
            rule3.SelectStatus = RuleSelectStatus.NotSelected;
            return filter;
        }