Paradox Game Engine  v1.0.0 beta06
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros Pages
NUnitOutputTextWriter.cs
Go to the documentation of this file.
1 // Copyright (c) 2014 Silicon Studio Corp. (http://siliconstudio.co.jp)
2 // This file is distributed under Apache 2.0 License. See LICENSE.md for details.
3 //
4 // NUnitOutputTextWriter.cs
5 //
6 // Authors:
7 // Sebastien Pouliot <sebastien@xamarin.com>
8 //
9 // Copyright 2013 Xamarin Inc.
10 //
11 // Licensed under the Apache License, Version 2.0 (the "License");
12 // you may not use this file except in compliance with the License.
13 // You may obtain a copy of the License at
14 //
15 // http://www.apache.org/licenses/LICENSE-2.0
16 //
17 // Unless required by applicable law or agreed to in writing, software
18 // distributed under the License is distributed on an "AS IS" BASIS,
19 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20 // See the License for the specific language governing permissions and
21 // limitations under the License.
22 //
23 
24 using System;
25 using System.IO;
26 using System.Text;
27 
28 using NUnitLite.Runner;
29 using MonoTouch.NUnit.UI;
30 
31 namespace MonoTouch.NUnit {
32 
34 
35  bool real_time_reporting;
36 
37  public NUnitOutputTextWriter (TouchRunner runner, TextWriter baseWriter, OutputWriter xmlWriter)
38  {
39  Runner = runner;
40  BaseWriter = baseWriter ?? Console.Out;
41  XmlOutputWriter = xmlWriter;
42  // do not send real-time test results on the writer sif XML reports are enabled
43  real_time_reporting = (xmlWriter == null);
44  }
45 
46  public override Encoding Encoding {
47  get { return Encoding.UTF8; }
48  }
49 
50  public TextWriter BaseWriter { get; private set; }
51 
52  public TouchRunner Runner { get; private set; }
53 
54  public OutputWriter XmlOutputWriter { get; private set; }
55 
56  public override void Write (char value)
57  {
58  if (real_time_reporting)
59  BaseWriter.Write (value);
60  }
61 
62  public override void Write (string value)
63  {
64  if (real_time_reporting)
65  BaseWriter.Write (value);
66  }
67 
68  public override void Close ()
69  {
70  if (XmlOutputWriter != null) {
71  // now we want the XML report to write
72  real_time_reporting = true;
73  XmlOutputWriter.WriteResultFile (Runner.Result, BaseWriter);
74  real_time_reporting = false;
75  }
76  base.Close ();
77  }
78  }
79 }
NUnitOutputTextWriter(TouchRunner runner, TextWriter baseWriter, OutputWriter xmlWriter)
System.Text.Encoding Encoding