Skip to content

Commit 5a3828e

Browse files
committed
Add another extra couple of tests
1 parent 5573afb commit 5a3828e

File tree

3 files changed

+55
-2
lines changed

3 files changed

+55
-2
lines changed

tests/CommandLine.Tests/StringExtensions.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@ public static string[] ToNotEmptyLines(this string value)
1313
return value.Split(new[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries);
1414
}
1515

16+
public static string[] ToLines(this string value)
17+
{
18+
return value.Split(new[] { Environment.NewLine }, StringSplitOptions.None);
19+
}
20+
1621
public static string[] TrimStringArray(this IEnumerable<string> array)
1722
{
1823
return array.Select(item => item.Trim()).ToArray();

tests/CommandLine.Tests/Unit/ParserTests.cs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -860,5 +860,25 @@ public void Parse_options_with_shuffled_index_values()
860860
Assert.Equal("two", args.Arg2);
861861
});
862862
}
863+
864+
865+
[Fact]
866+
public void Blank_lines_are_inserted_between_verbs()
867+
{
868+
// Fixture setup
869+
var help = new StringWriter();
870+
var sut = new Parser(config => config.HelpWriter = help);
871+
872+
// Exercize system
873+
sut.ParseArguments<Secert_Verb, Add_Verb_With_Usage_Attribute>(new string[] { });
874+
var result = help.ToString();
875+
876+
// Verify outcome
877+
var lines = result.ToLines().TrimStringArray();
878+
lines[6].Should().BeEquivalentTo("add Add file contents to the index.");
879+
lines[8].Should().BeEquivalentTo("help Display more information on a specific command.");
880+
lines[10].Should().BeEquivalentTo("version Display version information.");
881+
// Teardown
882+
}
863883
}
864884
}

tests/CommandLine.Tests/Unit/Text/HelpTextTests.cs

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -540,7 +540,7 @@ public void Invoke_AutoBuild_for_Options_with_Usage_returns_appropriate_formatte
540540
// Teardown
541541
}
542542

543-
#if !PLATFORM_DOTNET
543+
544544
[Fact]
545545
public void Default_set_to_sequence_should_be_properly_printed()
546546
{
@@ -566,7 +566,6 @@ public void Default_set_to_sequence_should_be_properly_printed()
566566

567567
// Teardown
568568
}
569-
#endif
570569

571570
[Fact]
572571
public void AutoBuild_when_no_assembly_attributes()
@@ -744,5 +743,34 @@ public void HelpTextPreservesIndentationAcrossWordWrapWithSmallMaximumDisplayWid
744743
// Teardown
745744
}
746745

746+
747+
748+
[Fact]
749+
public void Options_should_be_separated_by_spaces()
750+
{
751+
// Fixture setup
752+
var handlers = new CultureInfo("en-US").MakeCultureHandlers();
753+
var fakeResult =
754+
new NotParsed<Options_With_Default_Set_To_Sequence>(
755+
typeof(Options_With_Default_Set_To_Sequence).ToTypeInfo(),
756+
Enumerable.Empty<Error>()
757+
);
758+
759+
// Exercize system
760+
handlers.ChangeCulture();
761+
var helpText = HelpText.AutoBuild(fakeResult);
762+
handlers.ResetCulture();
763+
764+
// Verify outcome
765+
var text = helpText.ToString();
766+
var lines = text.ToLines().TrimStringArray();
767+
Console.WriteLine(text);
768+
lines[3].Should().Be("-z, --strseq (Default: a b c)");
769+
lines[5].Should().Be("-y, --intseq (Default: 1 2 3)");
770+
lines[7].Should().Be("-q, --dblseq (Default: 1.1 2.2 3.3)");
771+
772+
// Teardown
773+
}
774+
747775
}
748776
}

0 commit comments

Comments
 (0)