Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Floating Point In ProgressBar #3

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions src/Hangfire.Console/Dashboard/ConsoleRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public static void RenderLine(StringBuilder builder, ConsoleLine line, DateTime

if (isProgressBar)
{
builder.AppendFormat(CultureInfo.InvariantCulture, "<div class=\"pv\" style=\"width:{0:0.#}%\" data-value=\"{0:f0}\"></div>", line.ProgressValue!.Value);
builder.AppendFormat(CultureInfo.InvariantCulture, "<div class=\"pv\" style=\"width:{0}%\" data-value=\"{0}\"></div>", line.ProgressValue!.Value);
}
else
{
Expand Down Expand Up @@ -249,6 +249,7 @@ public static void RenderLineBuffer(StringBuilder builder, IConsoleStorage stora

private class DummyPage : RazorPage
{
public override void Execute() { }
public override void Execute()
{ }
}
}
}
15 changes: 13 additions & 2 deletions tests/Hangfire.Console.Tests/Dashboard/ConsoleRendererFacts.cs
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,18 @@ public void RenderLine_WithFractionalProgress()

ConsoleRenderer.RenderLine(builder, line, new DateTime(2016, 1, 1, 0, 0, 0, DateTimeKind.Utc));

Assert.Equal("<div class=\"line pb\" data-id=\"3\"><span data-moment-title=\"1451606400\">+ &lt;1ms</span><div class=\"pv\" style=\"width:17.3%\" data-value=\"17\"></div></div>", builder.ToString());
Assert.Equal("<div class=\"line pb\" data-id=\"3\"><span data-moment-title=\"1451606400\">+ &lt;1ms</span><div class=\"pv\" style=\"width:17.3%\" data-value=\"17.3\"></div></div>", 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("<div class=\"line pb\" data-id=\"3\"><span data-moment-title=\"1451606400\">+ &lt;1ms</span><div class=\"pv\" style=\"width:17.3213%\" data-value=\"17.3213\"></div></div>", builder.ToString());
}

[Fact]
Expand Down Expand Up @@ -341,4 +352,4 @@ private void SetupStorage(StateData? stateData, params ConsoleLine[] lines)
_storage.Setup(x => x.GetLines(It.IsAny<ConsoleId>(), It.IsAny<int>(), It.IsAny<int>()))
.Returns((ConsoleId _, int start, int end) => lines.Where((_, i) => i >= start && i <= end));
}
}
}