Skip to content

Commit

Permalink
Test maintainance: add missed tests and removing xUnit1013 warning (#462
Browse files Browse the repository at this point in the history
)

* Add  test cases ignored in v2.4.3 (18 test case)

* Fix Xunit warning: 'Skipping test case with duplicate ID'

* Fix warning xUnit1014: 'MemberData should use nameof operator to reference member'

* Modify hard-wired copyrigt and heading constants to be platform independent and testsuit independent
  • Loading branch information
moh-hassan authored Jun 30, 2019
1 parent 4d69a38 commit 8579025
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 138 deletions.
4 changes: 2 additions & 2 deletions tests/CommandLine.Tests/Unit/Core/TypeConverterTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ public static IEnumerable<object[]> 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},
Expand Down
117 changes: 30 additions & 87 deletions tests/CommandLine.Tests/Unit/ParserTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using CommandLine.Tests.Fakes;
using FluentAssertions;
using Xunit;
using CommandLine.Text;

namespace CommandLine.Tests.Unit
{
Expand Down Expand Up @@ -326,7 +327,7 @@ public void Explicit_version_request_generates_version_requested_error()
// Teardown
}

//[Fact]
[Fact]
public void Explicit_version_request_generates_version_info_screen()
{
// Fixture setup
Expand All @@ -340,17 +341,12 @@ 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("xUnit");
#endif
lines.Should().HaveCount(x => x == 1);
lines[0].Should().Be(HeadingInfo.Default.ToString());
// Teardown
}

//[Fact]
[Fact]
public void Implicit_help_screen_in_verb_scenario()
{
// Fixture setup
Expand All @@ -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("xUnit");
lines[1].Should().StartWithEquivalent("Copyright (C) Outercurve Foundation");
#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.");
Expand All @@ -382,7 +372,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
Expand All @@ -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("xUnit");
lines[1].Should().StartWithEquivalent("Copyright (C) Outercurve Foundation");
#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.");
Expand All @@ -411,7 +395,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)
Expand All @@ -428,16 +412,11 @@ 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("xUnit");
#endif
lines[0].Should().Be(HeadingInfo.Default.ToString());
// Teardown
}

//[Fact]
[Fact]
public void Errors_of_type_MutuallyExclusiveSetError_are_properly_formatted()
{
// Fixture setup
Expand All @@ -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("xUnit");
lines[1].Should().StartWithEquivalent("Copyright (C) Outercurve Foundation");
#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'.");
Expand Down Expand Up @@ -485,7 +458,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
Expand All @@ -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("xUnit");
lines[1].Should().StartWithEquivalent("Copyright (C) Outercurve Foundation");
#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:");
Expand All @@ -530,7 +497,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
Expand All @@ -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("xUnit");
lines[1].Should().StartWithEquivalent("Copyright (C) Outercurve Foundation");
#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.");
Expand All @@ -560,7 +521,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
Expand All @@ -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("xUnit");
lines[1].Should().StartWithEquivalent("Copyright (C) Outercurve Foundation");
#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.");
Expand Down Expand Up @@ -627,7 +582,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
Expand All @@ -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("xUnit");
lines[1].Should().StartWithEquivalent("Copyright (C) Outercurve Foundation");
#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.");
Expand Down Expand Up @@ -701,7 +650,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
Expand All @@ -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("xUnit");
lines[1].Should().StartWithEquivalent("Copyright (C) Outercurve Foundation");
#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");
Expand Down
Loading

0 comments on commit 8579025

Please sign in to comment.