コード例 #1
0
        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) => { }));
        }
コード例 #2
0
        public void CommandCatagoryNameMethodSetsName()
        {
            ICommandCatagory <NoOptions> cat = ArgumentParser.Create("app").CreateCommandCatagory <NoOptions>();

            cat.Name("CustomName");

            Assert.Equal("CustomName", cat.CatagoryName);
        }
コード例 #3
0
ファイル: Command.cs プロジェクト: watermelonpizza/argparse
        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);
        }
コード例 #4
0
        public void CommandCatagoryWithArgumentIsTypeIArgument_T_()
        {
            ICommandCatagory <Commands> catagory = ArgumentParser.Create("app").CreateCommandCatagory <Commands>();

            Assert.IsAssignableFrom <ICommand <Commands> >(catagory.WithCommand(x => x.FlagCommand));
        }
コード例 #5
0
        public void CommandCatagoryWithCommandNotNull()
        {
            ICommandCatagory <Commands> catagory = ArgumentParser.Create("app").CreateCommandCatagory <Commands>();

            Assert.NotNull(catagory.WithCommand(x => x.FlagCommand));
        }