public void Parse_ValuePresent_ShouldAddError() { var parser = new BooleanOptionParser(typeof(DataTypesCommandOptions).GetProperty("Boolean"), "boolean"); var tokens = new List <Token> { new OptionToken("boolean") { OptionValues = { "value" } } }; var parseResult = new ParseResult(); parseResult.CommandOptions = new DataTypesCommandOptions(); parser.Parse(tokens, parseResult); parseResult.HasErrors.Should().BeTrue(); parseResult.Errors.Should().HaveCount(1); parseResult.Errors[0].Should().BeOfType <InvalidOptionError>(); var error = (InvalidOptionError)parseResult.Errors[0]; error.OptionName.Should().Be("boolean"); error.GetErrorMessage().Should().Be("The option --boolean is invalid: This option does not support any values."); }
public void Parse_OptionNotPresent_ShouldSetTargetPropertyToTrue() { var parser = new BooleanOptionParser(typeof(DataTypesCommandOptions).GetProperty("Boolean"), "boolean"); var tokens = new List <Token>(); var parseResult = new ParseResult(); var dataTypesCommandOptions = new DataTypesCommandOptions(); parseResult.CommandOptions = dataTypesCommandOptions; parser.Parse(tokens, parseResult); dataTypesCommandOptions.Boolean.Should().BeFalse(); }