Adds ValueFormatter to ProgressBar

This commit is contained in:
Jonathan Sheely
2024-01-31 11:37:05 -05:00
committed by GitHub
parent 71631b248a
commit 703d653ec5
7 changed files with 108 additions and 1 deletions

View File

@ -0,0 +1 @@
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 9,000

View File

@ -0,0 +1 @@
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 9000

View File

@ -0,0 +1,51 @@
namespace Spectre.Console.Tests.Unit;
[UsesVerify]
[ExpectationPath("Widgets/ProgressBar")]
public class ProgressBarTests
{
[Fact]
[Expectation("Render")]
public async Task Should_Render_Correctly()
{
// Given
var console = new TestConsole();
var bar = new ProgressBar()
{
Width = 60,
Value = 9000,
MaxValue = 9000,
ShowValue = true,
};
// When
console.Write(bar);
// Then
await Verifier.Verify(console.Output);
}
[Fact]
[Expectation("Formatted")]
public async Task Should_Render_ValueFormatted()
{
// Given
var console = new TestConsole();
var bar = new ProgressBar()
{
Width = 60,
Value = 9000,
MaxValue = 9000,
ShowValue = true,
ValueFormatter = (value, _) => value.ToString("N0"),
};
// When
console.Write(bar);
// Then
await Verifier.Verify(console.Output);
}
}