Throw when a required option is set but doesn't have a value

Closes #47
This commit is contained in:
Alexey Golub
2020-04-16 16:02:21 +03:00
parent fdd39855ad
commit 8c3b8d1f49
3 changed files with 34 additions and 16 deletions

View File

@@ -933,7 +933,7 @@ namespace CliFx.Tests
}
[Fact]
public void Property_annotated_as_a_required_option_must_always_be_bound_to_some_value()
public void Property_annotated_as_a_required_option_must_always_be_set()
{
// Arrange
var schema = ApplicationSchema.Resolve(new[] {typeof(RequiredOptionCommand)});
@@ -946,6 +946,20 @@ namespace CliFx.Tests
Assert.Throws<CliFxException>(() => schema.InitializeEntryPoint(input));
}
[Fact]
public void Property_annotated_as_a_required_option_must_always_be_bound_to_some_value()
{
// Arrange
var schema = ApplicationSchema.Resolve(new[] {typeof(RequiredOptionCommand)});
var input = new CommandLineInputBuilder()
.AddOption(nameof(RequiredOptionCommand.OptionB))
.Build();
// Act & assert
Assert.Throws<CliFxException>(() => schema.InitializeEntryPoint(input));
}
[Fact]
public void Property_annotated_as_parameter_is_bound_directly_from_argument_value_according_to_the_order()
{