예제 #1
0
        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);
        }
예제 #2
0
        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);
        }
예제 #3
0
        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);
        }
예제 #4
0
        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);
        }
예제 #5
0
        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);
        }