Beispiel #1
0
        public void IdFilter_AddIds()
        {
            var filter = new IdFilter();

            filter.Add(dummyFixture.Id);
            filter.Add(anotherFixture.Id);

            Assert.False(filter.IsEmpty);
            Assert.That(filter.Match(dummyFixture));
            Assert.That(filter.Match(anotherFixture));
            Assert.False(filter.Match(yetAnotherFixture));
        }
Beispiel #2
0
        private static TestFilter FromXml(TNode node)
        {
            switch (node.Name)
            {
            case "filter":
            case "and":
                var andFilter = new AndFilter();
                foreach (var childNode in node.ChildNodes)
                {
                    andFilter.Add(FromXml(childNode));
                }
                return(andFilter);

            case "or":
                var orFilter = new OrFilter();
                foreach (var childNode in node.ChildNodes)
                {
                    orFilter.Add(FromXml(childNode));
                }
                return(orFilter);

            case "not":
                return(new NotFilter(FromXml(node.FirstChild)));

            case "id":
                var idFilter = new IdFilter();
                if (node.Value != null)
                {
                    foreach (string id in node.Value.Split(COMMA))
                    {
                        idFilter.Add(id);
                    }
                }
                return(idFilter);

            case "tests":
                var testFilter = new SimpleNameFilter();
                foreach (var childNode in node.SelectNodes("test"))
                {
                    testFilter.Add(childNode.Value);
                }
                return(testFilter);

            case "cat":
                var catFilter = new CategoryFilter();
                if (node.Value != null)
                {
                    foreach (string cat in node.Value.Split(COMMA))
                    {
                        catFilter.AddCategory(cat);
                    }
                }
                return(catFilter);

            default:
                throw new ArgumentException("Invalid filter element: " + node.Name, "xmlNode");
            }
        }
Beispiel #3
0
        private static TestFilter FromXml(XmlNode xmlNode)
        {
            switch (xmlNode.Name)
            {
            case "filter":
            case "and":
                var andFilter = new AndFilter();
                foreach (XmlNode childNode in xmlNode.ChildNodes)
                {
                    andFilter.Add(FromXml(childNode));
                }
                return(andFilter);

            case "or":
                var orFilter = new OrFilter();
                foreach (System.Xml.XmlNode childNode in xmlNode.ChildNodes)
                {
                    orFilter.Add(FromXml(childNode));
                }
                return(orFilter);

            case "not":
                return(new NotFilter(FromXml(xmlNode.FirstChild)));

            case "id":
                var idFilter = new IdFilter();
                foreach (string id in xmlNode.InnerText.Split(COMMA))
                {
                    idFilter.Add(int.Parse(id));
                }
                return(idFilter);

            case "tests":
                var testFilter = new SimpleNameFilter();
                foreach (XmlNode childNode in xmlNode.SelectNodes("test"))
                {
                    testFilter.Add(childNode.InnerText);
                }
                return(testFilter);

            case "cat":
                var catFilter = new CategoryFilter();
                foreach (string cat in xmlNode.InnerText.Split(COMMA))
                {
                    catFilter.AddCategory(cat);
                }
                return(catFilter);

            default:
                throw new ArgumentException("Invalid filter element: " + xmlNode.Name, "xmlNode");
            }
        }