mirror of
				https://github.com/nsnail/spectre.console.git
				synced 2025-11-04 02:25:28 +08:00 
			
		
		
		
	Adds ValueFormatter to ProgressBar
This commit is contained in:
		@@ -0,0 +1 @@
 | 
			
		||||
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 9,000
 | 
			
		||||
@@ -0,0 +1 @@
 | 
			
		||||
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 9000
 | 
			
		||||
							
								
								
									
										51
									
								
								test/Spectre.Console.Tests/Unit/Widgets/ProgressBarTests.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										51
									
								
								test/Spectre.Console.Tests/Unit/Widgets/ProgressBarTests.cs
									
									
									
									
									
										Normal 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);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user