Skip to content

Commit

Permalink
fixed missing color settings after 9f9c7b4
Browse files Browse the repository at this point in the history
  • Loading branch information
jochenwezel committed Jul 22, 2022
1 parent 0248b8e commit 35e5112
Show file tree
Hide file tree
Showing 3 changed files with 134 additions and 14 deletions.
4 changes: 2 additions & 2 deletions Console/CompuMaster.Console.vbproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
<Product>CompuMaster.Console</Product>
<Copyright>2016-2017,2019,2021,2022 CompuMaster GmbH</Copyright>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<AssemblyVersion>2022.7.21.100</AssemblyVersion>
<Version>2022.7.22.100</Version>
<AssemblyVersion>2022.7.22.101</AssemblyVersion>
<Version>2022.7.22.101</Version>
<VBRuntime>Embed</VBRuntime>
<IsPackable>true</IsPackable>
<Configurations>Debug;Release;CI_CD</Configurations>
Expand Down
38 changes: 26 additions & 12 deletions Console/Console.vb
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,13 @@ Namespace CompuMaster
_WriteDual(text, html, False)
End Sub

''' <summary>
''' Log message without output to console
''' </summary>
Public Shared Sub LogLine()
_Write(System.Environment.NewLine, False)
End Sub

''' <summary>
''' Log message without output to console
''' </summary>
Expand All @@ -197,6 +204,13 @@ Namespace CompuMaster
_Write(System.Environment.NewLine, False)
End Sub

