public void CommandCatagoryWithCatagoryOnSamePropertyThrowArgumentException() { ICommandCatagory <Commands> catagory = ArgumentParser.Create("app").CreateCommandCatagory <Commands>(); Assert.Throws <ArgumentException>(() => catagory.WithCommand(x => x.FlagCommand).WithCommand(x => x.FlagCommand)); Assert.Throws <ArgumentException>(() => catagory.WithCommand(x => x.CommandWithArguments, (sp) => { }).WithCommand(x => x.CommandWithArguments, (sp) => { })); }
public void CommandCatagoryNameMethodSetsName() { ICommandCatagory <NoOptions> cat = ArgumentParser.Create("app").CreateCommandCatagory <NoOptions>(); cat.Name("CustomName"); Assert.Equal("CustomName", cat.CatagoryName); }
public Command(ICreateCommandCatagory catagoryCreator, ICommandCatagory <TOptions> currentCatagory, PropertyInfo property) { if (property.GetMethod == null || property.SetMethod == null) { throw new ArgumentException( $"Property '{property.Name}' must have both a get and set accessor on catagory '{typeof(TOptions).Name}'.", nameof(property)); } _catagoryCreator = catagoryCreator; _currentCatagory = currentCatagory; Property = property; Name(property.Name); }
public void CommandCatagoryWithArgumentIsTypeIArgument_T_() { ICommandCatagory <Commands> catagory = ArgumentParser.Create("app").CreateCommandCatagory <Commands>(); Assert.IsAssignableFrom <ICommand <Commands> >(catagory.WithCommand(x => x.FlagCommand)); }
public void CommandCatagoryWithCommandNotNull() { ICommandCatagory <Commands> catagory = ArgumentParser.Create("app").CreateCommandCatagory <Commands>(); Assert.NotNull(catagory.WithCommand(x => x.FlagCommand)); }