From 35e511238945fc4f8adbc8753ea339e00ce11b42 Mon Sep 17 00:00:00 2001 From: Jochen Wezel Date: Fri, 22 Jul 2022 10:33:48 +0200 Subject: [PATCH] fixed missing color settings after 9f9c7b460c3316246b7269252eed7aaf5545f8c7 --- Console/CompuMaster.Console.vbproj | 4 +- Console/Console.vb | 38 +++++++---- ConsoleTest/ConsoleLoggingTests.vb | 106 +++++++++++++++++++++++++++++ 3 files changed, 134 insertions(+), 14 deletions(-) diff --git a/Console/CompuMaster.Console.vbproj b/Console/CompuMaster.Console.vbproj index 7747240..189d7d6 100644 --- a/Console/CompuMaster.Console.vbproj +++ b/Console/CompuMaster.Console.vbproj @@ -7,8 +7,8 @@ CompuMaster.Console 2016-2017,2019,2021,2022 CompuMaster GmbH true - 2022.7.21.100 - 2022.7.22.100 + 2022.7.22.101 + 2022.7.22.101 Embed true Debug;Release;CI_CD diff --git a/Console/Console.vb b/Console/Console.vb index a69ea6a..9256afd 100644 --- a/Console/Console.vb +++ b/Console/Console.vb @@ -180,6 +180,13 @@ Namespace CompuMaster _WriteDual(text, html, False) End Sub + ''' + ''' Log message without output to console + ''' + Public Shared Sub LogLine() + _Write(System.Environment.NewLine, False) + End Sub + ''' ''' Log message without output to console ''' @@ -197,6 +204,13 @@ Namespace CompuMaster _Write(System.Environment.NewLine, False) End Sub + ''' + ''' Log message without output to console + ''' + Public Shared Sub LogLineDual() + _WriteDual(System.Environment.NewLine, "
", False) + End Sub + ''' ''' Log message without output to console ''' @@ -239,17 +253,17 @@ Namespace CompuMaster If text = System.Environment.NewLine Then _RawPlainTextLog.Append(System.Environment.NewLine) Else - If BackgroundColor <> SystemConsoleDefaultBackgroundColor Then + If BackgroundColor <> SystemConsoleDefaultBackgroundColor OrElse SystemColorsInLogs = SystemColorModesInLogs.AlwaysApplySystemColorInLog Then _RawPlainTextLog.Append("") End If - If ForegroundColor <> SystemConsoleDefaultForegroundColor Then + If ForegroundColor <> SystemConsoleDefaultForegroundColor OrElse SystemColorsInLogs = SystemColorModesInLogs.AlwaysApplySystemColorInLog Then _RawPlainTextLog.Append("") End If _RawPlainTextLog.Append(IndentText(text, Not IsNewOutputLineAtLog)) - If ForegroundColor <> SystemConsoleDefaultForegroundColor Then + If ForegroundColor <> SystemConsoleDefaultForegroundColor OrElse SystemColorsInLogs = SystemColorModesInLogs.AlwaysApplySystemColorInLog Then _RawPlainTextLog.Append("") End If - If BackgroundColor <> SystemConsoleDefaultBackgroundColor Then + If BackgroundColor <> SystemConsoleDefaultBackgroundColor OrElse SystemColorsInLogs = SystemColorModesInLogs.AlwaysApplySystemColorInLog Then _RawPlainTextLog.Append("") End If End If @@ -339,11 +353,11 @@ Namespace CompuMaster If BackgroundColor <> SystemConsoleDefaultBackgroundColor Then _HtmlLog.Append("") End If - If ForegroundColor <> SystemConsoleDefaultForegroundColor Then + If ForegroundColor <> SystemConsoleDefaultForegroundColor OrElse SystemColorsInLogs = SystemColorModesInLogs.AlwaysApplySystemColorInLog Then _HtmlLog.Append("") End If _HtmlLog.Append(TextAsHtml) - If ForegroundColor <> SystemConsoleDefaultForegroundColor Then + If ForegroundColor <> SystemConsoleDefaultForegroundColor OrElse SystemColorsInLogs = SystemColorModesInLogs.AlwaysApplySystemColorInLog Then _HtmlLog.Append("") End If If BackgroundColor <> SystemConsoleDefaultBackgroundColor Then @@ -471,17 +485,17 @@ Namespace CompuMaster If text.Length < 3 AndAlso text.ToString = System.Environment.NewLine Then _RawPlainTextLog.Append(System.Environment.NewLine) Else - If BackgroundColor <> SystemConsoleDefaultBackgroundColor Then + If BackgroundColor <> SystemConsoleDefaultBackgroundColor OrElse SystemColorsInLogs = SystemColorModesInLogs.AlwaysApplySystemColorInLog Then _RawPlainTextLog.Append("") End If - If ForegroundColor <> SystemConsoleDefaultForegroundColor Then + If ForegroundColor <> SystemConsoleDefaultForegroundColor OrElse SystemColorsInLogs = SystemColorModesInLogs.AlwaysApplySystemColorInLog Then _RawPlainTextLog.Append("") End If _RawPlainTextLog.Append(IndentText(text.ToString, Not IsNewOutputLineAtLog)) - If ForegroundColor <> SystemConsoleDefaultForegroundColor Then + If ForegroundColor <> SystemConsoleDefaultForegroundColor OrElse SystemColorsInLogs = SystemColorModesInLogs.AlwaysApplySystemColorInLog Then _RawPlainTextLog.Append("") End If - If BackgroundColor <> SystemConsoleDefaultBackgroundColor Then + If BackgroundColor <> SystemConsoleDefaultBackgroundColor OrElse SystemColorsInLogs = SystemColorModesInLogs.AlwaysApplySystemColorInLog Then _RawPlainTextLog.Append("") End If End If @@ -496,11 +510,11 @@ Namespace CompuMaster If BackgroundColor <> SystemConsoleDefaultBackgroundColor Then _HtmlLog.Append("") End If - If ForegroundColor <> SystemConsoleDefaultForegroundColor Then + If ForegroundColor <> SystemConsoleDefaultForegroundColor OrElse SystemColorsInLogs = SystemColorModesInLogs.AlwaysApplySystemColorInLog Then _HtmlLog.Append("") End If _HtmlLog.Append(TextAsHtml) - If ForegroundColor <> SystemConsoleDefaultForegroundColor Then + If ForegroundColor <> SystemConsoleDefaultForegroundColor OrElse SystemColorsInLogs = SystemColorModesInLogs.AlwaysApplySystemColorInLog Then _HtmlLog.Append("") End If If BackgroundColor <> SystemConsoleDefaultBackgroundColor Then diff --git a/ConsoleTest/ConsoleLoggingTests.vb b/ConsoleTest/ConsoleLoggingTests.vb index 9b3fc4a..f5c26d2 100644 --- a/ConsoleTest/ConsoleLoggingTests.vb +++ b/ConsoleTest/ConsoleLoggingTests.vb @@ -407,29 +407,135 @@ Namespace ConsoleTest Public Sub DualFeatureStringArgsCompletionTest() Dim Text As String = "Plain Text" Dim Html As String = "

