Skip to content

Commit 8579025

Browse files
authored
Test maintainance: add missed tests and removing xUnit1013 warning (#462)
* 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
1 parent 4d69a38 commit 8579025

File tree

4 files changed

+53
-138
lines changed

4 files changed

+53
-138
lines changed

tests/CommandLine.Tests/Unit/Core/TypeConverterTests.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ public static IEnumerable<object[]> ChangeType_scalars_source
5050
new object[] {((long) int.MinValue - 1).ToString(), typeof (int), true, null},
5151

5252
new object[] {"1", typeof (uint), false, (uint) 1},
53-
new object[] {"0", typeof (uint), false, (uint) 0},
54-
new object[] {"-1", typeof (uint), true, null},
53+
// new object[] {"0", typeof (uint), false, (uint) 0}, //cause warning: Skipping test case with duplicate ID
54+
// new object[] {"-1", typeof (uint), true, null}, //cause warning: Skipping test case with duplicate ID
5555
new object[] {uint.MaxValue.ToString(), typeof (uint), false, uint.MaxValue},
5656
new object[] {uint.MinValue.ToString(), typeof (uint), false, uint.MinValue},
5757
new object[] {((long) uint.MaxValue + 1).ToString(), typeof (uint), true, null},

tests/CommandLine.Tests/Unit/ParserTests.cs

+30-87
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
using CommandLine.Tests.Fakes;
99
using FluentAssertions;
1010
using Xunit;
11+
using CommandLine.Text;
1112

1213
namespace CommandLine.Tests.Unit
1314
{
@@ -326,7 +327,7 @@ public void Explicit_version_request_generates_version_requested_error()
326327
// Teardown
327328
}
328329

329-
//[Fact]
330+
[Fact]
330331
public void Explicit_version_request_generates_version_info_screen()
331332
{
332333
// Fixture setup
@@ -340,17 +341,12 @@ public void Explicit_version_request_generates_version_info_screen()
340341
// Verify outcome
341342
result.Length.Should().BeGreaterThan(0);
342343
var lines = result.ToNotEmptyLines().TrimStringArray();
343-
lines.Should().HaveCount(x => x == 1);
344-
#if !PLATFORM_DOTNET
345-
lines[0].Should().StartWithEquivalent("CommandLine");
346-
#else
347-
// Takes the name of the xUnit test program
348-
lines[0].Should().StartWithEquivalent("xUnit");
349-
#endif
344+
lines.Should().HaveCount(x => x == 1);
345+
lines[0].Should().Be(HeadingInfo.Default.ToString());
350346
// Teardown
351347
}
352348

353-
//[Fact]
349+
[Fact]
354350
public void Implicit_help_screen_in_verb_scenario()
355351
{
356352
// Fixture setup
@@ -364,14 +360,8 @@ public void Implicit_help_screen_in_verb_scenario()
364360
// Verify outcome
365361
result.Length.Should().BeGreaterThan(0);
366362
var lines = result.ToNotEmptyLines().TrimStringArray();
367-
#if !PLATFORM_DOTNET
368-
lines[0].Should().StartWithEquivalent("CommandLine");
369-
lines[1].Should().BeEquivalentTo("Copyright (c) 2005 - 2018 Giacomo Stelluti Scala & Contributors");
370-
#else
371-
// Takes the name of the xUnit test program
372-
lines[0].Should().StartWithEquivalent("xUnit");
373-
lines[1].Should().StartWithEquivalent("Copyright (C) Outercurve Foundation");
374-
#endif
363+
lines[0].Should().Be(HeadingInfo.Default.ToString());
364+
lines[1].Should().Be(CopyrightInfo.Default.ToString());
375365
lines[2].Should().BeEquivalentTo("ERROR(S):");
376366
lines[3].Should().BeEquivalentTo("No verb selected.");
377367
lines[4].Should().BeEquivalentTo("add Add file contents to the index.");
@@ -382,7 +372,7 @@ public void Implicit_help_screen_in_verb_scenario()
382372
// Teardown
383373
}
384374

385-
//[Fact]
375+
[Fact]
386376
public void Double_dash_help_dispalys_verbs_index_in_verbs_scenario()
387377
{
388378
// Fixture setup
@@ -395,14 +385,8 @@ public void Double_dash_help_dispalys_verbs_index_in_verbs_scenario()
395385

396386
// Verify outcome
397387
var lines = result.ToNotEmptyLines().TrimStringArray();
398-
#if !PLATFORM_DOTNET
399-
lines[0].Should().StartWithEquivalent("CommandLine");
400-
lines[1].Should().BeEquivalentTo("Copyright (c) 2005 - 2018 Giacomo Stelluti Scala & Contributors");
401-
#else
402-
// Takes the name of the xUnit test program
403-
lines[0].Should().StartWithEquivalent("xUnit");
404-
lines[1].Should().StartWithEquivalent("Copyright (C) Outercurve Foundation");
405-
#endif
388+
lines[0].Should().Be(HeadingInfo.Default.ToString());
389+
lines[1].Should().Be(CopyrightInfo.Default.ToString());
406390
lines[2].Should().BeEquivalentTo("add Add file contents to the index.");
407391
lines[3].Should().BeEquivalentTo("commit Record changes to the repository.");
408392
lines[4].Should().BeEquivalentTo("clone Clone a repository into a new directory.");
@@ -411,7 +395,7 @@ public void Double_dash_help_dispalys_verbs_index_in_verbs_scenario()
411395
// Teardown
412396
}
413397

414-
//[Theory]
398+
[Theory]
415399
[InlineData("--version")]
416400
[InlineData("version")]
417401
public void Explicit_version_request_generates_version_info_screen_in_verbs_scenario(string command)
@@ -428,16 +412,11 @@ public void Explicit_version_request_generates_version_info_screen_in_verbs_scen
428412
result.Length.Should().BeGreaterThan(0);
429413
var lines = result.ToNotEmptyLines().TrimStringArray();
430414
lines.Should().HaveCount(x => x == 1);
431-
#if !PLATFORM_DOTNET
432-
lines[0].Should().StartWithEquivalent("CommandLine");
433-
#else
434-
// Takes the name of the xUnit test program
435-
lines[0].Should().StartWithEquivalent("xUnit");
436-
#endif
415+
lines[0].Should().Be(HeadingInfo.Default.ToString());
437416
// Teardown
438417
}
439418

