/// <summary>
        /// Returns the outcome of a given test based on its xml element.
        /// </summary>
        internal static string GetTestMessage(XElement testElement)
        {
            var message = new StringBuilder {
            };

            // If this is a failed section, print a header.
            if (testElement.Name == "Section" && GetTestOutcome(testElement) != TestOutcome.Passed)
            {
                message.AppendFormat("Section \"{0}\":\n", testElement.Attribute("name").Value);
            }

            // First, recurse over all section elements.
            foreach (var sectionNode in testElement.Elements("Section"))
            {
                message.AppendLine(GetTestMessage(sectionNode));
            }

            // Print failed expressions...
            foreach (var expressionElement in testElement.Elements("Expression"))
            {
                if (expressionElement.Attribute("success").Value.Trim().ToLower() == "false")
                {
                    var expr = new FailureExpression(expressionElement);
                    message.AppendLine(expr.ToString());
                }
            }

            // Print unexpected exceptions...
            foreach (var exceptionElement in testElement.Elements("Exception"))
            {
                var location = SourceLocation.FromXElement(exceptionElement);
                message.AppendFormat("Unexpected exception at {0} with message:\n\t{1}\n", location, exceptionElement.Value.Trim());
                message.AppendLine();
            }

            // Print info...
            foreach (var infoElement in testElement.Elements("Info"))
            {
                if (infoElement.Value != null)
                {
                    message.AppendFormat("Info: {0}\n", infoElement.Value.Trim());
                    message.AppendLine();
                }
            }

            // Print warnings...
            foreach (var warningElement in testElement.Elements("Warning"))
            {
                if (warningElement.Value != null)
                {
                    message.AppendFormat("Warning: {0}\n", warningElement.Value.Trim());
                    message.AppendLine();
                }
            }

            // Print failures...
            foreach (var failureElement in testElement.Elements("Failure"))
            {
                if (failureElement.Value != null && failureElement.Value != "")
                {
                    message.AppendFormat("Explictly failed with message: {0}\n", failureElement.Value.Trim());
                    message.AppendLine();
                }
                else
                {
                    message.AppendLine("Explictly failed.\n");
                }
            }


            // Print fatal error conditions...
            foreach (var fatalElement in testElement.Elements("FatalErrorCondition"))
            {
                var location = SourceLocation.FromXElement(fatalElement);
                if (fatalElement.Value != null && fatalElement.Value.Trim() != "")
                {
                    message.AppendFormat("Fatal Error at {0} with message:\n\t{1}\n", location, fatalElement.Value.Trim());
                    message.AppendLine();
                }
                else
                {
                    message.AppendFormat("Fatal Error at {0}\n", location);
                    message.AppendLine();
                }
            }

            return(message.ToString());
        }
        /// <summary>
        /// Returns the outcome of a given test based on its xml element.
        /// </summary>
        internal static string GetTestMessage(XElement testElement)
        {
            var message = new StringBuilder { };

            // If this is a failed section, print a header.
            // We write the sections as the stack trace
            /*if (testElement.Name == "Section" && GetTestOutcome(testElement) != TestOutcome.Passed)
            {
                message.AppendLine(SourceLocation.FromXElement(testElement).ToStacktraceString(testElement.Attribute("name").Value));
            }*/

            // First, recurse over all section elements.
            foreach (var sectionNode in testElement.Elements("Section"))
            {
                message.Append(GetTestMessage(sectionNode));
            }

            // Print failed expressions...
            foreach (var expressionElement in testElement.Elements("Expression"))
            {
                if (expressionElement.Attribute("success").Value.Trim().ToLower() == "false")
                {
                    var expr = new FailureExpression(expressionElement);
                    message.AppendLine(expr.ToString());
                }
            }

            // Print unexpected exceptions...
            foreach (var exceptionElement in testElement.Elements("Exception"))
            {
                var location = SourceLocation.FromXElement(exceptionElement);
                message.AppendFormat("Unexpected exception at {0} with message:\n\t{1}\n", location, exceptionElement.Value.Trim());
                message.AppendLine();
            }

            // Print info...
            foreach (var infoElement in testElement.Elements("Info"))
            {
                if (infoElement.Value != null)
                {
                    message.AppendFormat("Info: {0}\n", infoElement.Value.Trim());
                    message.AppendLine();
                }
            }

            // Print warnings...
            foreach (var warningElement in testElement.Elements("Warning"))
            {
                if (warningElement.Value != null)
                {
                    message.AppendFormat("Warning: {0}\n", warningElement.Value.Trim());
                    message.AppendLine();
                }
            }

            // Print failures...
            foreach (var failureElement in testElement.Elements("Failure"))
            {
                if (failureElement.Value != null && failureElement.Value != "")
                {
                    message.AppendFormat("Explictly failed with message: {0}\n", failureElement.Value.Trim());
                    message.AppendLine();
                }
                else
                {
                    message.AppendLine("Explictly failed.\n");
                }
            }


            // Print fatal error conditions...
            foreach (var fatalElement in testElement.Elements("FatalErrorCondition"))
            {
                var location = SourceLocation.FromXElement(fatalElement);
                if (fatalElement.Value != null && fatalElement.Value.Trim() != "")
                {
                    message.AppendFormat("Fatal Error at {0} with message:\n\t{1}\n", location, fatalElement.Value.Trim());
                    message.AppendLine();
                }
                else
                {
                    message.AppendFormat("Fatal Error at {0}\n", location);
                    message.AppendLine();
                }
            }

            return message.ToString();
        }