nunit-core team mailing list archive
-
nunit-core team
-
Mailing list archive
-
Message #02011
[Bug 797150] Re: Console.Clear(); throw System.IO.Exception
Continuing above comment...
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()
{
Console.WriteLine("Starting...");
var savedOut = Console.Out;
var sw = new StringWriter();
Console.WriteLine("Setting Console to StringWriter");
Console.SetOut(sw);
Console.WriteLine("This should not appear");
Console.Clear();
Console.WriteLine("Neither should this");
Console.SetOut(savedOut);
Console.WriteLine("Exiting...");
}
Results in a cleared screan with "Exiting..." displayed at the top.
Since Console.Clear() is being applied to the real console, the example
test runs successfully under nunit-console, but causes an error under
the nunit gui, which doesn't have a real console.
An interesting effect, but not an NUnit bug.
Charlie
** Changed in: nunitv2
Milestone: 2.6.0 => None
** Changed in: nunitv2
Assignee: Charlie Poole (charlie.poole) => (unassigned)
** Changed in: nunitv2
Status: New => Invalid
--
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:
Invalid
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