440-
//[Fact]
419+
[Fact]
441420
public void Errors_of_type_MutuallyExclusiveSetError_are_properly_formatted()
442421
{
443422
// Fixture setup
@@ -450,14 +429,8 @@ public void Errors_of_type_MutuallyExclusiveSetError_are_properly_formatted()
450429

451430
// Verify outcome
452431
var lines = result.ToNotEmptyLines().TrimStringArray();
453-
#if !PLATFORM_DOTNET
454-
lines[0].Should().StartWithEquivalent("CommandLine");
455-
lines[1].Should().BeEquivalentTo("Copyright (c) 2005 - 2018 Giacomo Stelluti Scala & Contributors");
456-
#else
457-
// Takes the name of the xUnit test program
458-
lines[0].Should().StartWithEquivalent("xUnit");
459-
lines[1].Should().StartWithEquivalent("Copyright (C) Outercurve Foundation");
460-
#endif
432+
lines[0].Should().Be(HeadingInfo.Default.ToString());
433+
lines[1].Should().Be(CopyrightInfo.Default.ToString());
461434
lines[2].Should().BeEquivalentTo("ERROR(S):");
462435
lines[3].Should().BeEquivalentTo("Option: 'weburl' is not compatible with: 'ftpurl'.");
463436
lines[4].Should().BeEquivalentTo("Option: 'ftpurl' is not compatible with: 'weburl'.");
@@ -485,7 +458,7 @@ public void Explicit_help_request_with_specific_verb_generates_help_screen()
485458
// Teardown
486459
}
487460

488-
//[Fact]
461+
[Fact]
489462
public void Properly_formatted_help_screen_is_displayed_when_usage_is_defined_in_verb_scenario()
490463
{
491464
// Fixture setup
@@ -503,14 +476,8 @@ public void Properly_formatted_help_screen_is_displayed_when_usage_is_defined_in
503476

504477
// Verify outcome
505478
var lines = result.ToNotEmptyLines().TrimStringArray();
506-
#if !PLATFORM_DOTNET
507-
lines[0].Should().StartWithEquivalent("CommandLine");
508-
lines[1].Should().BeEquivalentTo("Copyright (c) 2005 - 2018 Giacomo Stelluti Scala & Contributors");
509-
#else
510-
// Takes the name of the xUnit test program
511-
lines[0].Should().StartWithEquivalent("xUnit");
512-
lines[1].Should().StartWithEquivalent("Copyright (C) Outercurve Foundation");
513-
#endif
479+
lines[0].Should().Be(HeadingInfo.Default.ToString());
480+
lines[1].Should().Be(CopyrightInfo.Default.ToString());
514481
lines[2].Should().BeEquivalentTo("ERROR(S):");
515482
lines[3].Should().BeEquivalentTo("Option 'badoption' is unknown.");
516483
lines[4].Should().BeEquivalentTo("USAGE:");
@@ -530,7 +497,7 @@ public void Properly_formatted_help_screen_is_displayed_when_usage_is_defined_in
530497
// Teardown
531498
}
532499

533-
//[Fact]
500+
[Fact]
534501
public void Properly_formatted_help_screen_is_displayed_when_there_is_a_hidden_verb()
535502
{
536503
// Fixture setup
@@ -543,14 +510,8 @@ public void Properly_formatted_help_screen_is_displayed_when_there_is_a_hidden_v
543510

544511
// Verify outcome
545512
var lines = result.ToNotEmptyLines().TrimStringArray();
546-
#if !PLATFORM_DOTNET
547-
lines[0].Should().StartWithEquivalent("CommandLine");
548-
lines[1].Should().BeEquivalentTo("Copyright (c) 2005 - 2018 Giacomo Stelluti Scala & Contributors");
549-
#else
550-
// Takes the name of the xUnit test program
551-
lines[0].Should().StartWithEquivalent("xUnit");
552-
lines[1].Should().StartWithEquivalent("Copyright (C) Outercurve Foundation");
553-
#endif
513+
lines[0].Should().Be(HeadingInfo.Default.ToString());
514+
lines[1].Should().Be(CopyrightInfo.Default.ToString());
554515
lines[2].Should().BeEquivalentTo("ERROR(S):");
555516
lines[3].Should().BeEquivalentTo("No verb selected.");
556517
lines[4].Should().BeEquivalentTo("add Add file contents to the index.");
@@ -560,7 +521,7 @@ public void Properly_formatted_help_screen_is_displayed_when_there_is_a_hidden_v
560521
// Teardown
561522
}
562523