HTML code

" + Dim ExpectedTextWithLineBreak As String = Text & System.Environment.NewLine + Dim ExpectedHtmlWithLineBreak As String = Html & "
" + CompuMaster.Console.Clear(True, True, True, True) + CompuMaster.Console.WriteLineDual() + Assert.AreEqual(System.Environment.NewLine, CompuMaster.Console.PlainTextLog.ToString) + Assert.AreEqual(System.Environment.NewLine, CompuMaster.Console.RawPlainTextLog.ToString) + Assert.AreEqual("
", CompuMaster.Console.HtmlLog.ToString) + + CompuMaster.Console.Clear(True, True, True, True) + CompuMaster.Console.LogLineDual() + Assert.AreEqual(System.Environment.NewLine, CompuMaster.Console.PlainTextLog.ToString) + Assert.AreEqual(System.Environment.NewLine, CompuMaster.Console.RawPlainTextLog.ToString) + Assert.AreEqual("
", CompuMaster.Console.HtmlLog.ToString) + + CompuMaster.Console.Clear(True, True, True, True) CompuMaster.Console.WriteDual(Text, Html) + Assert.AreEqual(Text, CompuMaster.Console.PlainTextLog.ToString) + Assert.AreEqual(Text, CompuMaster.Console.RawPlainTextLog.ToString) + Assert.AreEqual(Html, CompuMaster.Console.HtmlLog.ToString) + + CompuMaster.Console.Clear(True, True, True, True) CompuMaster.Console.WriteLineDual(Text, Html) + Assert.AreEqual(ExpectedTextWithLineBreak, CompuMaster.Console.PlainTextLog.ToString) + Assert.AreEqual(ExpectedTextWithLineBreak, CompuMaster.Console.RawPlainTextLog.ToString) + Assert.AreEqual(ExpectedHtmlWithLineBreak, CompuMaster.Console.HtmlLog.ToString) + + CompuMaster.Console.Clear(True, True, True, True) CompuMaster.Console.WarnDual(Text, Html) + Assert.AreEqual(Text, CompuMaster.Console.PlainTextLog.ToString) + Assert.AreEqual("" & Text & "", CompuMaster.Console.RawPlainTextLog.ToString) + Assert.AreEqual("" & Html & "", CompuMaster.Console.HtmlLog.ToString) + + CompuMaster.Console.Clear(True, True, True, True) CompuMaster.Console.WarnLineDual(Text, Html) + Assert.AreEqual(ExpectedTextWithLineBreak, CompuMaster.Console.PlainTextLog.ToString) + Assert.AreEqual("" & ExpectedTextWithLineBreak & "", CompuMaster.Console.RawPlainTextLog.ToString) + Assert.AreEqual("" & ExpectedHtmlWithLineBreak.ToString & "", CompuMaster.Console.HtmlLog.ToString) + + CompuMaster.Console.Clear(True, True, True, True) CompuMaster.Console.OkayDual(Text, Html) + Assert.AreEqual(Text, CompuMaster.Console.PlainTextLog.ToString) + Assert.AreEqual("" & Text & "", CompuMaster.Console.RawPlainTextLog.ToString) + Assert.AreEqual("" & Html.ToString & "", CompuMaster.Console.HtmlLog.ToString) + + CompuMaster.Console.Clear(True, True, True, True) CompuMaster.Console.OkayLineDual(Text, Html) + Assert.AreEqual(ExpectedTextWithLineBreak, CompuMaster.Console.PlainTextLog.ToString) + Assert.AreEqual("" & ExpectedTextWithLineBreak & "", CompuMaster.Console.RawPlainTextLog.ToString) + Assert.AreEqual("" & ExpectedHtmlWithLineBreak.ToString & "", CompuMaster.Console.HtmlLog.ToString) + + CompuMaster.Console.Clear(True, True, True, True) CompuMaster.Console.LogDual(Text, Html) + Assert.AreEqual(Text, CompuMaster.Console.PlainTextLog.ToString) + Assert.AreEqual(Text, CompuMaster.Console.RawPlainTextLog.ToString) + Assert.AreEqual(Html, CompuMaster.Console.HtmlLog.ToString) + + CompuMaster.Console.Clear(True, True, True, True) CompuMaster.Console.LogLineDual(Text, Html) + Assert.AreEqual(ExpectedTextWithLineBreak, CompuMaster.Console.PlainTextLog.ToString) + Assert.AreEqual(ExpectedTextWithLineBreak, CompuMaster.Console.RawPlainTextLog.ToString) + Assert.AreEqual(ExpectedHtmlWithLineBreak, CompuMaster.Console.HtmlLog.ToString) End Sub Public Sub DualFeatureStringBuilderArgsCompletionTest() Dim Text As New System.Text.StringBuilder("Plain Text") Dim Html As New System.Text.StringBuilder("

