forked from commandlineparser/commandline
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIssue776Tests.cs
More file actions
36 lines (31 loc) · 1.14 KB
/
Copy pathIssue776Tests.cs
File metadata and controls
36 lines (31 loc) · 1.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
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; }
}
}
}