Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions src/Spectre.Console.Tests/Unit/Prompts/TextPromptTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -453,4 +453,24 @@ public Task Should_Clear_Prompt_Line_When_ClearOnFinish_Is_Enabled()
// Then
return Verifier.Verify(console.Output);
}

[Theory]
[InlineData("yes")]
[InlineData("Yes")]
[InlineData("YES")]
public async Task Uses_case_insensitive_comparison_when_no_comparer_is_passed(string input)
{
// Given
var console = new TestConsole { EmitAnsiSequences = true, };
console.Input.PushTextWithEnter(input);

var prompt = new TextPrompt<string>("Was the tool helpful?")
.AddChoices(["Yes", "Partially", "No"]);

// When
var result = await console.PromptAsync(prompt);

// Then
result.ShouldBe("Yes");
}
}
2 changes: 1 addition & 1 deletion src/Spectre.Console/Prompts/TextPrompt.cs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public sealed class TextPrompt<T> : IPrompt<T>, IHasCulture
public TextPrompt(string prompt, StringComparer? comparer = null)
{
_prompt = prompt ?? throw new System.ArgumentNullException(nameof(prompt));
_comparer = comparer;
_comparer = comparer ?? StringComparer.OrdinalIgnoreCase;
}

/// <summary>
Expand Down