Comment 0 for bug 797150

Revision history for this message
Juan José Montes de Oca Arbós (juanjose-montesdeocaarbos) wrote :

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 Console and don't work at NUnit Console and Resharper 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();
        }
    }
}