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)); }
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); } }
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"); }
public void TestGetColor(ColorStyle style, ConsoleColor expected) { Assert.That(ColorConsole.GetColor(style), Is.EqualTo(expected)); }