From 20e114484c92ebf8d2d4f0f60aaa4f45c522d462 Mon Sep 17 00:00:00 2001 From: "Moh.Hassan" Date: Tue, 7 May 2019 13:04:50 +0200 Subject: [PATCH 1/4] Add test cases ignored in v2.4.3 (18 test case) --- tests/CommandLine.Tests/Unit/ParserTests.cs | 56 +++++++++---------- .../Unit/Text/HelpTextTests.cs | 37 ++++++------ 2 files changed, 47 insertions(+), 46 deletions(-) diff --git a/tests/CommandLine.Tests/Unit/ParserTests.cs b/tests/CommandLine.Tests/Unit/ParserTests.cs index c183c47d..4df56eac 100644 --- a/tests/CommandLine.Tests/Unit/ParserTests.cs +++ b/tests/CommandLine.Tests/Unit/ParserTests.cs @@ -326,7 +326,7 @@ public void Explicit_version_request_generates_version_requested_error() // Teardown } - //[Fact] + [Fact] public void Explicit_version_request_generates_version_info_screen() { // Fixture setup @@ -345,12 +345,12 @@ public void Explicit_version_request_generates_version_info_screen() lines[0].Should().StartWithEquivalent("CommandLine"); #else // Takes the name of the xUnit test program - lines[0].Should().StartWithEquivalent("xUnit"); + lines[0].Should().StartWithEquivalent("testhost"); #endif // Teardown } - //[Fact] + [Fact] public void Implicit_help_screen_in_verb_scenario() { // Fixture setup @@ -369,8 +369,8 @@ public void Implicit_help_screen_in_verb_scenario() lines[1].Should().BeEquivalentTo("Copyright (c) 2005 - 2018 Giacomo Stelluti Scala & Contributors"); #else // Takes the name of the xUnit test program - lines[0].Should().StartWithEquivalent("xUnit"); - lines[1].Should().StartWithEquivalent("Copyright (C) Outercurve Foundation"); + lines[0].Should().StartWithEquivalent("testhost"); + lines[1].Should().StartWithEquivalent("© Microsoft Corporation"); #endif lines[2].Should().BeEquivalentTo("ERROR(S):"); lines[3].Should().BeEquivalentTo("No verb selected."); @@ -382,7 +382,7 @@ public void Implicit_help_screen_in_verb_scenario() // Teardown } - //[Fact] + [Fact] public void Double_dash_help_dispalys_verbs_index_in_verbs_scenario() { // Fixture setup @@ -400,8 +400,8 @@ public void Double_dash_help_dispalys_verbs_index_in_verbs_scenario() lines[1].Should().BeEquivalentTo("Copyright (c) 2005 - 2018 Giacomo Stelluti Scala & Contributors"); #else // Takes the name of the xUnit test program - lines[0].Should().StartWithEquivalent("xUnit"); - lines[1].Should().StartWithEquivalent("Copyright (C) Outercurve Foundation"); + lines[0].Should().StartWithEquivalent("testhost"); + lines[1].Should().StartWithEquivalent("© Microsoft Corporation"); #endif lines[2].Should().BeEquivalentTo("add Add file contents to the index."); lines[3].Should().BeEquivalentTo("commit Record changes to the repository."); @@ -411,7 +411,7 @@ public void Double_dash_help_dispalys_verbs_index_in_verbs_scenario() // Teardown } - //[Theory] + [Theory] [InlineData("--version")] [InlineData("version")] public void Explicit_version_request_generates_version_info_screen_in_verbs_scenario(string command) @@ -432,12 +432,12 @@ public void Explicit_version_request_generates_version_info_screen_in_verbs_scen lines[0].Should().StartWithEquivalent("CommandLine"); #else // Takes the name of the xUnit test program - lines[0].Should().StartWithEquivalent("xUnit"); + lines[0].Should().StartWithEquivalent("testhost"); #endif // Teardown } - //[Fact] + [Fact] public void Errors_of_type_MutuallyExclusiveSetError_are_properly_formatted() { // Fixture setup @@ -455,8 +455,8 @@ public void Errors_of_type_MutuallyExclusiveSetError_are_properly_formatted() lines[1].Should().BeEquivalentTo("Copyright (c) 2005 - 2018 Giacomo Stelluti Scala & Contributors"); #else // Takes the name of the xUnit test program - lines[0].Should().StartWithEquivalent("xUnit"); - lines[1].Should().StartWithEquivalent("Copyright (C) Outercurve Foundation"); + lines[0].Should().StartWithEquivalent("testhost"); + lines[1].Should().StartWithEquivalent("© Microsoft Corporation"); #endif lines[2].Should().BeEquivalentTo("ERROR(S):"); lines[3].Should().BeEquivalentTo("Option: 'weburl' is not compatible with: 'ftpurl'."); @@ -485,7 +485,7 @@ public void Explicit_help_request_with_specific_verb_generates_help_screen() // Teardown } - //[Fact] + [Fact] public void Properly_formatted_help_screen_is_displayed_when_usage_is_defined_in_verb_scenario() { // Fixture setup @@ -508,8 +508,8 @@ public void Properly_formatted_help_screen_is_displayed_when_usage_is_defined_in lines[1].Should().BeEquivalentTo("Copyright (c) 2005 - 2018 Giacomo Stelluti Scala & Contributors"); #else // Takes the name of the xUnit test program - lines[0].Should().StartWithEquivalent("xUnit"); - lines[1].Should().StartWithEquivalent("Copyright (C) Outercurve Foundation"); + lines[0].Should().StartWithEquivalent("testhost"); + lines[1].Should().StartWithEquivalent("© Microsoft Corporation"); #endif lines[2].Should().BeEquivalentTo("ERROR(S):"); lines[3].Should().BeEquivalentTo("Option 'badoption' is unknown."); @@ -530,7 +530,7 @@ public void Properly_formatted_help_screen_is_displayed_when_usage_is_defined_in // Teardown } - //[Fact] + [Fact] public void Properly_formatted_help_screen_is_displayed_when_there_is_a_hidden_verb() { // Fixture setup @@ -548,8 +548,8 @@ public void Properly_formatted_help_screen_is_displayed_when_there_is_a_hidden_v lines[1].Should().BeEquivalentTo("Copyright (c) 2005 - 2018 Giacomo Stelluti Scala & Contributors"); #else // Takes the name of the xUnit test program - lines[0].Should().StartWithEquivalent("xUnit"); - lines[1].Should().StartWithEquivalent("Copyright (C) Outercurve Foundation"); + lines[0].Should().StartWithEquivalent("testhost"); + lines[1].Should().StartWithEquivalent("© Microsoft Corporation"); #endif lines[2].Should().BeEquivalentTo("ERROR(S):"); lines[3].Should().BeEquivalentTo("No verb selected."); @@ -560,7 +560,7 @@ public void Properly_formatted_help_screen_is_displayed_when_there_is_a_hidden_v // Teardown } - //[Fact] + [Fact] public void Properly_formatted_help_screen_is_displayed_when_there_is_a_hidden_verb_selected_usage_displays_with_hidden_option() { // Fixture setup @@ -578,8 +578,8 @@ public void Properly_formatted_help_screen_is_displayed_when_there_is_a_hidden_v lines[1].Should().BeEquivalentTo("Copyright (c) 2005 - 2018 Giacomo Stelluti Scala & Contributors"); #else // Takes the name of the xUnit test program - lines[0].Should().StartWithEquivalent("xUnit"); - lines[1].Should().StartWithEquivalent("Copyright (C) Outercurve Foundation"); + lines[0].Should().StartWithEquivalent("testhost"); + lines[1].Should().StartWithEquivalent("© Microsoft Corporation"); #endif lines[2].Should().BeEquivalentTo("-f, --force Allow adding otherwise ignored files."); lines[3].Should().BeEquivalentTo("--help Display this help screen."); @@ -627,7 +627,7 @@ public void Parse_options_when_given_hidden_verb_with_hidden_option() // Teardown } - //[Fact] + [Fact] public void Specific_verb_help_screen_should_be_displayed_regardless_other_argument() { // Fixture setup @@ -650,8 +650,8 @@ public void Specific_verb_help_screen_should_be_displayed_regardless_other_argum lines[1].Should().BeEquivalentTo("Copyright (c) 2005 - 2018 Giacomo Stelluti Scala & Contributors"); #else // Takes the name of the xUnit test program - lines[0].Should().StartWithEquivalent("xUnit"); - lines[1].Should().StartWithEquivalent("Copyright (C) Outercurve Foundation"); + lines[0].Should().StartWithEquivalent("testhost"); + lines[1].Should().StartWithEquivalent("© Microsoft Corporation"); #endif lines[2].Should().BeEquivalentTo("--no-hardlinks Optimize the cloning process from a repository on a local"); lines[3].Should().BeEquivalentTo("filesystem by copying files."); @@ -701,7 +701,7 @@ public void When_IgnoreUnknownArguments_is_set_valid_unknown_arguments_avoid_a_f // Teardown } - //[Fact] + [Fact] public void Properly_formatted_help_screen_excludes_help_as_unknown_option() { // Fixture setup @@ -724,8 +724,8 @@ public void Properly_formatted_help_screen_excludes_help_as_unknown_option() lines[1].Should().BeEquivalentTo("Copyright (c) 2005 - 2018 Giacomo Stelluti Scala & Contributors"); #else // Takes the name of the xUnit test program - lines[0].Should().StartWithEquivalent("xUnit"); - lines[1].Should().StartWithEquivalent("Copyright (C) Outercurve Foundation"); + lines[0].Should().StartWithEquivalent("testhost"); + lines[1].Should().StartWithEquivalent("© Microsoft Corporation"); #endif lines[2].Should().BeEquivalentTo("ERROR(S):"); lines[3].Should().BeEquivalentTo("Option 'bad-arg' is unknown."); diff --git a/tests/CommandLine.Tests/Unit/Text/HelpTextTests.cs b/tests/CommandLine.Tests/Unit/Text/HelpTextTests.cs index 7c4d7590..d01630cb 100644 --- a/tests/CommandLine.Tests/Unit/Text/HelpTextTests.cs +++ b/tests/CommandLine.Tests/Unit/Text/HelpTextTests.cs @@ -77,7 +77,7 @@ public void Create_instance_with_options() // Teardown } - //[Fact] + [Fact] public void Create_instance_with_enum_options_enabled() { // Fixture setup @@ -182,7 +182,7 @@ public void When_help_text_is_longer_than_width_it_will_wrap_around_as_if_in_a_c // Teardown } - //[Fact] + [Fact] public void When_help_text_has_hidden_option_it_should_not_be_added_to_help_text_output() { // Fixture setup @@ -307,7 +307,7 @@ public void Invoking_RenderParsingErrorsText_returns_appropriate_formatted_text( // Teardown } - //[Fact] + [Fact] public void Invoke_AutoBuild_for_Options_returns_appropriate_formatted_text() { // Fixture setup @@ -329,8 +329,8 @@ public void Invoke_AutoBuild_for_Options_returns_appropriate_formatted_text() lines[1].Should().StartWithEquivalent("Copyright (c)"); #else // Takes the name of the xUnit test program - lines[0].Should().StartWithEquivalent("xUnit"); - lines[1].Should().StartWithEquivalent("Copyright (C) Outercurve Foundation"); + lines[0].Should().StartWithEquivalent("testhost"); + lines[1].Should().StartWithEquivalent("© Microsoft Corporation"); #endif lines[2].Should().BeEquivalentTo("ERROR(S):"); lines[3].Should().BeEquivalentTo("Token 'badtoken' is not recognized."); @@ -343,7 +343,7 @@ public void Invoke_AutoBuild_for_Options_returns_appropriate_formatted_text() // Teardown } - //[Fact] + [Fact] public void Invoke_AutoBuild_for_Verbs_with_specific_verb_returns_appropriate_formatted_text() { // Fixture setup @@ -365,8 +365,8 @@ public void Invoke_AutoBuild_for_Verbs_with_specific_verb_returns_appropriate_fo lines[1].Should().StartWithEquivalent("Copyright (c)"); #else // Takes the name of the xUnit test program - lines[0].Should().StartWithEquivalent("xUnit"); - lines[1].Should().StartWithEquivalent("Copyright (C) Outercurve Foundation"); + lines[0].Should().StartWithEquivalent("testhost"); + lines[1].Should().StartWithEquivalent("© Microsoft Corporation"); #endif lines[2].Should().BeEquivalentTo("-p, --patch Use the interactive patch selection interface to chose which"); lines[3].Should().BeEquivalentTo("changes to commit."); @@ -376,7 +376,7 @@ public void Invoke_AutoBuild_for_Verbs_with_specific_verb_returns_appropriate_fo // Teardown } - //[Fact] + [Fact] public void Invoke_AutoBuild_for_Verbs_with_specific_verb_returns_appropriate_formatted_text_given_display_width_100() { // Fixture setup @@ -398,8 +398,8 @@ public void Invoke_AutoBuild_for_Verbs_with_specific_verb_returns_appropriate_fo lines[1].Should().BeEquivalentTo("Copyright (c) 2005 - 2018 Giacomo Stelluti Scala & Contributors"); #else // Takes the name of the xUnit test program - lines[0].Should().StartWithEquivalent("xUnit"); - lines[1].Should().StartWithEquivalent("Copyright (C) Outercurve Foundation"); + lines[0].Should().StartWithEquivalent("testhost"); + lines[1].Should().StartWithEquivalent("© Microsoft Corporation"); #endif lines[2].Should().BeEquivalentTo("-p, --patch Use the interactive patch selection interface to chose which changes to commit."); lines[3].Should().BeEquivalentTo("--amend Used to amend the tip of the current branch."); @@ -408,7 +408,7 @@ public void Invoke_AutoBuild_for_Verbs_with_specific_verb_returns_appropriate_fo // Teardown } - //[Fact] + [Fact] public void Invoke_AutoBuild_for_Verbs_with_unknown_verb_returns_appropriate_formatted_text() { // Fixture setup @@ -430,8 +430,8 @@ public void Invoke_AutoBuild_for_Verbs_with_unknown_verb_returns_appropriate_for lines[1].Should().StartWithEquivalent("Copyright (c)"); #else // Takes the name of the xUnit test program - lines[0].Should().StartWithEquivalent("xUnit"); - lines[1].Should().StartWithEquivalent("Copyright (C) Outercurve Foundation"); + lines[0].Should().StartWithEquivalent("testhost"); + lines[1].Should().StartWithEquivalent("© Microsoft Corporation"); #endif lines[2].Should().BeEquivalentTo("add Add file contents to the index."); lines[3].Should().BeEquivalentTo("commit Record changes to the repository."); @@ -494,7 +494,7 @@ public static void RenderUsageText_returns_properly_formatted_text() lines[10].Should().BeEquivalentTo(" mono testapp.exe value"); } - //[Fact] + [Fact] public void Invoke_AutoBuild_for_Options_with_Usage_returns_appropriate_formatted_text() { // Fixture setup @@ -510,14 +510,14 @@ public void Invoke_AutoBuild_for_Options_with_Usage_returns_appropriate_formatte // Verify outcome var text = helpText.ToString(); - var lines = text.ToNotEmptyLines(); + var lines = text.ToNotEmptyLines().Select(x=>x.Trim()).ToArray(); #if !PLATFORM_DOTNET lines[0].Should().StartWithEquivalent("CommandLine"); lines[1].Should().StartWithEquivalent("Copyright (c)"); #else // Takes the name of the xUnit test program - lines[0].Should().StartWithEquivalent("xUnit"); - lines[1].Should().StartWithEquivalent("Copyright (C) Outercurve Foundation"); + lines[0].Should().StartWithEquivalent("testhost"); + lines[1].Should().StartWithEquivalent("© Microsoft Corporation"); #endif lines[2].Should().BeEquivalentTo("ERROR(S):"); lines[3].Should().BeEquivalentTo("Token 'badtoken' is not recognized."); @@ -653,5 +653,6 @@ public void Add_line_with_two_empty_spaces_at_the_end() Assert.Equal("T" + Environment.NewLine + "e" + Environment.NewLine + "s" + Environment.NewLine + "t", b.ToString()); } + } } From 260d537d37d528b629fbad23dd5cd2c346629400 Mon Sep 17 00:00:00 2001 From: "Moh.Hassan" Date: Sat, 22 Jun 2019 02:24:48 +0200 Subject: [PATCH 2/4] Fix Xunit warning: 'Skipping test case with duplicate ID' --- tests/CommandLine.Tests/Unit/Core/TypeConverterTests.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/CommandLine.Tests/Unit/Core/TypeConverterTests.cs b/tests/CommandLine.Tests/Unit/Core/TypeConverterTests.cs index 90782b4b..90fbc3f5 100644 --- a/tests/CommandLine.Tests/Unit/Core/TypeConverterTests.cs +++ b/tests/CommandLine.Tests/Unit/Core/TypeConverterTests.cs @@ -50,8 +50,8 @@ public static IEnumerable ChangeType_scalars_source new object[] {((long) int.MinValue - 1).ToString(), typeof (int), true, null}, new object[] {"1", typeof (uint), false, (uint) 1}, - new object[] {"0", typeof (uint), false, (uint) 0}, - new object[] {"-1", typeof (uint), true, null}, + // new object[] {"0", typeof (uint), false, (uint) 0}, //cause warning: Skipping test case with duplicate ID + // new object[] {"-1", typeof (uint), true, null}, //cause warning: Skipping test case with duplicate ID new object[] {uint.MaxValue.ToString(), typeof (uint), false, uint.MaxValue}, new object[] {uint.MinValue.ToString(), typeof (uint), false, uint.MinValue}, new object[] {((long) uint.MaxValue + 1).ToString(), typeof (uint), true, null}, From 39734b3e6732da3a8731945a8f1922989f698213 Mon Sep 17 00:00:00 2001 From: "Moh.Hassan" Date: Sat, 22 Jun 2019 02:25:50 +0200 Subject: [PATCH 3/4] Fix warning xUnit1014: 'MemberData should use nameof operator to reference member' --- tests/CommandLine.Tests/Unit/UnParserExtensionsTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/CommandLine.Tests/Unit/UnParserExtensionsTests.cs b/tests/CommandLine.Tests/Unit/UnParserExtensionsTests.cs index 461fc969..8ff702a5 100644 --- a/tests/CommandLine.Tests/Unit/UnParserExtensionsTests.cs +++ b/tests/CommandLine.Tests/Unit/UnParserExtensionsTests.cs @@ -39,7 +39,7 @@ public static void UnParsing_immutable_instance_returns_command_line(Immutable_S } [Theory] - [MemberData("UnParseDataHidden")] + [MemberData(nameof(UnParseDataHidden))] public static void Unparsing_hidden_option_returns_command_line(Hidden_Option options, bool showHidden, string result) { new Parser() From 18042c38d0dd4810cac8ba7aaf949988b7f49c8c Mon Sep 17 00:00:00 2001 From: "Moh.Hassan" Date: Fri, 28 Jun 2019 16:19:25 +0200 Subject: [PATCH 4/4] Modify hard-wired copyrigt and heading constants to be platform independent and testsuit independent --- tests/CommandLine.Tests/Unit/ParserTests.cs | 97 ++++--------------- .../Unit/Text/HelpTextTests.cs | 53 +++------- 2 files changed, 32 insertions(+), 118 deletions(-) diff --git a/tests/CommandLine.Tests/Unit/ParserTests.cs b/tests/CommandLine.Tests/Unit/ParserTests.cs index 4df56eac..9d6e56fb 100644 --- a/tests/CommandLine.Tests/Unit/ParserTests.cs +++ b/tests/CommandLine.Tests/Unit/ParserTests.cs @@ -8,6 +8,7 @@ using CommandLine.Tests.Fakes; using FluentAssertions; using Xunit; +using CommandLine.Text; namespace CommandLine.Tests.Unit { @@ -340,13 +341,8 @@ public void Explicit_version_request_generates_version_info_screen() // Verify outcome result.Length.Should().BeGreaterThan(0); var lines = result.ToNotEmptyLines().TrimStringArray(); - lines.Should().HaveCount(x => x == 1); -#if !PLATFORM_DOTNET - lines[0].Should().StartWithEquivalent("CommandLine"); -#else - // Takes the name of the xUnit test program - lines[0].Should().StartWithEquivalent("testhost"); -#endif + lines.Should().HaveCount(x => x == 1); + lines[0].Should().Be(HeadingInfo.Default.ToString()); // Teardown } @@ -364,14 +360,8 @@ public void Implicit_help_screen_in_verb_scenario() // Verify outcome result.Length.Should().BeGreaterThan(0); var lines = result.ToNotEmptyLines().TrimStringArray(); -#if !PLATFORM_DOTNET - lines[0].Should().StartWithEquivalent("CommandLine"); - lines[1].Should().BeEquivalentTo("Copyright (c) 2005 - 2018 Giacomo Stelluti Scala & Contributors"); -#else - // Takes the name of the xUnit test program - lines[0].Should().StartWithEquivalent("testhost"); - lines[1].Should().StartWithEquivalent("© Microsoft Corporation"); -#endif + lines[0].Should().Be(HeadingInfo.Default.ToString()); + lines[1].Should().Be(CopyrightInfo.Default.ToString()); lines[2].Should().BeEquivalentTo("ERROR(S):"); lines[3].Should().BeEquivalentTo("No verb selected."); lines[4].Should().BeEquivalentTo("add Add file contents to the index."); @@ -395,14 +385,8 @@ public void Double_dash_help_dispalys_verbs_index_in_verbs_scenario() // Verify outcome var lines = result.ToNotEmptyLines().TrimStringArray(); -#if !PLATFORM_DOTNET - lines[0].Should().StartWithEquivalent("CommandLine"); - lines[1].Should().BeEquivalentTo("Copyright (c) 2005 - 2018 Giacomo Stelluti Scala & Contributors"); -#else - // Takes the name of the xUnit test program - lines[0].Should().StartWithEquivalent("testhost"); - lines[1].Should().StartWithEquivalent("© Microsoft Corporation"); -#endif + lines[0].Should().Be(HeadingInfo.Default.ToString()); + lines[1].Should().Be(CopyrightInfo.Default.ToString()); lines[2].Should().BeEquivalentTo("add Add file contents to the index."); lines[3].Should().BeEquivalentTo("commit Record changes to the repository."); lines[4].Should().BeEquivalentTo("clone Clone a repository into a new directory."); @@ -428,12 +412,7 @@ public void Explicit_version_request_generates_version_info_screen_in_verbs_scen result.Length.Should().BeGreaterThan(0); var lines = result.ToNotEmptyLines().TrimStringArray(); lines.Should().HaveCount(x => x == 1); -#if !PLATFORM_DOTNET - lines[0].Should().StartWithEquivalent("CommandLine"); -#else - // Takes the name of the xUnit test program - lines[0].Should().StartWithEquivalent("testhost"); -#endif + lines[0].Should().Be(HeadingInfo.Default.ToString()); // Teardown } @@ -450,14 +429,8 @@ public void Errors_of_type_MutuallyExclusiveSetError_are_properly_formatted() // Verify outcome var lines = result.ToNotEmptyLines().TrimStringArray(); -#if !PLATFORM_DOTNET - lines[0].Should().StartWithEquivalent("CommandLine"); - lines[1].Should().BeEquivalentTo("Copyright (c) 2005 - 2018 Giacomo Stelluti Scala & Contributors"); -#else - // Takes the name of the xUnit test program - lines[0].Should().StartWithEquivalent("testhost"); - lines[1].Should().StartWithEquivalent("© Microsoft Corporation"); -#endif + lines[0].Should().Be(HeadingInfo.Default.ToString()); + lines[1].Should().Be(CopyrightInfo.Default.ToString()); lines[2].Should().BeEquivalentTo("ERROR(S):"); lines[3].Should().BeEquivalentTo("Option: 'weburl' is not compatible with: 'ftpurl'."); lines[4].Should().BeEquivalentTo("Option: 'ftpurl' is not compatible with: 'weburl'."); @@ -503,14 +476,8 @@ public void Properly_formatted_help_screen_is_displayed_when_usage_is_defined_in // Verify outcome var lines = result.ToNotEmptyLines().TrimStringArray(); -#if !PLATFORM_DOTNET - lines[0].Should().StartWithEquivalent("CommandLine"); - lines[1].Should().BeEquivalentTo("Copyright (c) 2005 - 2018 Giacomo Stelluti Scala & Contributors"); -#else - // Takes the name of the xUnit test program - lines[0].Should().StartWithEquivalent("testhost"); - lines[1].Should().StartWithEquivalent("© Microsoft Corporation"); -#endif + lines[0].Should().Be(HeadingInfo.Default.ToString()); + lines[1].Should().Be(CopyrightInfo.Default.ToString()); lines[2].Should().BeEquivalentTo("ERROR(S):"); lines[3].Should().BeEquivalentTo("Option 'badoption' is unknown."); lines[4].Should().BeEquivalentTo("USAGE:"); @@ -543,14 +510,8 @@ public void Properly_formatted_help_screen_is_displayed_when_there_is_a_hidden_v // Verify outcome var lines = result.ToNotEmptyLines().TrimStringArray(); -#if !PLATFORM_DOTNET - lines[0].Should().StartWithEquivalent("CommandLine"); - lines[1].Should().BeEquivalentTo("Copyright (c) 2005 - 2018 Giacomo Stelluti Scala & Contributors"); -#else - // Takes the name of the xUnit test program - lines[0].Should().StartWithEquivalent("testhost"); - lines[1].Should().StartWithEquivalent("© Microsoft Corporation"); -#endif + lines[0].Should().Be(HeadingInfo.Default.ToString()); + lines[1].Should().Be(CopyrightInfo.Default.ToString()); lines[2].Should().BeEquivalentTo("ERROR(S):"); lines[3].Should().BeEquivalentTo("No verb selected."); lines[4].Should().BeEquivalentTo("add Add file contents to the index."); @@ -573,14 +534,8 @@ public void Properly_formatted_help_screen_is_displayed_when_there_is_a_hidden_v // Verify outcome var lines = result.ToNotEmptyLines().TrimStringArray(); -#if !PLATFORM_DOTNET - lines[0].Should().StartWithEquivalent("CommandLine"); - lines[1].Should().BeEquivalentTo("Copyright (c) 2005 - 2018 Giacomo Stelluti Scala & Contributors"); -#else - // Takes the name of the xUnit test program - lines[0].Should().StartWithEquivalent("testhost"); - lines[1].Should().StartWithEquivalent("© Microsoft Corporation"); -#endif + lines[0].Should().Be(HeadingInfo.Default.ToString()); + lines[1].Should().Be(CopyrightInfo.Default.ToString()); lines[2].Should().BeEquivalentTo("-f, --force Allow adding otherwise ignored files."); lines[3].Should().BeEquivalentTo("--help Display this help screen."); lines[4].Should().BeEquivalentTo("--version Display version information."); @@ -645,14 +600,8 @@ public void Specific_verb_help_screen_should_be_displayed_regardless_other_argum // Verify outcome var lines = result.ToNotEmptyLines().TrimStringArray(); -#if !PLATFORM_DOTNET - lines[0].Should().StartWithEquivalent("CommandLine"); - lines[1].Should().BeEquivalentTo("Copyright (c) 2005 - 2018 Giacomo Stelluti Scala & Contributors"); -#else - // Takes the name of the xUnit test program - lines[0].Should().StartWithEquivalent("testhost"); - lines[1].Should().StartWithEquivalent("© Microsoft Corporation"); -#endif + lines[0].Should().Be(HeadingInfo.Default.ToString()); + lines[1].Should().Be(CopyrightInfo.Default.ToString()); lines[2].Should().BeEquivalentTo("--no-hardlinks Optimize the cloning process from a repository on a local"); lines[3].Should().BeEquivalentTo("filesystem by copying files."); lines[4].Should().BeEquivalentTo("-q, --quiet Suppress summary message."); @@ -719,14 +668,8 @@ public void Properly_formatted_help_screen_excludes_help_as_unknown_option() // Verify outcome var lines = result.ToNotEmptyLines().TrimStringArray(); -#if !PLATFORM_DOTNET - lines[0].Should().StartWithEquivalent("CommandLine"); - lines[1].Should().BeEquivalentTo("Copyright (c) 2005 - 2018 Giacomo Stelluti Scala & Contributors"); -#else - // Takes the name of the xUnit test program - lines[0].Should().StartWithEquivalent("testhost"); - lines[1].Should().StartWithEquivalent("© Microsoft Corporation"); -#endif + lines[0].Should().Be(HeadingInfo.Default.ToString()); + lines[1].Should().Be(CopyrightInfo.Default.ToString()); lines[2].Should().BeEquivalentTo("ERROR(S):"); lines[3].Should().BeEquivalentTo("Option 'bad-arg' is unknown."); lines[4].Should().BeEquivalentTo("--no-hardlinks Optimize the cloning process from a repository on a local"); diff --git a/tests/CommandLine.Tests/Unit/Text/HelpTextTests.cs b/tests/CommandLine.Tests/Unit/Text/HelpTextTests.cs index d01630cb..bd2148a2 100644 --- a/tests/CommandLine.Tests/Unit/Text/HelpTextTests.cs +++ b/tests/CommandLine.Tests/Unit/Text/HelpTextTests.cs @@ -324,14 +324,9 @@ public void Invoke_AutoBuild_for_Options_returns_appropriate_formatted_text() // Verify outcome var lines = helpText.ToString().ToNotEmptyLines().TrimStringArray(); -#if !PLATFORM_DOTNET - lines[0].Should().StartWithEquivalent("CommandLine"); - lines[1].Should().StartWithEquivalent("Copyright (c)"); -#else - // Takes the name of the xUnit test program - lines[0].Should().StartWithEquivalent("testhost"); - lines[1].Should().StartWithEquivalent("© Microsoft Corporation"); -#endif + + lines[0].Should().Be(HeadingInfo.Default.ToString()); + lines[1].Should().Be(CopyrightInfo.Default.ToString()); lines[2].Should().BeEquivalentTo("ERROR(S):"); lines[3].Should().BeEquivalentTo("Token 'badtoken' is not recognized."); lines[4].Should().BeEquivalentTo("A sequence option 'i' is defined with fewer or more items than required."); @@ -360,14 +355,8 @@ public void Invoke_AutoBuild_for_Verbs_with_specific_verb_returns_appropriate_fo // Verify outcome var lines = helpText.ToString().ToNotEmptyLines().TrimStringArray(); -#if !PLATFORM_DOTNET - lines[0].Should().StartWithEquivalent("CommandLine"); - lines[1].Should().StartWithEquivalent("Copyright (c)"); -#else - // Takes the name of the xUnit test program - lines[0].Should().StartWithEquivalent("testhost"); - lines[1].Should().StartWithEquivalent("© Microsoft Corporation"); -#endif + lines[0].Should().Be(HeadingInfo.Default.ToString()); + lines[1].Should().Be(CopyrightInfo.Default.ToString()); lines[2].Should().BeEquivalentTo("-p, --patch Use the interactive patch selection interface to chose which"); lines[3].Should().BeEquivalentTo("changes to commit."); lines[4].Should().BeEquivalentTo("--amend Used to amend the tip of the current branch."); @@ -393,14 +382,8 @@ public void Invoke_AutoBuild_for_Verbs_with_specific_verb_returns_appropriate_fo // Verify outcome var lines = helpText.ToString().ToNotEmptyLines().TrimStringArray(); -#if !PLATFORM_DOTNET - lines[0].Should().StartWithEquivalent("CommandLine"); - lines[1].Should().BeEquivalentTo("Copyright (c) 2005 - 2018 Giacomo Stelluti Scala & Contributors"); -#else - // Takes the name of the xUnit test program - lines[0].Should().StartWithEquivalent("testhost"); - lines[1].Should().StartWithEquivalent("© Microsoft Corporation"); -#endif + lines[0].Should().Be(HeadingInfo.Default.ToString()); + lines[1].Should().Be(CopyrightInfo.Default.ToString()); lines[2].Should().BeEquivalentTo("-p, --patch Use the interactive patch selection interface to chose which changes to commit."); lines[3].Should().BeEquivalentTo("--amend Used to amend the tip of the current branch."); lines[4].Should().BeEquivalentTo("-m, --message Use the given message as the commit message."); @@ -425,14 +408,8 @@ public void Invoke_AutoBuild_for_Verbs_with_unknown_verb_returns_appropriate_for // Verify outcome var lines = helpText.ToString().ToNotEmptyLines().TrimStringArray(); -#if !PLATFORM_DOTNET - lines[0].Should().StartWithEquivalent("CommandLine"); - lines[1].Should().StartWithEquivalent("Copyright (c)"); -#else - // Takes the name of the xUnit test program - lines[0].Should().StartWithEquivalent("testhost"); - lines[1].Should().StartWithEquivalent("© Microsoft Corporation"); -#endif + lines[0].Should().Be(HeadingInfo.Default.ToString()); + lines[1].Should().Be(CopyrightInfo.Default.ToString()); lines[2].Should().BeEquivalentTo("add Add file contents to the index."); lines[3].Should().BeEquivalentTo("commit Record changes to the repository."); lines[4].Should().BeEquivalentTo("clone Clone a repository into a new directory."); @@ -510,15 +487,9 @@ public void Invoke_AutoBuild_for_Options_with_Usage_returns_appropriate_formatte // Verify outcome var text = helpText.ToString(); - var lines = text.ToNotEmptyLines().Select(x=>x.Trim()).ToArray(); -#if !PLATFORM_DOTNET - lines[0].Should().StartWithEquivalent("CommandLine"); - lines[1].Should().StartWithEquivalent("Copyright (c)"); -#else - // Takes the name of the xUnit test program - lines[0].Should().StartWithEquivalent("testhost"); - lines[1].Should().StartWithEquivalent("© Microsoft Corporation"); -#endif + var lines = text.ToNotEmptyLines().TrimStringArray(); + lines[0].Should().Be(HeadingInfo.Default.ToString()); + lines[1].Should().Be(CopyrightInfo.Default.ToString()); lines[2].Should().BeEquivalentTo("ERROR(S):"); lines[3].Should().BeEquivalentTo("Token 'badtoken' is not recognized."); lines[4].Should().BeEquivalentTo("USAGE:");