public void TestConstructor()
        {
            ConsoleColor expected = ColorConsole.GetColor(ColorStyle.Error);

            using (new ColorConsole(ColorStyle.Error))
            {
                Assert.That(Console.ForegroundColor, Is.EqualTo(expected));
            }
            Assert.That(Console.ForegroundColor, Is.Not.EqualTo(expected));
        }
Beispiel #2
0
        void WriteNotification(string label, ConsoleColor labelColor, string logLevel, string source, string message)
        {
            var level = LogLevel.FromString(logLevel);

            if (!string.IsNullOrWhiteSpace(source))
            {
                var n = source.LastIndexOf('.');
                if (n < source.Length - 1)
                {
                    source = source.Substring(n + 1);
                }
                source = string.Concat("%*[", source, "]%* ");
            }
            if (_app.DisplayServerNotifications)
            {
                ColorConsole.WriteLinesLabelled(label, label.Length, labelColor, ColorConsole.GetColor(level), source + message);
            }
        }
Beispiel #3
0
        public void SetUp()
        {
            // Find a test color that is different than the console color
            if (Console.ForegroundColor != ColorConsole.GetColor(ColorStyle.Error))
            {
                _testStyle = ColorStyle.Error;
            }
            else if (Console.ForegroundColor != ColorConsole.GetColor(ColorStyle.Pass))
            {
                _testStyle = ColorStyle.Pass;
            }
            else
            {
                Assert.Inconclusive("Could not find a color to test with");
            }

            // Set to an unknown, unlikely color so that we can test for change
            Console.ForegroundColor = ConsoleColor.Magenta;

            Assume.That(Console.ForegroundColor, Is.EqualTo(ConsoleColor.Magenta), "Color tests cannot be run because the current console does not support color");
        }
Beispiel #4
0
 public void TestGetColor(ColorStyle style, ConsoleColor expected)
 {
     Assert.That(ColorConsole.GetColor(style), Is.EqualTo(expected));
 }