mirror of
https://github.com/Tyrrrz/CliFx.git
synced 2025-10-25 15:19:17 +00:00
Throw when a required option is set but doesn't have a value
Closes #47
This commit is contained in:
@@ -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()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user