Exemplo n.º 1
0
        public void Parse_WithFactoryAndVerbHavingNoDefaultConstructor_ParsesVerb()
        {
            const string expected = "myfile.txt";
            var          opt      = new OptionsWithNoDefaultConstructor();
            var          factory  = new SimpleVerbfactory
            {
                { typeof(VerbWithNoDefaultConstructor), () => new VerbWithNoDefaultConstructor("default.txt") }
            };
            var parser = new CliParser <OptionsWithNoDefaultConstructor>(
                opt, ParserOptions.None, new AutomaticHelpGenerator <OptionsWithNoDefaultConstructor>(), factory);

            parser.Parse("add myfile.txt".Split());

            Assert.AreEqual(expected, opt.AddInfo.Filename);
        }
Exemplo n.º 2
0
        public void Parse_WithFactoryAndVerbHavingNoDefaultConstructor_ParsesVerb()
        {
            const string expected = "myfile.txt";
            var opt = new OptionsWithNoDefaultConstructor();
            var factory = new SimpleVerbfactory
            {
                { typeof(VerbWithNoDefaultConstructor), () => new VerbWithNoDefaultConstructor("default.txt") }
            };
            var parser = new CliParser<OptionsWithNoDefaultConstructor>(
                opt, ParserOptions.None, new AutomaticHelpGenerator<OptionsWithNoDefaultConstructor>(), factory);

            parser.Parse("add myfile.txt".Split());

            Assert.AreEqual(expected, opt.AddInfo.Filename);
        }