예제 #1
0
        public void Parse_WithFactoryAndGitVerbsAdd_ParsesAddVerb()
        {
            string[] expected = { "myfile.txt", "otherfile.txt" };
            var      opt      = new OptionsWithGitVerbs();
            var      factory  = new SimpleVerbfactory
            {
                { () => new GitAdd() },
                { typeof(GitCommit), () => new GitCommit("My default message") }
            };
            var parser = new CliParser <OptionsWithGitVerbs>(
                opt, ParserOptions.None, new AutomaticHelpGenerator <OptionsWithGitVerbs>(), factory);

            parser.Parse("add myfile.txt otherfile.txt".Split());
            var actual = opt.Add.Files.ToList();

            CollectionAssert.AreEqual(expected, actual);
        }
예제 #2
0
파일: VerbUnitTest.cs 프로젝트: nemec/clipr
        public void Parse_WithFactoryAndGitVerbsAdd_ParsesAddVerb()
        {
            string[] expected = { "myfile.txt", "otherfile.txt" };
            var opt = new OptionsWithGitVerbs();
            var factory = new SimpleVerbfactory
            {
                { () => new GitAdd() },
                { typeof(GitCommit), () => new GitCommit("My default message") }
            };
            var parser = new CliParser<OptionsWithGitVerbs>(
                opt, ParserOptions.None, new AutomaticHelpGenerator<OptionsWithGitVerbs>(), factory);

            parser.Parse("add myfile.txt otherfile.txt".Split());
            var actual = opt.Add.Files.ToList();

            CollectionAssert.AreEqual(expected, actual);
        }
예제 #3
0
파일: VerbUnitTest.cs 프로젝트: nemec/clipr
        public void Parse_WithFactoryAndGitVerbsCommitAndNoMessage_ParsesCommitVerb()
        {
            const string expected = "My default message";
            var opt = new OptionsWithGitVerbs();
            var factory = new SimpleVerbfactory
            {
                { () => new GitAdd() },
                { typeof(GitCommit), () => new GitCommit("My default message") }
            };
            var parser = new CliParser<OptionsWithGitVerbs>(
                opt, ParserOptions.None, new AutomaticHelpGenerator<OptionsWithGitVerbs>(), factory);

            parser.Parse("commit".Split());
            var actual = opt.Commit.CommitMessage;

            Assert.AreEqual(expected, actual);
        }
예제 #4
0
        public void Parse_WithFactoryAndGitVerbsCommitAndMessage_ParsesCommitVerb()
        {
            const string expected = "My message";
            var          opt      = new OptionsWithGitVerbs();
            var          factory  = new SimpleVerbfactory
            {
                { () => new GitAdd() },
                { typeof(GitCommit), () => new GitCommit("My default message") }
            };
            var parser = new CliParser <OptionsWithGitVerbs>(
                opt, ParserOptions.Default, new AutomaticHelpGenerator <OptionsWithGitVerbs>(), factory);

            parser.Parse(new[] { "commit", "-m", "My message" });
            var actual = opt.Commit.CommitMessage;

            Assert.AreEqual(expected, actual);
        }