Beispiel #1
0
    public void DisplayHelper_CreateValidationSummaryTest()
    {
      string[] args;
      ParameterDisplayHelper parameterDisplayHelper;
      string result;
      bool validationPassed;

      parameterDisplayHelper = new ParameterDisplayHelper("register_pet", Assembly.GetExecutingAssembly());
      args = new string[] { "age=-3", "gender=null" };
      parameterDisplayHelper.Parse(args);
      validationPassed = parameterDisplayHelper.Validate();
      result = parameterDisplayHelper.CreateValidationSummary();
      Assert.IsFalse(validationPassed);
      Assert.IsTrue(!String.IsNullOrEmpty(result));
      StringAssert.Contains(result, "║ One or more of the command line arguments are invalid.                       ║", "The returned string should show the expected message.");

      Debugger.Log(1, "CreateValidationSummary", "VALIDATION SUMMARY WITH STD MESSAGE\r\n\r\n");
      Debugger.Log(1, "CreateValidationSummary", result + "\r\n\r\n");

      result = parameterDisplayHelper.CreateValidationSummary("This is a very large message which should break at the maximum line length and continue on the next line.");
      StringAssert.Contains(result, "║ This is a very large message which should break at the maximum line length   ║", "The returned string should show the expected message.");
      StringAssert.Contains(result, "║ and continue on the next line.                                               ║", "The returned string should show the expected message.");

      Debugger.Log(1, "CreateValidationSummary", "VALIDATION SUMMARY  WITH CUSTOM MESSAGE\r\n\r\n");
      Debugger.Log(1, "CreateValidationSummary", result + "\r\n\r\n");
    }
Beispiel #2
0
    public void DisplayHelper_CreateValidationSummaryFailTest()
    {
      string[] args;
      ParameterDisplayHelper parameterDisplayHelper;

      parameterDisplayHelper = new ParameterDisplayHelper("register_pet", Assembly.GetExecutingAssembly());
      args = new string[] { "age=-3", "gender=null" };
      parameterDisplayHelper.Parse(args);
      parameterDisplayHelper.Validate();
      //
      // Calling 'CreateValidationSummary' with an empty message should raise an exception
      //
      Assert.ThrowsException<System.ArgumentException>( () => { parameterDisplayHelper.CreateValidationSummary("");});
    }
Beispiel #3
0
    public void DisplayHelper_CreateHelpTest()
    {
      ParameterDisplayHelper parameterDisplayHelper;
      string result;

      parameterDisplayHelper = new ParameterDisplayHelper("register_pet", Assembly.GetExecutingAssembly());
      result = parameterDisplayHelper.CreateHelp();
      Assert.IsTrue(!String.IsNullOrWhiteSpace(result));
      StringAssert.Contains(result, "In order to register a new pet use", "The returned string should show the expected message.");
      StringAssert.Contains(result, "╔═╦═[Parameter]═╦═[Type]═╦═[Default]═╦═[Description]═══════════════════════════╗", "The returned string should show the expected message.");
      StringAssert.Contains(result, "║+║ is_chipped  ║ Char   ║ \\0        ║ Enter a 'y' for yes or 'n' for no.      ║", "The returned string should show the expected message.");
      StringAssert.Contains(result, "║+║ name        ║ String ║           ║ The name of the pet you want to         ║", "The returned string should show the expected message.");
      StringAssert.Contains(result, "║+║ age         ║ UInt32 ║ 0         ║ The age of the pet you want to          ║", "The returned string should show the expected message.");
      StringAssert.Contains(result, "║-║ gender      ║ String ║ undefined ║ The gender of the pet you want to       ║", "The returned string should show the expected message.");
      StringAssert.Contains(result, "register_pet [help] [version]", "The returned string should show the expected message.");
      StringAssert.Contains(result, "yes_or_no=", "The returned string should show the expected message.");
      StringAssert.Contains(result, "name=", "The returned string should show the expected message.");
      StringAssert.Contains(result, "age=", "The returned string should show the expected message.");
      StringAssert.Contains(result, "[gender=", "The returned string should show the expected message.");

      Debugger.Log(1, "CreateHelp", result);
    }