Наследование: ValueMatchFilter
Пример #1
0
        public void Match_SingleId()
        {
            var filter = new IdFilter(_dummyFixture.Id);

            Assert.That(filter.Match(_dummyFixture));
            Assert.False(filter.Match(_anotherFixture));
        }
Пример #2
0
        public void Match_SingleId()
        {
            var filter = new IdFilter(_dummyFixture.Id);

            Assert.That(filter.Match(_dummyFixture));
            Assert.False(filter.Match(_anotherFixture));
        }
Пример #3
0
        public void Match_MultipleIds()
        {
            var filter = new IdFilter(new string[] { _dummyFixture.Id, _anotherFixture.Id });

            Assert.That(filter.Match(_dummyFixture));
            Assert.That(filter.Match(_anotherFixture));

            Assert.False(filter.Match(_yetAnotherFixture));
        }
Пример #4
0
        public void Match_MultipleIds()
        {
            var filter = new IdFilter(new string[] { _dummyFixture.Id, _anotherFixture.Id });

            Assert.That(filter.Match(_dummyFixture));
            Assert.That(filter.Match(_anotherFixture));

            Assert.False(filter.Match(_yetAnotherFixture));
        }
Пример #5
0
        public void ExplicitMatch_SingleId()
        {
            var filter = new IdFilter(_dummyFixture.Id);

            Assert.That(filter.IsExplicitMatch(_topLevelSuite));
            Assert.That(filter.IsExplicitMatch(_dummyFixture));
            Assert.False(filter.IsExplicitMatch(_dummyFixture.Tests[0]));

            Assert.False(filter.IsExplicitMatch(_anotherFixture));
        }
Пример #6
0
        public void Pass_SingleId()
        {
            var filter = new IdFilter(_dummyFixture.Id);

            Assert.That(filter.Pass(_topLevelSuite));
            Assert.That(filter.Pass(_dummyFixture));
            Assert.That(filter.Pass(_dummyFixture.Tests[0]));

            Assert.False(filter.Pass(_anotherFixture));
        }
Пример #7
0
        public void Pass_SingleId()
        {
            var filter = new IdFilter(_dummyFixture.Id);

            Assert.That(filter.Pass(_topLevelSuite));
            Assert.That(filter.Pass(_dummyFixture));
            Assert.That(filter.Pass(_dummyFixture.Tests[0]));

            Assert.False(filter.Pass(_anotherFixture));
        }
Пример #8
0
        public void ExplicitMatch_SingleId()
        {
            var filter = new IdFilter(_dummyFixture.Id);

            Assert.That(filter.IsExplicitMatch(_topLevelSuite));
            Assert.That(filter.IsExplicitMatch(_dummyFixture));
            Assert.False(filter.IsExplicitMatch(_dummyFixture.Tests[0]));

            Assert.False(filter.IsExplicitMatch(_anotherFixture));
        }
Пример #9
0
        public void AddIds()
        {
            var filter = new IdFilter();

            filter.Add(_dummyFixture.Id);
            filter.Add(_anotherFixture.Id);

            Assert.That(filter.Match(_dummyFixture));
            Assert.That(filter.Match(_anotherFixture));
            Assert.False(filter.Match(_yetAnotherFixture));
        }
Пример #10
0
        public void ExplicitMatch_MultipleIds()
        {
            var filter = new IdFilter(new string[] { _dummyFixture.Id, _anotherFixture.Id });

            Assert.That(filter.IsExplicitMatch(_topLevelSuite));
            Assert.That(filter.IsExplicitMatch(_dummyFixture));
            Assert.False(filter.IsExplicitMatch(_dummyFixture.Tests[0]));
            Assert.True(filter.IsExplicitMatch(_anotherFixture));
            Assert.False(filter.IsExplicitMatch(_anotherFixture.Tests[0]));

            Assert.False(filter.IsExplicitMatch(_yetAnotherFixture));
        }
Пример #11
0
        public void ExplicitMatch_MultipleIds()
        {
            var filter = new IdFilter(new string[] { _dummyFixture.Id, _anotherFixture.Id });

            Assert.That(filter.IsExplicitMatch(_topLevelSuite));
            Assert.That(filter.IsExplicitMatch(_dummyFixture));
            Assert.False(filter.IsExplicitMatch(_dummyFixture.Tests[0]));
            Assert.True(filter.IsExplicitMatch(_anotherFixture));
            Assert.False(filter.IsExplicitMatch(_anotherFixture.Tests[0]));

            Assert.False(filter.IsExplicitMatch(_yetAnotherFixture));
        }
Пример #12
0
        public void IdFilter_ConstructWithMultipleIds()
        {
            var filter = new IdFilter(new string[] { dummyFixture.Id, anotherFixture.Id });

            Assert.False(filter.IsEmpty);
            Assert.That(filter.Match(dummyFixture));
            Assert.That(filter.Match(anotherFixture));
            Assert.False(filter.Match(yetAnotherFixture));
        }
Пример #13
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");
            }
        }
Пример #14
0
        public void AddIds()
        {
            var filter = new IdFilter();
            filter.Add(_dummyFixture.Id);
            filter.Add(_anotherFixture.Id);

            Assert.That(filter.Match(_dummyFixture));
            Assert.That(filter.Match(_anotherFixture));
            Assert.False(filter.Match(_yetAnotherFixture));
        }
Пример #15
0
        public void IsNotEmpty()
        {
            var filter = new IdFilter(_dummyFixture.Id);

            Assert.False(filter.IsEmpty);
        }
Пример #16
0
        public void IdFilter_ToXml()
        {
            TestFilter filter = new IdFilter("ID-123");

            Assert.That(filter.ToXml(false).OuterXml, Is.EqualTo("<id>ID-123</id>"));
        }
Пример #17
0
        public void IdFilter_ConstructWithSingleId()
        {
            var filter = new IdFilter(dummyFixture.Id);

            Assert.False(filter.IsEmpty);
            Assert.That(filter.Match(dummyFixture));
            Assert.False(filter.Match(anotherFixture));
        }
Пример #18
0
        public void IsNotEmpty()
        {
            var filter = new IdFilter(_dummyFixture.Id);

            Assert.False(filter.IsEmpty);
        }
Пример #19
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));
        }
Пример #20
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");
            }
        }
Пример #21
0
 public void IdFilter_ToXml()
 {
     TestFilter filter = new IdFilter("ID-123");
     Assert.That(filter.ToXml(false).OuterXml, Is.EqualTo("<id>ID-123</id>"));
 }