mirror of
https://github.com/nsnail/spectre.console.git
synced 2025-07-02 19:08:15 +08:00
Fix progress rendering bug
This commit is contained in:

committed by
Patrik Svensson

parent
ae32785f21
commit
3c504155bc
@ -0,0 +1,5 @@
|
||||
|
||||
foo ━━━ 0% -:--:-- ⣷
|
||||
bar ━━━ 0% -:--:-- ⣷
|
||||
baz ━━━ 0% -:--:-- ⣷
|
||||
|
17
src/Spectre.Console.Tests/Tools/DummyCursor.cs
Normal file
17
src/Spectre.Console.Tests/Tools/DummyCursor.cs
Normal file
@ -0,0 +1,17 @@
|
||||
namespace Spectre.Console.Tests
|
||||
{
|
||||
public sealed class DummyCursor : IAnsiConsoleCursor
|
||||
{
|
||||
public void Move(CursorDirection direction, int steps)
|
||||
{
|
||||
}
|
||||
|
||||
public void SetPosition(int column, int line)
|
||||
{
|
||||
}
|
||||
|
||||
public void Show(bool show)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
@ -11,7 +11,7 @@ namespace Spectre.Console.Tests
|
||||
{
|
||||
public Capabilities Capabilities { get; }
|
||||
public Encoding Encoding { get; }
|
||||
public IAnsiConsoleCursor Cursor => throw new NotSupportedException();
|
||||
public IAnsiConsoleCursor Cursor => new DummyCursor();
|
||||
public TestableConsoleInput Input { get; }
|
||||
|
||||
public int Width { get; }
|
||||
|
@ -1,4 +1,4 @@
|
||||
namespace Spectre.Console.Tests.Tools
|
||||
namespace Spectre.Console.Tests
|
||||
{
|
||||
public sealed class TestLinkIdentityGenerator : ILinkIdentityGenerator
|
||||
{
|
||||
|
@ -3,7 +3,6 @@ using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using Spectre.Console.Rendering;
|
||||
using Spectre.Console.Tests.Tools;
|
||||
|
||||
namespace Spectre.Console.Tests
|
||||
{
|
||||
|
@ -1,8 +1,11 @@
|
||||
using System.Threading.Tasks;
|
||||
using Shouldly;
|
||||
using VerifyXunit;
|
||||
using Xunit;
|
||||
|
||||
namespace Spectre.Console.Tests.Unit
|
||||
{
|
||||
[UsesVerify]
|
||||
public sealed class ProgressTests
|
||||
{
|
||||
[Fact]
|
||||
@ -54,5 +57,35 @@ namespace Spectre.Console.Tests.Unit
|
||||
" \n" + // Bottom padding
|
||||
"[?25h"); // show cursor
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public Task Foo()
|
||||
{
|
||||
// Given
|
||||
var console = new PlainConsole(width: 20);
|
||||
|
||||
var progress = new Progress(console)
|
||||
.Columns(new ProgressColumn[]
|
||||
{
|
||||
new TaskDescriptionColumn(),
|
||||
new ProgressBarColumn(),
|
||||
new PercentageColumn(),
|
||||
new RemainingTimeColumn(),
|
||||
new SpinnerColumn(),
|
||||
})
|
||||
.AutoRefresh(false)
|
||||
.AutoClear(false);
|
||||
|
||||
// When
|
||||
progress.Start(ctx =>
|
||||
{
|
||||
ctx.AddTask("foo");
|
||||
ctx.AddTask("bar");
|
||||
ctx.AddTask("baz");
|
||||
});
|
||||
|
||||
// Then
|
||||
return Verifier.Verify(console.Output);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user