Skip to content

[main] Test has incorrect errors for -x 1 2 3 4 #2392

Open
@KathleenDollard

Description

@KathleenDollard

The test I used to confirm unexpected behavior

The test is:

      [Fact]
      public void When_option_arguments_are_greater_than_maximum_arity_then_an_error_is_returned()
      {
          var command = new CliCommand("the-command")
                  {
                      new CliOption<int[]>("-x") { Arity = new ArgumentArity(2, 3)}
                  };

          var parseResult = CliParser.Parse(command, "-x 1 2 3 4");
          parseResult.Errors
                     .Select(e => e.Message)
                     .Should()
                     .Contain(LocalizationResources.UnrecognizedCommandOrArgument("4"));
      }

I modified the test only to get an interim variable for parseResult,

When I do this, the error list is

image

I encountered this because for Powderhouse I encountered issues with options with collection types and I believe I am using the same or funcionally equivalent code - and this test passes. In exploring why my new tests were failing, I realized this test does not appear to be succeeding at what the CLI and the commandline request.

I believe this test should result in a single parse error - an unexpected argument only on the 4.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions