public void Should_Write_Error_Log_Messages_Written_With_A_Lower_Log_Level_Than_Warning(LogLevel logLevel) { // Given var console = FakeConsole.CreateAnsiConsole(); var log = new CakeBuildLog(console, Verbosity.Diagnostic); // When log.Write(Verbosity.Diagnostic, logLevel, "Hello World"); // Then Assert.Single(console.ErrorMessages); }
public void Should_Write_Log_Messages_Written_With_A_Higher_Verbosity_Than_Allowed(Verbosity logVerbosity, Verbosity messageVerbosity) { // Given var console = FakeConsole.CreateAnsiConsole(); var log = new CakeBuildLog(console, logVerbosity); // When log.Write(messageVerbosity, LogLevel.Information, "Hello World"); // Then Assert.Single(console.Messages); }
public void Should_Not_Colorize_A_Log_Message_Containg_A_Single_Token() { // Given var console = FakeConsole.CreateAnsiConsole(); var log = new CakeBuildLog(console, Verbosity.Diagnostic); // When log.Write(Verbosity.Diagnostic, LogLevel.Information, "{0}", "Hello World"); // Then Assert.Single(console.Messages); Assert.Equal("Hello World", console.Messages[0]); }
public void Should_Colorize_Error_Tokens_Correctly(LogLevel level, string expected) { // Given var console = FakeConsole.CreateAnsiConsole(); var log = new CakeBuildLog(console, Verbosity.Diagnostic); // When log.Write(Verbosity.Diagnostic, level, "Hello, {0}", "World"); // Then Assert.Single(console.ErrorMessages); Assert.Equal(expected, console.ErrorMessages[0]); }
public void Should_Output_Escaped_Tokens_Correctly(bool ansi, string expected) { // Given var message = "Executing: if ($LASTEXITCODE -gt 0) {{ throw \"script failed with exit code $LASTEXITCODE\" }}"; var console = ansi ? FakeConsole.CreateAnsiConsole() : new FakeConsole() { OutputConsoleColor = true }; var log = new CakeBuildLog(console, Verbosity.Diagnostic); // When log.Debug(Verbosity.Normal, message); // Then Assert.Single(console.Messages); Assert.Equal(expected, console.Messages[0]); }