public void Show_1() { MockOutput output = new MockOutput(); OutputHelp outputHelp = new OutputHelp(CliOptions.WindowsStyle, output); List <Description> descs = new List <Description> { new Description("width", "The width of the rectangle.", eROLE.NAMED, new ParamString(), eSCOPE.REQUIRED, eMULTIPLICITY.ONCE), new Description("filename", "The input file.", eROLE.PASSED, new ParamString(), eSCOPE.OPTIONAL, eMULTIPLICITY.ONCE) }; outputHelp.Show(descs); string[] lines = output.getLines(); CollectionAssert.AreEqual( new[] { "Usage: GemsCLI [/options] [filename]", "Where options include:", "/width The width of the rectangle.", "filename* The input file.", "* shows optional parameters." }, lines); }
public void Error_0() { Description desc = new Description("width", "The rectangle width", eROLE.NAMED, new ParamString(), eSCOPE.REQUIRED, eMULTIPLICITY.ONCE); MockOutput mock = new MockOutput(); OutputMessages messages = new OutputMessages(CliOptions.WindowsStyle, mock); mock.Clear(); messages.Error(desc, eERROR.REQUIRED); CollectionAssert.AreEqual(new[] { "GemsCLI: option '/width' is required." }, mock.getLines()); mock.Clear(); messages.Error(desc, eERROR.DUPLICATE); CollectionAssert.AreEqual(new[] { "GemsCLI: option '/width' can only be used once." }, mock.getLines()); mock.Clear(); messages.Error(desc, eERROR.MISSING_VALUE); CollectionAssert.AreEqual(new[] { "GemsCLI: option '/width' is missing value." }, mock.getLines()); }