示例#1
0
 private static void Log_OnErrorWriteLine(string obj)
 {
     using (ConsoleColorResetter reset = new ConsoleColorResetter(ConsoleColor.Red, null))
     {
         Console.Error.Write(obj);
     }
 }
示例#2
0
 private static void Log_OnWarningWriteLine(string obj)
 {
     using (ConsoleColorResetter reset = new ConsoleColorResetter(ConsoleColor.Yellow, null))
     {
         Console.Write(obj);
     }
 }
示例#3
0
        public void ForegroundOnlyTest()
        {
            const ConsoleColor newFgColor = ConsoleColor.DarkGreen;

            using (ConsoleColorResetter uut = new ConsoleColorResetter(newFgColor, null))
            {
                Assert.AreEqual(newFgColor, Console.ForegroundColor);
                Assert.AreEqual(originalBackground, Console.BackgroundColor);
            }

            // Should be restored after dispose is called.
            Assert.AreEqual(originalForeground, Console.ForegroundColor);
            Assert.AreEqual(originalBackground, Console.BackgroundColor);
        }