''' <summary>
''' Log message without output to console
''' </summary>
Public Shared Sub LogLineDual()
_WriteDual(System.Environment.NewLine, "<br />", False)
End Sub

''' <summary>
''' Log message without output to console
''' </summary>
Expand Down Expand Up @@ -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("<BACKCOLOR:" & ConsoleColorSystemName(BackgroundColor) & ">")
End If
If ForegroundColor <> SystemConsoleDefaultForegroundColor Then
If ForegroundColor <> SystemConsoleDefaultForegroundColor OrElse SystemColorsInLogs = SystemColorModesInLogs.AlwaysApplySystemColorInLog Then
_RawPlainTextLog.Append("<FORECOLOR:" & ConsoleColorSystemName(ForegroundColor) & ">")
End If
_RawPlainTextLog.Append(IndentText(text, Not IsNewOutputLineAtLog))
If ForegroundColor <> SystemConsoleDefaultForegroundColor Then
If ForegroundColor <> SystemConsoleDefaultForegroundColor OrElse SystemColorsInLogs = SystemColorModesInLogs.AlwaysApplySystemColorInLog Then
_RawPlainTextLog.Append("</FORECOLOR:" & ConsoleColorSystemName(ForegroundColor) & ">")
End If
If BackgroundColor <> SystemConsoleDefaultBackgroundColor Then
If BackgroundColor <> SystemConsoleDefaultBackgroundColor OrElse SystemColorsInLogs = SystemColorModesInLogs.AlwaysApplySystemColorInLog Then
_RawPlainTextLog.Append("</BACKCOLOR:" & ConsoleColorSystemName(BackgroundColor) & ">")
End If
End If
Expand Down Expand Up @@ -339,11 +353,11 @@ Namespace CompuMaster
If BackgroundColor <> SystemConsoleDefaultBackgroundColor Then
_HtmlLog.Append("<span style=""background-color: " & ConsoleColorCssName(BackgroundColor) & ";"">")
End If
If ForegroundColor <> SystemConsoleDefaultForegroundColor Then
If ForegroundColor <> SystemConsoleDefaultForegroundColor OrElse SystemColorsInLogs = SystemColorModesInLogs.AlwaysApplySystemColorInLog Then
_HtmlLog.Append("<span style=""color: " & ConsoleColorCssName(ForegroundColor) & ";"">")
End If
_HtmlLog.Append(TextAsHtml)
If ForegroundColor <> SystemConsoleDefaultForegroundColor Then
If ForegroundColor <> SystemConsoleDefaultForegroundColor OrElse SystemColorsInLogs = SystemColorModesInLogs.AlwaysApplySystemColorInLog Then
_HtmlLog.Append("</span>")
End If
If BackgroundColor <> SystemConsoleDefaultBackgroundColor Then
Expand Down Expand Up @@ -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("<BACKCOLOR:" & ConsoleColorSystemName(BackgroundColor) & ">")
End If
If ForegroundColor <> SystemConsoleDefaultForegroundColor Then
If ForegroundColor <> SystemConsoleDefaultForegroundColor OrElse SystemColorsInLogs = SystemColorModesInLogs.AlwaysApplySystemColorInLog Then
_RawPlainTextLog.Append("<FORECOLOR:" & ConsoleColorSystemName(ForegroundColor) & ">")
End If
_RawPlainTextLog.Append(IndentText(text.ToString, Not IsNewOutputLineAtLog))
If ForegroundColor <> SystemConsoleDefaultForegroundColor Then
If ForegroundColor <> SystemConsoleDefaultForegroundColor OrElse SystemColorsInLogs = SystemColorModesInLogs.AlwaysApplySystemColorInLog Then
_RawPlainTextLog.Append("</FORECOLOR:" & ConsoleColorSystemName(ForegroundColor) & ">")
End If
If BackgroundColor <> SystemConsoleDefaultBackgroundColor Then
If BackgroundColor <> SystemConsoleDefaultBackgroundColor OrElse SystemColorsInLogs = SystemColorModesInLogs.AlwaysApplySystemColorInLog Then
_RawPlainTextLog.Append("</BACKCOLOR:" & ConsoleColorSystemName(BackgroundColor) & ">")
End If
End If
Expand All @@ -496,11 +510,11 @@ Namespace CompuMaster
If BackgroundColor <> SystemConsoleDefaultBackgroundColor Then
_HtmlLog.Append("<span style=""background-color: " & ConsoleColorCssName(BackgroundColor) & ";"">")
End If
If ForegroundColor <> SystemConsoleDefaultForegroundColor Then
If ForegroundColor <> SystemConsoleDefaultForegroundColor OrElse SystemColorsInLogs = SystemColorModesInLogs.AlwaysApplySystemColorInLog Then
_HtmlLog.Append("<span style=""color: " & ConsoleColorCssName(ForegroundColor) & ";"">")
End If
_HtmlLog.Append(TextAsHtml)
If ForegroundColor <> SystemConsoleDefaultForegroundColor Then
If ForegroundColor <> SystemConsoleDefaultForegroundColor OrElse SystemColorsInLogs = SystemColorModesInLogs.AlwaysApplySystemColorInLog Then
_HtmlLog.Append("</span>")
End If
If BackgroundColor <> SystemConsoleDefaultBackgroundColor Then
Expand Down
106 changes: 106 additions & 0 deletions ConsoleTest/ConsoleLoggingTests.vb
Original file line number Diff line number Diff line change
Expand Up @@ -407,29 +407,135 @@ Namespace ConsoleTest
<Test> Public Sub DualFeatureStringArgsCompletionTest()
Dim Text As String = "Plain Text"
Dim Html As String = "<h2>HTML code</h2>"
Dim ExpectedTextWithLineBreak As String = Text & System.Environment.NewLine
Dim ExpectedHtmlWithLineBreak As String = Html & "<br />"

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("<br />", 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("<br />", 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("<FORECOLOR:Red>" & Text & "</FORECOLOR:Red>", CompuMaster.Console.RawPlainTextLog.ToString)
Assert.AreEqual("<span style=""color: Red;"">" & Html & "</span>", 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("<FORECOLOR:Red>" & ExpectedTextWithLineBreak & "</FORECOLOR:Red>", CompuMaster.Console.RawPlainTextLog.ToString)
Assert.AreEqual("<span style=""color: Red;"">" & ExpectedHtmlWithLineBreak.ToString & "</span>", 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("<FORECOLOR:Green>" & Text & "</FORECOLOR:Green>", CompuMaster.Console.RawPlainTextLog.ToString)
Assert.AreEqual("<span style=""color: Green;"">" & Html.ToString & "</span>", 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("<FORECOLOR:Green>" & ExpectedTextWithLineBreak & "</FORECOLOR:Green>", CompuMaster.Console.RawPlainTextLog.ToString)
Assert.AreEqual("<span style=""color: Green;"">" & ExpectedHtmlWithLineBreak.ToString & "</span>", 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

<Test> Public Sub DualFeatureStringBuilderArgsCompletionTest()
Dim Text As New System.Text.StringBuilder("Plain Text")
Dim Html As New System.Text.StringBuilder("<h2>HTML code</h2>")
Dim ExpectedTextWithLineBreak As String = Text.ToString & System.Environment.NewLine
Dim ExpectedHtmlWithLineBreak As String = Html.ToString & "<br />"

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("<br />", 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("<br />", 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("<FORECOLOR:Red>" & Text.ToString & "</FORECOLOR:Red>", CompuMaster.Console.RawPlainTextLog.ToString)
Assert.AreEqual("<span style=""color: Red;"">" & Html.ToString & "</span>", 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("<FORECOLOR:Red>" & ExpectedTextWithLineBreak.ToString.Replace(System.Environment.NewLine, "</FORECOLOR:Red>" & System.Environment.NewLine), CompuMaster.Console.RawPlainTextLog.ToString)
Assert.AreEqual("<span style=""color: Red;"">" & ExpectedHtmlWithLineBreak.ToString.Replace("<br />", "</span><br />"), 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("<FORECOLOR:Green>" & Text.ToString & "</FORECOLOR:Green>", CompuMaster.Console.RawPlainTextLog.ToString)
Assert.AreEqual("<span style=""color: Green;"">" & Html.ToString & "</span>", 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("<FORECOLOR:Green>" & ExpectedTextWithLineBreak.ToString.Replace(System.Environment.NewLine, "</FORECOLOR:Green>" & System.Environment.NewLine), CompuMaster.Console.RawPlainTextLog.ToString)
Assert.AreEqual("<span style=""color: Green;"">" & ExpectedHtmlWithLineBreak.ToString.Replace("<br />", "</span><br />"), 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
Expand Down

0 comments on commit 35e5112

Please sign in to comment.