예제 #1
0
 /// <summary>
 /// Flushes any internal buffers. Also closes <see cref="BaseWriter"/> if <see cref="OwnsWriter"/> is true.
 /// </summary>
 public void Close()
 {
     FlushLine();
     if (OwnsWriter)
     {
         BaseWriter.Close();
     }
 }
예제 #2
0
        public override void Close()
        {
            if (XmlOutputWriter != null)
            {
                // now we want the XML report to write
                real_time_reporting = true;
                // write to a temporary string, because NUnit2XmlOutputWriter.WriteResultFile closes the stream,
                // and we need to write more things to it.
                var wrapped = mode == XmlMode.Wrapped;

                if (!wrapped)
                {
                    XmlOutputWriter.WriteResultFile(Runner.Result, BaseWriter);
                    if (extra_data.Length > 0)
                    {
                        BaseWriter.Write("<!--");
                        extra_data.Replace("--", "- - ");
                        BaseWriter.Write(extra_data);
                        BaseWriter.Write(" -->");
                    }
                }
                else
                {
                    BaseWriter.WriteLine("<TouchUnitTestRun>");
                    BaseWriter.WriteLine("<NUnitOutput>");

                    using (var textWriter = new StringWriter()) {
                        XmlOutputWriter.WriteResultFile(Runner.Result, textWriter);
                        var str = textWriter.ToString();
                        // Remove any xml declarations, since we're embedding this inside a different xml document.
                        if (str.StartsWith("<?xml", StringComparison.Ordinal))
                        {
                            var closing = str.IndexOf('>');
                            if (closing > 0)
                            {
                                str = str.Substring(closing + 1);
                            }
                        }
                        BaseWriter.WriteLine(str);
                    }
                    BaseWriter.WriteLine("</NUnitOutput>");
                    if (extra_data.Length > 0)
                    {
                        BaseWriter.Write("<TouchUnitExtraData><![CDATA[");
                        BaseWriter.Write(extra_data);
                        BaseWriter.WriteLine("]]>");
                        BaseWriter.WriteLine("</TouchUnitExtraData>");
                    }
                    BaseWriter.WriteLine("</TouchUnitTestRun>");
                }
                BaseWriter.WriteLine("<!-- the end -->");
                BaseWriter.Close();
                real_time_reporting = false;
            }
            base.Close();
        }