HTML code

") + Dim ExpectedTextWithLineBreak As String = Text.ToString & System.Environment.NewLine + Dim ExpectedHtmlWithLineBreak As String = Html.ToString & "
" + CompuMaster.Console.Clear(True, True, True, True) + CompuMaster.Console.WriteLineDual() + Assert.AreEqual(System.Environment.NewLine, CompuMaster.Console.PlainTextLog.ToString) + Assert.AreEqual(System.Environment.NewLine, CompuMaster.Console.RawPlainTextLog.ToString) + Assert.AreEqual("
", CompuMaster.Console.HtmlLog.ToString) + + CompuMaster.Console.Clear(True, True, True, True) + CompuMaster.Console.LogLineDual() + Assert.AreEqual(System.Environment.NewLine, CompuMaster.Console.PlainTextLog.ToString) + Assert.AreEqual(System.Environment.NewLine, CompuMaster.Console.RawPlainTextLog.ToString) + Assert.AreEqual("
", CompuMaster.Console.HtmlLog.ToString) + + CompuMaster.Console.Clear(True, True, True, True) CompuMaster.Console.WriteDual(Text, Html) + Assert.AreEqual(Text.ToString, CompuMaster.Console.PlainTextLog.ToString) + Assert.AreEqual(Text.ToString, CompuMaster.Console.RawPlainTextLog.ToString) + Assert.AreEqual(Html.ToString, CompuMaster.Console.HtmlLog.ToString) + + CompuMaster.Console.Clear(True, True, True, True) CompuMaster.Console.WriteLineDual(Text, Html) + Assert.AreEqual(ExpectedTextWithLineBreak.ToString, CompuMaster.Console.PlainTextLog.ToString) + Assert.AreEqual(ExpectedTextWithLineBreak.ToString, CompuMaster.Console.RawPlainTextLog.ToString) + Assert.AreEqual(ExpectedHtmlWithLineBreak.ToString, CompuMaster.Console.HtmlLog.ToString) + + CompuMaster.Console.Clear(True, True, True, True) CompuMaster.Console.WarnDual(Text, Html) + Assert.AreEqual(Text.ToString, CompuMaster.Console.PlainTextLog.ToString) + Assert.AreEqual("" & Text.ToString & "", CompuMaster.Console.RawPlainTextLog.ToString) + Assert.AreEqual("" & Html.ToString & "", CompuMaster.Console.HtmlLog.ToString) + + CompuMaster.Console.Clear(True, True, True, True) CompuMaster.Console.WarnLineDual(Text, Html) + Assert.AreEqual(ExpectedTextWithLineBreak.ToString, CompuMaster.Console.PlainTextLog.ToString) + Assert.AreEqual("" & ExpectedTextWithLineBreak.ToString.Replace(System.Environment.NewLine, "" & System.Environment.NewLine), CompuMaster.Console.RawPlainTextLog.ToString) + Assert.AreEqual("" & ExpectedHtmlWithLineBreak.ToString.Replace("
", "

