Throw errors on unrecognized input

Closes #38
Closes #24
This commit is contained in:
Alexey Golub
2020-03-16 14:48:48 +02:00
parent f38bd32510
commit c854f5fb8d
3 changed files with 72 additions and 0 deletions

View File

@@ -1018,5 +1018,37 @@ namespace CliFx.Tests
// Act & assert
Assert.Throws<CliFxException>(() => schema.InitializeEntryPoint(input));
}
[Fact]
public void All_provided_option_arguments_must_be_bound_to_corresponding_properties()
{
// Arrange
var schema = ApplicationSchema.Resolve(new[] {typeof(AllSupportedTypesCommand)});
var input = new CommandLineInputBuilder()
.AddOption("not-a-real-option", "boom")
.AddOption("fake-option", "poof")
.Build();
// Act & assert
Assert.Throws<CliFxException>(() => schema.InitializeEntryPoint(input));
}
[Fact]
public void All_provided_parameter_arguments_must_be_bound_to_corresponding_properties()
{
// Arrange
var schema = ApplicationSchema.Resolve(new[] {typeof(NoParameterCommand)});
var input = new CommandLineInputBuilder()
.AddUnboundArgument("boom")
.AddUnboundArgument("poof")
.AddOption(nameof(NoParameterCommand.OptionA), "foo")
.AddOption(nameof(NoParameterCommand.OptionB), "bar")
.Build();
// Act & assert
Assert.Throws<CliFxException>(() => schema.InitializeEntryPoint(input));
}
}
}