public void TestIlligalCommand() { using (StringWriter strWriter = new StringWriter()) { Console.SetOut(strWriter); GameMessages.IlligalCommand(); string expected = string.Format("Illegal command!{0}", Environment.NewLine); Assert.AreEqual(expected, strWriter.ToString()); } }