"), CompuMaster.Console.HtmlLog.ToString) + + CompuMaster.Console.Clear(True, True, True, True) CompuMaster.Console.OkayDual(Text, Html) + Assert.AreEqual(Text.ToString, CompuMaster.Console.PlainTextLog.ToString) + Assert.AreEqual("" & Text.ToString & "", CompuMaster.Console.RawPlainTextLog.ToString) + Assert.AreEqual("" & Html.ToString & "", CompuMaster.Console.HtmlLog.ToString) + + CompuMaster.Console.Clear(True, True, True, True) CompuMaster.Console.OkayLineDual(Text, Html) + Assert.AreEqual(ExpectedTextWithLineBreak.ToString, CompuMaster.Console.PlainTextLog.ToString) + Assert.AreEqual("" & ExpectedTextWithLineBreak.ToString.Replace(System.Environment.NewLine, "" & System.Environment.NewLine), CompuMaster.Console.RawPlainTextLog.ToString) + Assert.AreEqual("" & ExpectedHtmlWithLineBreak.ToString.Replace("
", "

"), CompuMaster.Console.HtmlLog.ToString) + + CompuMaster.Console.Clear(True, True, True, True) CompuMaster.Console.LogDual(Text, Html) + Assert.AreEqual(Text.ToString, CompuMaster.Console.PlainTextLog.ToString) + Assert.AreEqual(Text.ToString, CompuMaster.Console.RawPlainTextLog.ToString) + Assert.AreEqual(Html.ToString, CompuMaster.Console.HtmlLog.ToString) + + CompuMaster.Console.Clear(True, True, True, True) CompuMaster.Console.LogLineDual(Text, Html) + Assert.AreEqual(ExpectedTextWithLineBreak.ToString, CompuMaster.Console.PlainTextLog.ToString) + Assert.AreEqual(ExpectedTextWithLineBreak.ToString, CompuMaster.Console.RawPlainTextLog.ToString) + Assert.AreEqual(ExpectedHtmlWithLineBreak.ToString, CompuMaster.Console.HtmlLog.ToString) End Sub End Class