BadScript 2
Loading...
Searching...
No Matches
Issue776Tests.cs
Go to the documentation of this file.
1using FluentAssertions;
2using Xunit;
3
4// Issue #776 and #797
5// When IgnoreUnknownArguments is used and there are unknown arguments with explicitly assigned values, other arguments with explicit assigned values should not be influenced.
6// The bug only occured when the value was the same for a known and an unknown argument.
7
9{
10 public class Issue776Tests
11 {
12 [Theory]
13 [InlineData("3")]
14 [InlineData("4")]
16 {
17 var arguments = new[] { "--cols=4", $"--dummy={dummyValue}" };
18 var result = new Parser(with => { with.IgnoreUnknownArguments = true; })
19 .ParseArguments<Options>(arguments);
20
21 Assert.Empty(result.Errors);
22 Assert.Equal(ParserResultType.Parsed, result.Tag);
23
24 result.WithParsed(options =>
25 {
26 options.Cols.Should().Be(4);
27 });
28 }
29
30 private class Options
31 {
32 [Option("cols", Required = false)]
33 public int Cols { get; set; }
34 }
35 }
36}
Provides methods to parse command line arguments.
Definition Parser.cs:21
void IgnoreUnknownArguments_should_work_for_all_values(string dummyValue)
ParserResultType
Discriminator enumeration of CommandLine.ParserResultType derivates.