-
Notifications
You must be signed in to change notification settings - Fork 656
Feat/progressbar valueformatter #1414
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
Merged
patriksvensson
merged 9 commits into
spectreconsole:main
from
jsheely:feat/progressbar-valueformatter
Jan 31, 2024
Merged
Changes from 5 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
96b6192
Adding ValueFormatter to ProgressBar
jsheely 73b1cd1
Added unit tests for ProgressBar valueFormatter
jsheely 71d0a50
Fixed spacings
jsheely 8fe2007
Re-added extension method.
jsheely 029af43
Re-added ValueFormatter to BarChart
jsheely 2903539
Updated comments
jsheely 5e5f947
Added documentation for ValueFormatter usage
jsheely 09ab344
Linting error
jsheely 41af066
I think this was fine but someone changed it.
jsheely File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
test/Spectre.Console.Tests/Expectations/Widgets/ProgressBar/Formatted.Output.verified.txt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 9,000 |
1 change: 1 addition & 0 deletions
1
test/Spectre.Console.Tests/Expectations/Widgets/ProgressBar/Render.Output.verified.txt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 9000 |
51 changes: 51 additions & 0 deletions
51
test/Spectre.Console.Tests/Unit/Widgets/ProgressBarTests.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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 | ||
|
jsheely marked this conversation as resolved.
|
||
| 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 | ||
|
jsheely marked this conversation as resolved.
|
||
| await Verifier.Verify(console.Output); | ||
| } | ||
| } | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.