コード例 #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");
    }
コード例 #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("");});
    }