mirror of
https://github.com/nsnail/spectre.console.git
synced 2025-08-03 02:17:59 +08:00
ProgressTask.GetPercentage() returns 100 when max value is 0 (#1694)
This commit is contained in:
@ -118,6 +118,31 @@ public sealed class ProgressTests
|
||||
task.Value.ShouldBe(20);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Setting_Max_Value_To_Zero_Should_Make_Percentage_OneHundred()
|
||||
{
|
||||
// Given
|
||||
var console = new TestConsole()
|
||||
.Interactive();
|
||||
|
||||
var task = default(ProgressTask);
|
||||
var progress = new Progress(console)
|
||||
.Columns(new[] { new ProgressBarColumn() })
|
||||
.AutoRefresh(false)
|
||||
.AutoClear(false);
|
||||
|
||||
// When
|
||||
progress.Start(ctx =>
|
||||
{
|
||||
task = ctx.AddTask("foo");
|
||||
task.MaxValue = 0;
|
||||
});
|
||||
|
||||
// Then
|
||||
task.Value.ShouldBe(0);
|
||||
task.Percentage.ShouldBe(100);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Setting_Value_Should_Override_Incremented_Value()
|
||||
{
|
||||
|
Reference in New Issue
Block a user