public SimpleOptionRecord( string name, object defaultVal, OptionValidator validator, OptionCoercer coercer, AbstractStringSerializer serializer) : base(name, defaultVal, validator, coercer) { Serializer = serializer; }
public AbstractOptionRecord(string name, object defaultVal, OptionValidator validator, OptionCoercer coercer) { Name = name; Validator = validator; Coercer = coercer; Default = defaultVal; }
public void validateValidOptionTest() { OptionValidator validator = new OptionValidator(); Option opt = new Option(1, 1); try { validator.validate(opt); Assert.IsTrue(true); } catch (ValidatorException) { Assert.IsTrue(false); } }
private ICommandLineOptionFluent <T> SetupInternal <T>(string shortOption, string longOption) { var argOption = this.OptionFactory.CreateOption <T>(shortOption, longOption); if (argOption == null) { throw new InvalidOperationException("OptionFactory is producing unexpected results."); } OptionValidator.Validate(argOption); this.Options.Add(argOption); return(argOption); }
private ICommandLineOptionFluent <T> SetupInternal <T>(string shortOption, string longOption) { var argOption = this.OptionFactory.CreateOption <T>(shortOption, longOption); if (argOption == null) { throw new InvalidOperationException("OptionFactory is producing unexpected results."); } OptionValidator.Validate(argOption, Parser.IsCaseSensitive ? StringComparison.CurrentCulture : StringComparison.CurrentCultureIgnoreCase); _options.Add(argOption); return(argOption); }
/** * Creates an Option using the specified parameters. * * @param opt short representation of the option * @param longOpt the long representation of the option * @param hasArg specifies whether the Option takes an argument or not * @param description describes the function of the option * * @throws IllegalArgumentException if there are any non valid * Option characters in <code>opt</code>. */ public Option(string opt, string longOpt, bool hasArg, string description) { // ensure that the option is valid OptionValidator.ValidateOption(opt); this.opt = opt; this.longOpt = longOpt; // if hasArg is set then the number of arguments is 1 if (hasArg) { this.numberOfArgs = 1; } this.description = description; }
public void validateInvalidReferenceTest() { OptionValidator validator = new OptionValidator(); Option opt = new Option(1, 1); opt = null; try { validator.validate(opt); Assert.IsTrue(false); } catch (ValidatorException exc) { Assert.IsTrue(true); Assert.AreEqual(exc.Message, "Option is null pointer"); } }
static void Main() { CandidateValidator validatorCandidate = new CandidateValidator(); CandidateFileRepository repositoryCandidate = new CandidateFileRepository(validatorCandidate, "../../Data/Candidates.txt"); CandidateController controllerCandidate = new CandidateController(repositoryCandidate); DepartmentValidator validatorDepartment = new DepartmentValidator(); DepartmentFileRepository repositoryDepartment = new DepartmentFileRepository(validatorDepartment, "../../Data/Departments.txt"); DepartmentController controllerDepartment = new DepartmentController(repositoryDepartment); OptionValidator validatorOption = new OptionValidator(); OptionFileRepository repositoryOption = new OptionFileRepository(validatorOption, "../../Data/Options.txt", repositoryDepartment, repositoryCandidate); OptionController controllerOption = new OptionController(repositoryOption); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new HomePage( new CandidateView(controllerCandidate), new DepartmentView(controllerDepartment), new OptionView(controllerOption, controllerCandidate, controllerDepartment))); }
public void OptionValidatorTest() { var optionValidator = new OptionValidator(); var option = new Option(); ValidationResults result = optionValidator.Validate(option); }
/** * Constructs a new <code>Builder</code> with the minimum * required parameters for an <code>Option</code> instance. * * @param opt short representation of the option * @throws IllegalArgumentException if there are any non valid Option characters in {@code opt} */ public OptionBuilder(string opt) { OptionValidator.ValidateOption(opt); this.opt = opt; }