Ejemplo n.º 1
0
 /// <summary>
 /// Adds an XML node
 /// </summary>
 /// <param name="parentNode">Parent node</param>
 /// <param name="recursive">True if recursive</param>
 /// <returns>The added XML node</returns>
 public override TNode AddToXml(TNode parentNode, bool recursive)
 {
     TNode result = parentNode.AddElement(ElementName, ExpectedValue);
     if (IsRegex)
         result.AddAttribute("re", "1");
     return result;
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Adds an XML node
        /// </summary>
        /// <param name="parentNode">Parent node</param>
        /// <param name="recursive">True if recursive</param>
        /// <returns>The added XML node</returns>
        public override TNode AddToXml(TNode parentNode, bool recursive)
        {
            TNode result = parentNode.AddElement(ElementName);

            if (recursive)
                foreach (ITestFilter filter in Filters)
                    filter.AddToXml(result, true);

            return result;
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Adds an XML node
        /// </summary>
        /// <param name="parentNode">Parent node</param>
        /// <param name="recursive">True if recursive</param>
        /// <returns>The added XML node</returns>
        public override TNode AddToXml(TNode parentNode, bool recursive)
        {
            TNode result = parentNode.AddElement(ElementName, ExpectedValue);

            if (IsRegex)
            {
                result.AddAttribute("re", "1");
            }
            return(result);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Adds an XML node
        /// </summary>
        /// <param name="parentNode">Parent node</param>
        /// <param name="recursive">True if recursive</param>
        /// <returns>The added XML node</returns>
        public override TNode AddToXml(TNode parentNode, bool recursive)
        {
            TNode result = parentNode.AddElement(ElementName);

            if (recursive)
            {
                foreach (ITestFilter filter in Filters)
                {
                    filter.AddToXml(result, true);
                }
            }

            return(result);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Adds a failure element to a node and returns it.
        /// </summary>
        /// <param name="targetNode">The target node.</param>
        /// <returns>The new failure element.</returns>
        private TNode AddFailureElement(TNode targetNode)
        {
            TNode failureNode = targetNode.AddElement("failure");

            if (Message != null)
            {
                failureNode.AddElementWithCDATA("message", Message);
            }

            if (StackTrace != null)
            {
                failureNode.AddElementWithCDATA("stack-trace", StackTrace);
            }

            return(failureNode);
        }
Ejemplo n.º 6
0
        private TNode AddAttachmentsElement(TNode targetNode)
        {
            TNode attachmentsNode = targetNode.AddElement("attachments");

            foreach (var attachment in _testAttachments)
            {
                var attachmentNode = attachmentsNode.AddElement("attachment");

                attachmentNode.AddElement("filePath", attachment.FilePath);

                if (attachment.Description != null)
                {
                    attachmentNode.AddElementWithCDATA("description", attachment.Description);
                }
            }

            return(attachmentsNode);
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Returns an XmlNode representing the PropertyBag after
        /// adding it as a child of the supplied parent node.
        /// </summary>
        /// <param name="parentNode">The parent node.</param>
        /// <param name="recursive">Not used</param>
        /// <returns></returns>
        public TNode AddToXml(TNode parentNode, bool recursive)
        {
            TNode properties = parentNode.AddElement("properties");

            foreach (string key in Keys)
            {
                foreach (object value in this[key])
                {
                    TNode prop = properties.AddElement("property");

                    // TODO: Format as string
                    prop.AddAttribute("name", key.ToString());
                    prop.AddAttribute("value", value.ToString());
                }
            }

            return(properties);
        }
Ejemplo n.º 8
0
        private TNode AddAssertionsElement(TNode targetNode)
        {
            var assertionsNode = targetNode.AddElement("assertions");

            foreach (var assertion in AssertionResults)
            {
                TNode assertionNode = assertionsNode.AddElement("assertion");
                assertionNode.AddAttribute("result", assertion.Status.ToString());
                if (assertion.Message != null)
                {
                    assertionNode.AddElementWithCDATA("message", assertion.Message);
                }
                if (assertion.StackTrace != null)
                {
                    assertionNode.AddElementWithCDATA("stack-trace", assertion.StackTrace);
                }
            }

            return(assertionsNode);
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Returns an XmlNode representing the current result after
        /// adding it as a child of the supplied parent node.
        /// </summary>
        /// <param name="parentNode">The parent node.</param>
        /// <param name="recursive">If true, descendant results are included</param>
        /// <returns></returns>
        public override TNode AddToXml(TNode parentNode, bool recursive)
        {
            TNode thisNode = parentNode.AddElement("test-suite");

            thisNode.AddAttribute("type", this.TestType);

            PopulateTestNode(thisNode, recursive);
            thisNode.AddAttribute("testcasecount", this.TestCaseCount.ToString());


            if (recursive)
            {
                foreach (Test test in this.Tests)
                {
                    test.AddToXml(thisNode, recursive);
                }
            }

            return(thisNode);
        }
Ejemplo n.º 10
0
        public virtual TNode AddToXml(TNode parentNode, bool recursive)
        {
            // A result node looks like a test node with extra info added
            TNode thisNode = Test.AddToXml(parentNode, false);

            thisNode.AddAttribute("result", ResultState.Status.ToString());
            if (ResultState.Label != string.Empty) // && ResultState.Label != ResultState.Status.ToString())
            {
                thisNode.AddAttribute("label", ResultState.Label);
            }
            if (ResultState.Site != FailureSite.Test)
            {
                thisNode.AddAttribute("site", ResultState.Site.ToString());
            }

            thisNode.AddAttribute("start-time", StartTime.ToString("o"));
            thisNode.AddAttribute("end-time", EndTime.ToString("o"));
            thisNode.AddAttribute("duration", Duration.ToString("0.000000", NumberFormatInfo.InvariantInfo));

            if (Test is TestSuite)
            {
                thisNode.AddAttribute("total", TotalCount.ToString());
                thisNode.AddAttribute("passed", PassCount.ToString());
                thisNode.AddAttribute("failed", FailCount.ToString());
                thisNode.AddAttribute("warnings", WarningCount.ToString());
                thisNode.AddAttribute("inconclusive", InconclusiveCount.ToString());
                thisNode.AddAttribute("skipped", SkipCount.ToString());
            }

            thisNode.AddAttribute("asserts", AssertCount.ToString());

            switch (ResultState.Status)
            {
            case TestStatus.Failed:
                AddFailureElement(thisNode);
                break;

            case TestStatus.Skipped:
            case TestStatus.Passed:
            case TestStatus.Inconclusive:
            case TestStatus.Warning:
                if (Message != null && Message.Trim().Length > 0)
                {
                    TNode reasonNode = thisNode.AddElement("reason");
                    reasonNode.AddElementWithCDATA("message", Message);
                }
                break;
            }

            if (Output.Length > 0)
            {
                AddOutputElement(thisNode);
            }

            if (AssertionResults.Count > 0)
            {
                AddAssertionsElement(thisNode);
            }

            if (_testAttachments.Count > 0)
            {
                AddAttachmentsElement(thisNode);
            }

            if (recursive && HasChildren)
            {
                foreach (var child in Children)
                {
                    child.AddToXml(thisNode, recursive);
                }
            }

            return(thisNode);
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Adds a failure element to a node and returns it.
        /// </summary>
        /// <param name="targetNode">The target node.</param>
        /// <returns>The new failure element.</returns>
        private TNode AddFailureElement(TNode targetNode)
        {
            TNode failureNode = targetNode.AddElement("failure");

            if (Message != null)
                failureNode.AddElementWithCDATA("message", Message);

            if (StackTrace != null)
                failureNode.AddElementWithCDATA("stack-trace", StackTrace);

            return failureNode;
        }
Ejemplo n.º 12
0
 /// <summary>
 /// Adds a reason element to a node and returns it.
 /// </summary>
 /// <param name="targetNode">The target node.</param>
 /// <returns>The new reason element.</returns>
 private TNode AddReasonElement(TNode targetNode)
 {
     TNode reasonNode = targetNode.AddElement("reason");
     return reasonNode.AddElementWithCDATA("message", Message);
 }
Ejemplo n.º 13
0
        /// <summary>
        /// Returns a TNode representing the current result after
        /// adding it as a child of the supplied parent node.
        /// </summary>
        /// <param name="parentNode">The parent node.</param>
        /// <param name="recursive">If true, descendant results are included</param>
        /// <returns></returns>
        public override TNode AddToXml(TNode parentNode, bool recursive)
        {
            TNode thisNode = parentNode.AddElement(XmlElementName);

            PopulateTestNode(thisNode, recursive);

            thisNode.AddAttribute("seed", this.Seed.ToString());

            return thisNode;
        }
Ejemplo n.º 14
0
 public override TNode AddToXml(TNode parentNode, bool recursive)
 {
     return(parentNode.AddElement("filter"));
 }
Ejemplo n.º 15
0
 public override TNode AddToXml(TNode parentNode, bool recursive)
 {
     return parentNode.AddElement("filter");
 }
Ejemplo n.º 16
0
        /// <summary>
        /// Adds a reason element to a node and returns it.
        /// </summary>
        /// <param name="targetNode">The target node.</param>
        /// <returns>The new reason element.</returns>
        private TNode AddReasonElement(TNode targetNode)
        {
            TNode reasonNode = targetNode.AddElement("reason");

            return(reasonNode.AddElementWithCDATA("message", Message));
        }
Ejemplo n.º 17
0
 /// <summary>
 /// Adds a reason element to a node and returns it.
 /// </summary>
 /// <param name="targetNode">The target node.</param>
 /// <returns>The new reason element.</returns>
 private TNode AddReasonElement(TNode targetNode)
 {
     TNode reasonNode = targetNode.AddElement("reason");
     return reasonNode.AddElement("message", EscapedMessage);
 }
Ejemplo n.º 18
0
 public TNode AddToXml(TNode parentNode, bool recursive)
 {
     parentNode.AddElement("test", fullName);
     return(parentNode);
 }
Ejemplo n.º 19
0
        /// <summary>
        /// Returns an XmlNode representing the current result after
        /// adding it as a child of the supplied parent node.
        /// </summary>
        /// <param name="parentNode">The parent node.</param>
        /// <param name="recursive">If true, descendant results are included</param>
        /// <returns></returns>
        public override TNode AddToXml(TNode parentNode, bool recursive)
        {
            TNode thisNode = parentNode.AddElement("test-suite");
            thisNode.AddAttribute("type", this.TestType);

            PopulateTestNode(thisNode, recursive);
            thisNode.AddAttribute("testcasecount", this.TestCaseCount.ToString());


            if (recursive)
                foreach (Test test in this.Tests)
                    test.AddToXml(thisNode, recursive);

            return thisNode;
        }
Ejemplo n.º 20
0
 private TNode AddOutputElement(TNode targetNode)
 {
     return(targetNode.AddElement("output", Output));
 }
Ejemplo n.º 21
0
        /// <summary>
        /// Adds a reason element to a node and returns it.
        /// </summary>
        /// <param name="targetNode">The target node.</param>
        /// <returns>The new reason element.</returns>
        private TNode AddReasonElement(TNode targetNode)
        {
            TNode reasonNode = targetNode.AddElement("reason");

            return(reasonNode.AddElement("message", EscapedMessage));
        }
Ejemplo n.º 22
0
        ///// <summary>
        ///// Determine whether any descendant of the test matches the filter criteria.
        ///// </summary>
        ///// <param name="test">The test to be matched</param>
        ///// <returns>True if at least one descendant matches the filter criteria</returns>
        //protected override bool MatchDescendant(ITest test)
        //{
        //    if (!test.HasChildren || test.Tests == null || TopLevel && test.RunState == RunState.Explicit)
        //        return false;

        //    foreach (ITest child in test.Tests)
        //    {
        //        if (Match(child) || MatchDescendant(child))
        //            return true;
        //    }

        //    return false;
        //}	

        /// <summary>
        /// Adds an XML node
        /// </summary>
        /// <param name="parentNode">Parent node</param>
        /// <param name="recursive">True if recursive</param>
        /// <returns>The added XML node</returns>
        public override TNode AddToXml(TNode parentNode, bool recursive)
        {
            TNode result = parentNode.AddElement("not");
            if (recursive)
                BaseFilter.AddToXml(result, true);
            return result;
        }
Ejemplo n.º 23
0
 private TNode AddOutputElement(TNode targetNode)
 {
     return targetNode.AddElement("output", Output);
 }
Ejemplo n.º 24
0
 public TNode AddToXml(TNode parentNode, bool recursive)
 {
     return(parentNode.AddElement("synchronousOnly"));
 }
Ejemplo n.º 25
0
        /// <summary>
        /// Returns an XmlNode representing the PropertyBag after
        /// adding it as a child of the supplied parent node.
        /// </summary>
        /// <param name="parentNode">The parent node.</param>
        /// <param name="recursive">Not used</param>
        /// <returns></returns>
        public TNode AddToXml(TNode parentNode, bool recursive)
        {
            TNode properties = parentNode.AddElement("properties");

            foreach (string key in Keys)
            {
                foreach (object value in this[key])
                {
                    TNode prop = properties.AddElement("property");

                    // TODO: Format as string
                    prop.AddAttribute("name", key.ToString());
                    prop.AddAttribute("value", value.ToString());
                }
            }

            return properties;
        }
 public override TNode AddToXml(TNode parentNode, bool recursive)
 {
     return(parentNode.AddElement("class", expectedValue));
 }