563-
//[Fact]
524+
[Fact]
564525
public void Properly_formatted_help_screen_is_displayed_when_there_is_a_hidden_verb_selected_usage_displays_with_hidden_option()
565526
{
566527
// Fixture setup
@@ -573,14 +534,8 @@ public void Properly_formatted_help_screen_is_displayed_when_there_is_a_hidden_v
573534

574535
// Verify outcome
575536
var lines = result.ToNotEmptyLines().TrimStringArray();
576-
#if !PLATFORM_DOTNET
577-
lines[0].Should().StartWithEquivalent("CommandLine");
578-
lines[1].Should().BeEquivalentTo("Copyright (c) 2005 - 2018 Giacomo Stelluti Scala & Contributors");
579-
#else
580-
// Takes the name of the xUnit test program
581-
lines[0].Should().StartWithEquivalent("xUnit");
582-
lines[1].Should().StartWithEquivalent("Copyright (C) Outercurve Foundation");
583-
#endif
537+
lines[0].Should().Be(HeadingInfo.Default.ToString());
538+
lines[1].Should().Be(CopyrightInfo.Default.ToString());
584539
lines[2].Should().BeEquivalentTo("-f, --force Allow adding otherwise ignored files.");
585540
lines[3].Should().BeEquivalentTo("--help Display this help screen.");
586541
lines[4].Should().BeEquivalentTo("--version Display version information.");
@@ -627,7 +582,7 @@ public void Parse_options_when_given_hidden_verb_with_hidden_option()
627582
// Teardown
628583
}
629584

630-
//[Fact]
585+
[Fact]
631586
public void Specific_verb_help_screen_should_be_displayed_regardless_other_argument()
632587
{
633588
// Fixture setup
@@ -645,14 +600,8 @@ public void Specific_verb_help_screen_should_be_displayed_regardless_other_argum
645600

646601
// Verify outcome
647602
var lines = result.ToNotEmptyLines().TrimStringArray();
648-
#if !PLATFORM_DOTNET
649-
lines[0].Should().StartWithEquivalent("CommandLine");
650-
lines[1].Should().BeEquivalentTo("Copyright (c) 2005 - 2018 Giacomo Stelluti Scala & Contributors");
651-
#else
652-
// Takes the name of the xUnit test program
653-
lines[0].Should().StartWithEquivalent("xUnit");
654-
lines[1].Should().StartWithEquivalent("Copyright (C) Outercurve Foundation");
655-
#endif
603+
lines[0].Should().Be(HeadingInfo.Default.ToString());
604+
lines[1].Should().Be(CopyrightInfo.Default.ToString());
656605
lines[2].Should().BeEquivalentTo("--no-hardlinks Optimize the cloning process from a repository on a local");
657606
lines[3].Should().BeEquivalentTo("filesystem by copying files.");
658607
lines[4].Should().BeEquivalentTo("-q, --quiet Suppress summary message.");
@@ -701,7 +650,7 @@ public void When_IgnoreUnknownArguments_is_set_valid_unknown_arguments_avoid_a_f
701650
// Teardown
702651
}
703652

704-
//[Fact]
653+
[Fact]
705654
public void Properly_formatted_help_screen_excludes_help_as_unknown_option()
706655
{
707656
// Fixture setup
@@ -719,14 +668,8 @@ public void Properly_formatted_help_screen_excludes_help_as_unknown_option()
719668

720669
// Verify outcome
721670
var lines = result.ToNotEmptyLines().TrimStringArray();
722-
#if !PLATFORM_DOTNET
723-
lines[0].Should().StartWithEquivalent("CommandLine");
724-
lines[1].Should().BeEquivalentTo("Copyright (c) 2005 - 2018 Giacomo Stelluti Scala & Contributors");
725-
#else
726-
// Takes the name of the xUnit test program
727-
lines[0].Should().StartWithEquivalent("xUnit");
728-
lines[1].Should().StartWithEquivalent("Copyright (C) Outercurve Foundation");
729-
#endif
671+
lines[0].Should().Be(HeadingInfo.Default.ToString());
672+
lines[1].Should().Be(CopyrightInfo.Default.ToString());
730673
lines[2].Should().BeEquivalentTo("ERROR(S):");
731674
lines[3].Should().BeEquivalentTo("Option 'bad-arg' is unknown.");
732675
lines[4].Should().BeEquivalentTo("--no-hardlinks Optimize the cloning process from a repository on a local");

0 commit comments

Comments
 (0)