public void PrintNothing() { HelpPrinter helpPrinter = new HelpPrinter(ExecutableName, NoSwitches); helpPrinter.Print(); StringBuilder expectedOutput = new StringBuilder(); expectedOutput.AppendLine(string.Empty); Assert.AreEqual(expectedOutput.ToString(), Output); }
/// <summary> /// Print help for using this executable, including switch usage /// information and descriptions. /// </summary> static void PrintHelp() { HelpPrinter helpPrinter = new HelpPrinter(ExecutableName, Switches, GetHeader()); helpPrinter.Print(); }
public void PrintNonPrintable() { const string Name1 = "s1"; const string Name2 = "s2"; SwitchCollection switches = new SwitchCollection(); switches.Add(Name1); switches.Add(Name2, IsRequired); HelpPrinter helpPrinter = new HelpPrinter(ExecutableName, switches); helpPrinter.Print(); StringBuilder expectedOutput = new StringBuilder(); expectedOutput.AppendLine("Usage: " + ExecutableName + " [-s1] -s2"); Assert.AreEqual(expectedOutput.ToString(), Output); }
public void PrintNoSwitches() { HelpPrinter helpPrinter = new HelpPrinter(ExecutableName, NoSwitches, GetHeader(), GetFooter()); helpPrinter.Print(); StringBuilder expectedOutput = new StringBuilder(); expectedOutput.AppendLine(GetHeader()); expectedOutput.AppendLine(); expectedOutput.AppendLine(GetFooter()); Assert.AreEqual(expectedOutput.ToString(), Output); }
public void PrintNoLongNames() { const string Description1 = "First switch."; const string Description2 = "Second switch. This switch is required."; const string Name1 = "s1"; const string Name2 = "s2"; SwitchCollection switches = new SwitchCollection(); switches.Add(Name1, NoLongName, Description1); switches.Add(Name2, NoLongName, Description2, IsRequired); HelpPrinter helpPrinter = new HelpPrinter(ExecutableName, switches); helpPrinter.Print(); StringBuilder expectedOutput = new StringBuilder(); expectedOutput.AppendLine("Usage: " + ExecutableName + " [-s1] -s2"); expectedOutput.AppendLine(); expectedOutput.AppendLine("-s1 " + Description1); expectedOutput.AppendLine("-s2 " + Description2); Assert.AreEqual(expectedOutput.ToString(), Output); }
public void PrintLongHeaderFooter() { HelpPrinter helpPrinter = new HelpPrinter(ExecutableName, NoSwitches, GetLongHeader(), GetLongFooter()); helpPrinter.Print(); StringBuilder expectedOutput = new StringBuilder(); expectedOutput.AppendLine("------------------------------------------------------------------------------"); expectedOutput.AppendLine("This is the long header."); expectedOutput.AppendLine("It is \"long\" to demonstrate how text is wrapped when it extends beyond the "); expectedOutput.AppendLine("output width of the screen."); expectedOutput.AppendLine("It is printed at the top of the help screen."); expectedOutput.AppendLine("------------------------------------------------------------------------------"); expectedOutput.AppendLine(); expectedOutput.AppendLine("------------------------------------------------------------------------------"); expectedOutput.AppendLine("This is the long footer."); expectedOutput.AppendLine("It is \"long\" to demonstrate how text is wrapped when it extends beyond the "); expectedOutput.AppendLine("output width of the screen."); expectedOutput.AppendLine("It is printed at the bottom of the help screen."); expectedOutput.AppendLine("------------------------------------------------------------------------------"); Assert.AreEqual(expectedOutput.ToString(), Output); }
public void Print() { const string ArgumentName = "arg"; const string Description1 = "First switch."; const string Description2 = "Second switch. This switch is required."; const string Description3 = "Third switch. This switch is required and has an argument."; const string LongName1 = "switch1"; const string LongName2 = "switch2"; const string LongName3 = "switch3"; const string Name1 = "s1"; const string Name2 = "s2"; const string Name3 = "s3"; SwitchCollection switches = new SwitchCollection(); switches.Add(Name1, LongName1, Description1); switches.Add(Name2, LongName2, Description2, IsRequired); switches.Add(Name3, LongName3, Description3, HasArguments, IsRequired, ArgumentName); HelpPrinter helpPrinter = new HelpPrinter(ExecutableName, switches, GetHeader(), GetFooter()); helpPrinter.Print(); StringBuilder expectedOutput = new StringBuilder(); expectedOutput.AppendLine(GetHeader()); expectedOutput.AppendLine(); expectedOutput.AppendLine("Usage: " + ExecutableName + " [-s1] -s2 -s3 <arg>"); expectedOutput.AppendLine(); expectedOutput.AppendLine("-s1, --switch1 " + Description1); expectedOutput.AppendLine("-s2, --switch2 " + Description2); expectedOutput.AppendLine("-s3, --switch3 <arg> Third switch. This switch is required and has an "); expectedOutput.AppendLine(" argument."); expectedOutput.AppendLine(); expectedOutput.AppendLine(GetFooter()); Assert.AreEqual(expectedOutput.ToString(), Output); }