← Back to team overview

nunit-core team mailing list archive

[Bug 797150] Re: Console.Clear(); throw System.IO.Exception

 

By experimenting, I ascertained that Console.Clear() always applies to
the real console, even when Console.SetOut has been called.

For example, in a console program, this  code

public static void Main()
{

}

-- 
You received this bug notification because you are a member of NUnit
Developers, which is subscribed to NUnit V2.
https://bugs.launchpad.net/bugs/797150

Title:
  Console.Clear(); throw System.IO.Exception

Status in NUnit V2 Test Framework:
  New

Bug description:
  When testing a console application and run the method Console.Clear(); NUnit's console generates the exception System.IO.Exception. This work at MonoDevelop Test GUI Console, NUnit Console no GUI and don't work at NUnit GUI Console and Resharper GUI Console.
  Code Example:

  using System;
  using System.IO;
  using NUnit.Framework;

  namespace NUnitConsoleBug
  {
      [TestFixture]
      public class NUnitConsole
      {
          [Test]
          public void TestConsoleWriteLine()
          {
              //This work!
              var sw = new StringWriter();
              Console.SetOut(sw);
              Console.WriteLine("Test WriteLine{0}", Environment.NewLine);
              Assert.IsTrue(sw.ToString().Contains(string.Format("Test WriteLine{0}", Environment.NewLine)));
              sw.Dispose();
          }

          [Test]
          public void TestConsoleClear()
          {
              //This dont work!
              var sw = new StringWriter();
              Console.SetOut(sw);
              Assert.DoesNotThrow(Console.Clear);
              sw.Dispose();
          }
      }
  }

To manage notifications about this bug go to:
https://bugs.launchpad.net/nunitv2/+bug/797150/+subscriptions


References