public void Ensure_NoOptionsText_Returned_If_No_options_Have_Been_Setup() { var formatter = new CommandLineOptionFormatter(); var actual = formatter.Format(new ICommandLineOption[0]); Assert.AreEqual(formatter.NoOptionsText, actual); }
public void Ensure_Header_Is_Displayed_If_One_Is_Set() { var formatter = new CommandLineOptionFormatter(); // expected: // my custom header // // Short1 Description1 // Short2:Long2 Description2 const string expectedHeader = "my custom header"; formatter.Header = expectedHeader; var mockOption1 = CreateMockOption("Short1", null, "Description1"); var mockOption2 = CreateMockOption("Short2", "Long2", "Description2"); var expectedSb = new StringBuilder(); expectedSb.AppendLine(); expectedSb.AppendLine(expectedHeader); expectedSb.AppendLine(); expectedSb.AppendFormat(CultureInfo.CurrentUICulture, CommandLineOptionFormatter.TextFormat, mockOption1.ShortName, mockOption1.Description); expectedSb.AppendFormat(CultureInfo.CurrentUICulture, CommandLineOptionFormatter.TextFormat, mockOption2.ShortName + ":" + mockOption2.LongName, mockOption2.Description); var expected = expectedSb.ToString(); var actual = formatter.Format(new[] { mockOption1, mockOption2 }); Assert.AreEqual(expected, actual, "Formatter returned unexpected string"); }
public void Ensure_Cannot_Specify_Null_options_Param() { var formatter = new CommandLineOptionFormatter(); formatter.Format(null); }
public void Ensure_Format_Returns_Expected_String() { var formatter = new CommandLineOptionFormatter(); // expected: // Short1 Description1 // Short2:Long2 Description2 var mockOptionA = CreateMockOption("a", "aaa", "a-description"); var mockOptionB = CreateMockOption("b", null, "b-description1"); var mockOptionC = CreateMockOption(null, "ccc", "c-description"); var expectedSb = new StringBuilder(); expectedSb.AppendLine(); expectedSb.AppendFormat(CultureInfo.CurrentUICulture, CommandLineOptionFormatter.TextFormat, mockOptionA.ShortName + ":" + mockOptionA.LongName, mockOptionA.Description); expectedSb.AppendFormat(CultureInfo.CurrentUICulture, CommandLineOptionFormatter.TextFormat, mockOptionB.ShortName, mockOptionB.Description); expectedSb.AppendFormat(CultureInfo.CurrentUICulture, CommandLineOptionFormatter.TextFormat, mockOptionC.LongName, mockOptionC.Description); var expected = expectedSb.ToString(); var actual = formatter.Format(new[] { mockOptionB, mockOptionA, mockOptionC }); Assert.AreEqual(expected, actual, "Formatter returned unexpected string"); }
public void Ensure_Format_Returns_Expected_String() { var formatter = new CommandLineOptionFormatter(); // expected: // Short1 Description1 // Short2:Long2 Description2 var mockOption1 = CreateMockOption("Short1", null, "Description1"); var mockOption2 = CreateMockOption("Short2", "Long2", "Description2"); var expectedSb = new StringBuilder(); expectedSb.AppendLine(); expectedSb.AppendFormat(CultureInfo.CurrentUICulture, CommandLineOptionFormatter.TextFormat, mockOption1.ShortName, mockOption1.Description); expectedSb.AppendFormat(CultureInfo.CurrentUICulture, CommandLineOptionFormatter.TextFormat, mockOption2.ShortName + ":" + mockOption2.LongName, mockOption2.Description); var expected = expectedSb.ToString(); var actual = formatter.Format(new[] { mockOption1, mockOption2 }); Assert.AreEqual(expected, actual, "Formatter returned unexpected string"); }