mirror of
https://github.com/nsnail/spectre.console.git
synced 2025-04-16 17:02:51 +08:00

If the item contained escaped markup, after the call to RemoveMarkup the string will contain unescaped markup (that the user explicitly had escaped before) for those cases we need to escape all remaining markup.
31 lines
885 B
C#
31 lines
885 B
C#
using System;
|
|
using Shouldly;
|
|
using Spectre.Console.Testing;
|
|
using Xunit;
|
|
|
|
namespace Spectre.Console.Tests.Unit
|
|
{
|
|
public sealed class SelectionPromptTests
|
|
{
|
|
[Fact]
|
|
[GitHubIssue(608)]
|
|
public void Should_Not_Throw_When_Selecting_An_Item_With_Escaped_Markup()
|
|
{
|
|
// Given
|
|
var console = new TestConsole();
|
|
console.Profile.Capabilities.Interactive = true;
|
|
console.Input.PushKey(ConsoleKey.Enter);
|
|
var input = "[red]This text will never be red[/]".EscapeMarkup();
|
|
|
|
// When
|
|
var prompt = new SelectionPrompt<string>()
|
|
.Title("Select one")
|
|
.AddChoices(input);
|
|
prompt.Show(console);
|
|
|
|
// Then
|
|
console.Output.ShouldContain(@"[red]This text will never be red[/]");
|
|
}
|
|
}
|
|
}
|