-
Notifications
You must be signed in to change notification settings - Fork 480
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #798 from batzen/fix/issue-776
- Loading branch information
Showing
4 changed files
with
86 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,5 +37,7 @@ artifacts/* | |
*.DotSettings.user | ||
# Visual Studio 2015 cache/options directory | ||
.vs/ | ||
# Rider | ||
.idea/ | ||
|
||
[R|r]elease/** |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
using FluentAssertions; | ||
using Xunit; | ||
|
||
// Issue #776 and #797 | ||
// When IgnoreUnknownArguments is used and there are unknown arguments with explicitly assigned values, other arguments with explicit assigned values should not be influenced. | ||
// The bug only occured when the value was the same for a known and an unknown argument. | ||
|
||
namespace CommandLine.Tests.Unit | ||
{ | ||
public class Issue776Tests | ||
{ | ||
[Theory] | ||
[InlineData("3")] | ||
[InlineData("4")] | ||
public void IgnoreUnknownArguments_should_work_for_all_values(string dummyValue) | ||
{ | ||
var arguments = new[] { "--cols=4", $"--dummy={dummyValue}" }; | ||
var result = new Parser(with => { with.IgnoreUnknownArguments = true; }) | ||
.ParseArguments<Options>(arguments); | ||
|
||
Assert.Empty(result.Errors); | ||
Assert.Equal(ParserResultType.Parsed, result.Tag); | ||
|
||
result.WithParsed(options => | ||
{ | ||
options.Cols.Should().Be(4); | ||
}); | ||
} | ||
|
||
private class Options | ||
{ | ||
[Option("cols", Required = false)] | ||
public int Cols { get; set; } | ||
} | ||
} | ||
} |