Example #1
0
        public void ExecuteTest()
        {
            string expectedMessage = "#Test Message123";

            WriteConsole wc = new WriteConsole();

            wc.Message    = expectedMessage;
            wc.AddNewline = true;

            StringWriter sw = new StringWriter();

            System.Console.SetOut(sw);

            wc.Execute();

            Assert.AreEqual(expectedMessage + Environment.NewLine, sw.ToString());


            // cleanup
            StreamWriter standardOutput = new StreamWriter(System.Console.OpenStandardOutput());

            standardOutput.AutoFlush = true;

            System.Console.SetOut(standardOutput);
        }