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); }
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); }
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); }
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); }