Esempio n. 1
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");
            }
        }
Esempio n. 2
0
        public void TestResultXmlNodeBasicInfo()
        {
            TNode testNode = testResult.ToXml(true);

            Assert.NotNull(testNode.Attributes["id"]);
            Assert.AreEqual("test-case", testNode.Name);
            Assert.AreEqual("DummyMethod", testNode.Attributes["name"]);
            Assert.AreEqual("NUnit.Framework.Internal.TestResultTests+DummySuite.DummyMethod", testNode.Attributes["fullname"]);

            Assert.AreEqual("Test description", testNode.SelectSingleNode("properties/property[@name='Description']").Attributes["value"]);
            Assert.AreEqual("Dubious", testNode.SelectSingleNode("properties/property[@name='Category']").Attributes["value"]);
            Assert.AreEqual("low", testNode.SelectSingleNode("properties/property[@name='Priority']").Attributes["value"]);

            Assert.AreEqual(0, testNode.SelectNodes("test-case").Count);
        }
Esempio n. 3
0
        public void TestResultXml_AssertionResults()
        {
            TNode assertionResults = _testResult.ToXml(true).SelectSingleNode("assertions");

            if (_expectedAssertions.Count == 0)
            {
                Assert.Null(assertionResults, "No <assertions> element expected");
                return;
            }

            Assert.NotNull(assertionResults, "Expected <assertions> element");

            var assertionNodes = assertionResults.SelectNodes("assertion");

            Assert.NotNull(assertionNodes, "Empty <assertions> element");

            Assert.AreEqual(_expectedAssertions.Count, assertionNodes.Count, "Wrong number of <assertion> elements");

            for (int index = 0; index < _expectedAssertions.Count; index++)
            {
                AssertionResult expectedAssertion = _expectedAssertions[index];
                TNode           assertionNode     = assertionNodes[index];

                Assert.AreEqual(expectedAssertion.Status.ToString(), assertionNode.Attributes["result"]);

                if (expectedAssertion.Message != null)
                {
                    TNode messageNode = assertionNode.SelectSingleNode("message");
                    Assert.NotNull(messageNode);
                    Assert.That(messageNode.Value, Is.EqualTo(expectedAssertion.Message));
                }

                if (expectedAssertion.StackTrace != null)
                {
                    TNode stackNode = assertionNode.SelectSingleNode("stack-trace");
                    Assert.NotNull(stackNode);
                    Assert.That(stackNode.Value, Is.EqualTo(expectedAssertion.StackTrace));
                }
            }
        }
Esempio n. 4
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");
            }
        }
Esempio n. 5
0
        public void SuiteResultXml_Children()
        {
            TNode suiteNode = _suiteResult.ToXml(true);

            Assert.AreEqual(_suiteResult.Children.Count(), suiteNode.SelectNodes("test-case").Count);
        }
Esempio n. 6
0
        public void TestResultXml_NoChildren()
        {
            TNode testNode = _testResult.ToXml(true);

            Assert.AreEqual(0, testNode.SelectNodes("test-case").Count);
        }
Esempio n. 7
0
        public void SuiteResultXmlNodeHasFourChildTests()
        {
            TNode suiteNode = suiteResult.ToXml(true);

            Assert.AreEqual(4, suiteNode.SelectNodes("test-case").Count);
        }