public void CallingFlush_ClearsData_FromOutputBuilder() { // Arrange var systemConsole = new TestAnsiSystemConsole(); var console = new AnsiLogConsole(systemConsole); var message = "Request received"; var expectedMessage = message + Environment.NewLine; // Act console.WriteLine(message, background: null, foreground: null); console.Flush(); console.WriteLine(message, background: null, foreground: null); console.Flush(); // Assert Assert.Equal(expectedMessage, systemConsole.Message); }
public void WritesMessage_WithoutEscapeCodes_AndNoForegroundOrBackgroundColorsSpecified() { // Arrange var systemConsole = new TestAnsiSystemConsole(); var console = new AnsiLogConsole(systemConsole); var message = "Request received"; var expectedMessage = message + Environment.NewLine; // Act console.WriteLine(message, background: null, foreground: null); console.Flush(); // Assert Assert.Equal(expectedMessage, systemConsole.Message); }
public void DoesNotAddNewLine() { // Arrange var systemConsole = new TestAnsiSystemConsole(); var console = new AnsiLogConsole(systemConsole); var message = "Request received"; var expectedMessage = message; // Act console.Write(message, background: null, foreground: null); console.Flush(); // Assert Assert.Equal(expectedMessage, systemConsole.Message); }
public void WritesMessage_WithForegroundEscapeCode_AndNoBackgroundColorSpecified() { // Arrange var systemConsole = new TestAnsiSystemConsole(); var console = new AnsiLogConsole(systemConsole); var message = "Request received"; var expectedMessage = GetForegroundColorEscapeCode(ConsoleColor.DarkGreen) + message + "\x1B[39m"; //resets foreground color // Act console.WriteLine(message, background: null, foreground: ConsoleColor.DarkGreen); console.Flush(); // Assert Assert.Equal(expectedMessage + Environment.NewLine, systemConsole.Message); }
public void WriteMessage_InOrder_WhenBothForegroundOrBackgroundColorsSpecified() { // Arrange var systemConsole = new TestAnsiSystemConsole(); var console = new AnsiLogConsole(systemConsole); var message = "Request received"; var expectedMessage = GetBackgroundColorEscapeCode(ConsoleColor.Red) + GetForegroundColorEscapeCode(ConsoleColor.DarkGreen) + "Request received" + "\x1B[39m" //resets foreground color + "\x1B[0m" //resets background color + Environment.NewLine; // Act console.WriteLine(message, background: ConsoleColor.Red, foreground: ConsoleColor.DarkGreen); console.Flush(); // Assert Assert.Equal(expectedMessage, systemConsole.Message); }