Add status support

This commit is contained in:
Patrik Svensson
2020-12-08 00:43:24 +01:00
committed by Patrik Svensson
parent cbed41e637
commit 501db5d287
36 changed files with 1290 additions and 476 deletions

View File

@ -0,0 +1,25 @@
using System;
using System.Collections.Generic;
namespace Spectre.Console.Tests
{
public sealed class DummySpinner1 : Spinner
{
public override TimeSpan Interval => TimeSpan.FromMilliseconds(100);
public override bool IsUnicode => true;
public override IReadOnlyList<string> Frames => new List<string>
{
"*",
};
}
public sealed class DummySpinner2 : Spinner
{
public override TimeSpan Interval => TimeSpan.FromMilliseconds(100);
public override bool IsUnicode => true;
public override IReadOnlyList<string> Frames => new List<string>
{
"-",
};
}
}

View File

@ -0,0 +1,42 @@
using Shouldly;
using Xunit;
namespace Spectre.Console.Tests.Unit
{
public sealed partial class StatusTests
{
[Fact]
public void Should_Render_Status_Correctly()
{
// Given
var console = new TestableAnsiConsole(ColorSystem.TrueColor, width: 10);
var status = new Status(console);
status.AutoRefresh = false;
status.Spinner = new DummySpinner1();
// When
status.Start("foo", ctx =>
{
ctx.Refresh();
ctx.Spinner(new DummySpinner2());
ctx.Status("bar");
ctx.Refresh();
ctx.Spinner(new DummySpinner1());
ctx.Status("baz");
});
// Then
console.Output
.NormalizeLineEndings()
.ShouldBe(
"[?25l \n" +
"* foo\n" +
"  \n" +
"- bar\n" +
"  \n" +
"* baz\n" +
" [?25h");
}
}
}