public void WriteGlobalArguments() { // Arrange var application = new KingpinApplication(console); application.Argument("arg1", "arg1 help"); application.Argument("arg2", "arg2 help"); // Act var subject = new HelpGenerator(application, console); var appText = subject.ReadResourceInExecutingAssembly("KingpinNet.Help.ApplicationHelp.liquid"); subject.Generate(writer, appText); // Assert var result = writer.ToString(); output.WriteLine(result); Assert.Contains($"usage: [<args> ...]", result); Assert.Contains($"Args:", result); Assert.Contains($" [<arg1>] arg1 help", result); Assert.Contains($" [<arg2>] arg2 help", result); }
public void ParseFileShouldExistFail() { // Arrange string fileName = Path.GetTempPath() + Guid.NewGuid().ToString() + ".tmp"; var application = new KingpinApplication(consoleMock.Object); string[] args = new[] { fileName }; var arg = application.Argument("file", "").FileExists(); // Act var subject = new Parser(application); Assert.Throws <ParseException>(() => subject.Parse(args)); }
public void ParseDirectoryShouldExistFail() { // Arrange string directory = Path.GetTempPath(); string[] args = new[] { directory + "\\notgonnaexist" }; var application = new KingpinApplication(consoleMock.Object); var arg = application.Argument("directory", "").DirectoryExists(); // Act var subject = new Parser(application); Assert.Throws <ParseException>(() => subject.Parse(args)); }
public void ParseGlobalArgument() { // Arrange string[] args = new[] { "hurray" }; var application = new KingpinApplication(consoleMock.Object); application.Argument("argument", "This is an argument"); // Act var subject = new Parser(application); var result = subject.Parse(args); // Assert Assert.Equal("hurray", result.Result["argument"]); }
public void ParseDirectoryShouldExistSuccess() { // Arrange string directory = Path.GetTempPath(); string[] args = new[] { directory }; var application = new KingpinApplication(consoleMock.Object); application.Argument("directory", "").DirectoryExists(); // Act var subject = new Parser(application); var result = subject.Parse(args); // Assert Assert.Equal(directory, result.Result["directory"]); }
public void ParseFileShouldExistSuccess() { // Arrange string fileName = Path.GetTempPath() + Guid.NewGuid().ToString() + ".tmp"; File.WriteAllText(fileName, "hej"); string[] args = new[] { fileName }; var application = new KingpinApplication(consoleMock.Object); application.Argument("file", "").FileExists(); // Act var subject = new Parser(application); var result = subject.Parse(args); // Assert Assert.Equal(fileName, result.Result["file"]); }