Skip to content

Commit 3f61097

Browse files
committed
Added failing test for Issue #225/b
1 parent 143eed1 commit 3f61097

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

tests/CommandLine.Tests/Unit/ParserTests.cs

+28
Original file line numberDiff line numberDiff line change
@@ -538,6 +538,34 @@ public void When_IgnoreUnknownArguments_is_set_valid_unknown_arguments_avoid_a_f
538538
// Teardown
539539
}
540540

541+
[Fact]
542+
public void Properly_formatted_help_screen_excludes_help_as_unknown_option()
543+
{
544+
// Fixture setup
545+
var help = new StringWriter();
546+
var sut = new Parser(config => config.HelpWriter = help);
547+
548+
// Exercize system
549+
sut.ParseArguments<Add_Verb, Commit_Verb, Clone_Verb>(
550+
new[] { "clone", "--bad-arg", "--help" });
551+
var result = help.ToString();
552+
553+
// Verify outcome
554+
var lines = result.ToNotEmptyLines().TrimStringArray();
555+
lines[0].Should().StartWithEquivalent("CommandLine");
556+
lines[1].ShouldBeEquivalentTo("Copyright (c) 2005 - 2015 Giacomo Stelluti Scala");
557+
lines[2].ShouldBeEquivalentTo("ERROR(S):");
558+
lines[3].ShouldBeEquivalentTo("Option 'bad-arg' is unknown.");
559+
lines[4].ShouldBeEquivalentTo("--no-hardlinks Optimize the cloning process from a repository on a local");
560+
lines[5].ShouldBeEquivalentTo("filesystem by copying files.");
561+
lines[6].ShouldBeEquivalentTo("-q, --quiet Suppress summary message.");
562+
lines[7].ShouldBeEquivalentTo("--help Display this help screen.");
563+
lines[8].ShouldBeEquivalentTo("--version Display version information.");
564+
lines[9].ShouldBeEquivalentTo("value pos. 0");
565+
566+
// Teardown
567+
}
568+
541569
public static IEnumerable<object> IgnoreUnknownArgumentsData
542570
{
543571
get

0 commit comments

Comments
 (0)