Example #1
0
 /// <summary>
 /// Checks the passed parameters. This consists of two steps which are overrideable by concrete commands.
 /// 1.) Check the number of parameters.
 /// 2.) Check the values of all passed parameters
 /// Template Method Pattern: Template Method.
 /// </summary>
 /// <param name="outputter">The outputter must be used to printout any error description.</param>
 /// <returns>
 /// - true  if number and values of the parameters are correct. Execute() may use the parameters afterwards unchecked.
 /// - false if the number is below or above excepted range or if any value is incorrect. An explaining error message must be given
 ///         by the concrete command.
 /// </returns>
 public bool CheckParameters(IOutputter outputter)
 {
     if (!CheckNumberOfParameters(parameters.Count))
     {
         outputter.PrintLine(INCORRECT_SYNTAX);
         return(false);
     }
     if (!CheckParameterValues(outputter))
     {
         if (!outputter.HasCharactersPrinted())
         {
             outputter.PrintLine(DEFAULT_ERROR_MESSAGE_WRONG_PARAMETER);
         }
         return(false);
     }
     return(true);
 }
Example #2
0
 public void HasCharactersPrinted_ByDefault_IsFalse()
 {
     Assert.IsFalse(outputter.HasCharactersPrinted());
     Assert.AreEqual(0, outputter.NumberOfCharactersPrinted());
 }