From 2b5e5701377019afccd1bd64abb43267e28a124f Mon Sep 17 00:00:00 2001 From: Sufyan Nisar Date: Sun, 28 Jan 2024 22:58:36 +0300 Subject: [PATCH 1/2] Render ProgressBar value in double with provided digits precision --- src/Hangfire.Console/Dashboard/ConsoleRenderer.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/Hangfire.Console/Dashboard/ConsoleRenderer.cs b/src/Hangfire.Console/Dashboard/ConsoleRenderer.cs index cc7410b..dd0b548 100644 --- a/src/Hangfire.Console/Dashboard/ConsoleRenderer.cs +++ b/src/Hangfire.Console/Dashboard/ConsoleRenderer.cs @@ -104,7 +104,7 @@ public static void RenderLine(StringBuilder builder, ConsoleLine line, DateTime if (isProgressBar) { - builder.AppendFormat(CultureInfo.InvariantCulture, "
", line.ProgressValue!.Value); + builder.AppendFormat(CultureInfo.InvariantCulture, "
", line.ProgressValue!.Value); } else { @@ -249,6 +249,7 @@ public static void RenderLineBuffer(StringBuilder builder, IConsoleStorage stora private class DummyPage : RazorPage { - public override void Execute() { } + public override void Execute() + { } } -} +} \ No newline at end of file From d546ca8fcf9629b268e355580288ccdf8d075d4e Mon Sep 17 00:00:00 2001 From: Sufyan Nisar Date: Sun, 28 Jan 2024 23:10:14 +0300 Subject: [PATCH 2/2] Fixed Failing UnitTests --- .../Dashboard/ConsoleRendererFacts.cs | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/tests/Hangfire.Console.Tests/Dashboard/ConsoleRendererFacts.cs b/tests/Hangfire.Console.Tests/Dashboard/ConsoleRendererFacts.cs index 4a8e2a1..82e6c06 100644 --- a/tests/Hangfire.Console.Tests/Dashboard/ConsoleRendererFacts.cs +++ b/tests/Hangfire.Console.Tests/Dashboard/ConsoleRendererFacts.cs @@ -137,7 +137,18 @@ public void RenderLine_WithFractionalProgress() ConsoleRenderer.RenderLine(builder, line, new DateTime(2016, 1, 1, 0, 0, 0, DateTimeKind.Utc)); - Assert.Equal("
+ <1ms
", builder.ToString()); + Assert.Equal("
+ <1ms
", builder.ToString()); + } + + [Fact] + public void RenderLine_WithFractionalProgressWith4DecimalPlaces() + { + var line = new ConsoleLine { TimeOffset = 0, Message = "3", ProgressValue = 17.3213 }; + var builder = new StringBuilder(); + + ConsoleRenderer.RenderLine(builder, line, new DateTime(2016, 1, 1, 0, 0, 0, DateTimeKind.Utc)); + + Assert.Equal("
+ <1ms
", builder.ToString()); } [Fact] @@ -341,4 +352,4 @@ private void SetupStorage(StateData? stateData, params ConsoleLine[] lines) _storage.Setup(x => x.GetLines(It.IsAny(), It.IsAny(), It.IsAny())) .Returns((ConsoleId _, int start, int end) => lines.Where((_, i) => i >= start && i <= end)); } -} +} \ No newline at end of file