Example #1
0
        public void ToXml_WithClassFailure()
        {
            Exception ex;

            try
            {
                throw new InvalidOperationException("message");
            }
            catch (Exception e)
            {
                ex = e;
            }

            XmlDocument doc = new XmlDocument();
            doc.LoadXml("<foo/>");
            XmlNode parentNode = doc.ChildNodes[0];
            ClassResult classResult = new ClassResult(typeof(object));
            classResult.SetException(ex);

            XmlNode resultNode = classResult.ToXml(parentNode);

            Assert.Equal("class", resultNode.Name);
            Assert.Equal(classResult.FullyQualifiedName, resultNode.Attributes["name"].Value);
            Assert.Equal("0.000", resultNode.Attributes["time"].Value);
            Assert.Equal("1", resultNode.Attributes["total"].Value);
            Assert.Equal("0", resultNode.Attributes["passed"].Value);
            Assert.Equal("1", resultNode.Attributes["failed"].Value);
            Assert.Equal("0", resultNode.Attributes["skipped"].Value);
            XmlNode failureNode = resultNode.SelectSingleNode("failure");
            Assert.Equal(ex.GetType().FullName, failureNode.Attributes["exception-type"].Value);
            Assert.Equal(ExceptionUtility.GetMessage(ex), failureNode.SelectSingleNode("message").InnerText);
            Assert.Equal(ExceptionUtility.GetStackTrace(ex), failureNode.SelectSingleNode("stack-trace").InnerText);
        }
Example #2
0
        public void ToXmlTwiceDoesNotDoubleCounts()
        {
            XmlDocument doc = new XmlDocument();
            doc.LoadXml("<foo/>");
            XmlNode parentNode = doc.ChildNodes[0];
            ClassResult classResult = new ClassResult(typeof(object));
            PassedResult passedResult = new PassedResult("foo", "bar", null, null);
            passedResult.ExecutionTime = 1.1;
            FailedResult failedResult = new FailedResult("foo", "bar", null, null, "extype", "message", "stack");
            failedResult.ExecutionTime = 2.2;
            SkipResult skipResult = new SkipResult("foo", "bar", null, null, "reason");
            classResult.Add(passedResult);
            classResult.Add(failedResult);
            classResult.Add(skipResult);

            XmlNode resultNode1 = classResult.ToXml(parentNode);
            XmlNode resultNode2 = classResult.ToXml(parentNode);

            Assert.Equal(resultNode1.Attributes["time"].Value, resultNode2.Attributes["time"].Value);
            Assert.Equal(resultNode1.Attributes["total"].Value, resultNode2.Attributes["total"].Value);
            Assert.Equal(resultNode1.Attributes["passed"].Value, resultNode2.Attributes["passed"].Value);
            Assert.Equal(resultNode1.Attributes["failed"].Value, resultNode2.Attributes["failed"].Value);
            Assert.Equal(resultNode1.Attributes["skipped"].Value, resultNode2.Attributes["skipped"].Value);
            Assert.Equal(resultNode1.SelectNodes("test").Count, resultNode2.SelectNodes("test").Count);
        }
Example #3
0
        public void ToXml()
        {
            XmlDocument doc = new XmlDocument();
            doc.LoadXml("<foo/>");
            XmlNode parentNode = doc.ChildNodes[0];
            ClassResult classResult = new ClassResult(typeof(object));

            XmlNode resultNode = classResult.ToXml(parentNode);

            Assert.Equal("class", resultNode.Name);
            Assert.Equal(classResult.FullyQualifiedName, resultNode.Attributes["name"].Value);
            Assert.Equal("0.000", resultNode.Attributes["time"].Value);
            Assert.Equal("0", resultNode.Attributes["total"].Value);
            Assert.Equal("0", resultNode.Attributes["passed"].Value);
            Assert.Equal("0", resultNode.Attributes["failed"].Value);
            Assert.Equal("0", resultNode.Attributes["skipped"].Value);
        }