mirror of
https://github.com/nsnail/spectre.console.git
synced 2025-04-16 00:42:51 +08:00
added some breaking unit tests
This commit is contained in:
parent
0d19ccd8a6
commit
0d72b94f9c
@ -49,6 +49,36 @@ public partial class AnsiConsoleTests
|
||||
console.Output.ShouldMatch("]8;id=[0-9]*;https:\\/\\/patriksvensson\\.se\\\\https:\\/\\/patriksvensson\\.se]8;;\\\\");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Should_Output_Expected_Ansi_For_Link_With_Bracket_In_Url_Only()
|
||||
{
|
||||
// Given
|
||||
var console = new TestConsole()
|
||||
.EmitAnsiSequences();
|
||||
|
||||
// When
|
||||
const string Path = "file://c:/temp/[x].txt";
|
||||
console.Markup($"[link]{Path.EscapeMarkup()}[/]");
|
||||
|
||||
// Then
|
||||
console.Output.ShouldMatch("]8;id=[0-9]*;file:\\/\\/c:\\/temp\\/\\[x\\].txt\\\\file:\\/\\/c:\\/temp\\/\\[x\\].txt]8;;\\\\");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Should_Output_Expected_Ansi_For_Link_With_Bracket_In_Url()
|
||||
{
|
||||
// Given
|
||||
var console = new TestConsole()
|
||||
.EmitAnsiSequences();
|
||||
|
||||
// When
|
||||
const string Path = "file://c:/temp/[x].txt";
|
||||
console.Markup($"[link={Path.EscapeMarkup()}]{Path.EscapeMarkup()}[/]");
|
||||
|
||||
// Then
|
||||
console.Output.ShouldMatch("]8;id=[0-9]*;file:\\/\\/c:\\/temp\\/\\[x\\].txt\\\\file:\\/\\/c:\\/temp\\/\\[x\\].txt]8;;\\\\");
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("[yellow]Hello [[ World[/]", "[93mHello [ World[0m")]
|
||||
public void Should_Be_Able_To_Escape_Tags(string markup, string expected)
|
||||
|
@ -0,0 +1,40 @@
|
||||
namespace Spectre.Console.Tests.Unit;
|
||||
|
||||
public partial class AnsiConsoleTests
|
||||
{
|
||||
public sealed class MarkupInterpolated
|
||||
{
|
||||
[Fact]
|
||||
public void Should_Print_Simple_Interpolated_Strings()
|
||||
{
|
||||
// Given
|
||||
var console = new TestConsole()
|
||||
.Colors(ColorSystem.Standard)
|
||||
.EmitAnsiSequences();
|
||||
|
||||
// When
|
||||
const string Path = "file://c:/temp/[x].txt";
|
||||
console.MarkupInterpolated($"[Green]{Path}[/]");
|
||||
|
||||
// Then
|
||||
console.Output.ShouldBe($"[32m{Path}[0m");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Should_Not_Throw_Error_On_Links_Brackets()
|
||||
{
|
||||
// Given
|
||||
var console = new TestConsole()
|
||||
.Colors(ColorSystem.Standard)
|
||||
.EmitAnsiSequences();
|
||||
|
||||
// When
|
||||
const string Path = "file://c:/temp/[x].txt";
|
||||
console.MarkupInterpolated($"[link={Path}]{Path}[/]");
|
||||
|
||||
// Then
|
||||
var pathAsRegEx = Regex.Replace(Path, "([/\\[\\]\\\\])", "\\$1", RegexOptions.Compiled|RegexOptions.IgnoreCase);
|
||||
console.Output.ShouldMatch($"\\]8;id=[0-9]+;{pathAsRegEx}\\\\{pathAsRegEx}\\]8;;\\\\");
|
||||
}
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user