private static string getError(OutputMessages pMessages, Description pDescription, eERROR pError)
 {
     using (StringWriter sw = new StringWriter())
     {
         Console.SetError(sw);
         pMessages.Error(pDescription, pError);
         return sw.ToString().Trim();
     }
 }
        public void Error_1()
        {
            MockOutput mock = new MockOutput();
            OutputMessages output = new OutputMessages(CliOptions.WindowsStyle, mock);

            Description desc = new Description("width", "The rectangle width", eROLE.NAMED, new ParamString(),
                eSCOPE.REQUIRED,
                eMULTIPLICITY.ONCE);

            const eERROR unsupported = (eERROR)(-1);
            output.Error(desc, unsupported);
        }
        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());
        }
 public void OutputMessages()
 {
     MockOutput mock = new MockOutput();
     OutputMessages output = new OutputMessages(CliOptions.WindowsStyle, mock);
 }
Beispiel #5
0
 /// <summary>
 /// Initializes this class with an error handler.
 /// </summary>
 /// <param name="pMessages">Handles errors found in parameters.</param>
 public Validator(OutputMessages pMessages)
 {
     _messages = pMessages;
 }