Пример #1
0
 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());
     }
 }
Пример #2
0
        /// <summary>
        /// Prints an error message that relates to the description.
        /// </summary>
        /// <param name="pDescs">Collection of parameter descriptions.</param>
        /// <param name="pError">Type of error being reported.</param>
        /// <returns>True if any errors reported.</returns>
        private bool Report(IEnumerable <Description> pDescs, eERROR pError)
        {
            bool result = false;

            foreach (Description desc in pDescs)
            {
                _messages.Error(desc, pError);
                result = true;
            }
            return(result);
        }
Пример #3
0
        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());
        }
Пример #4
0
        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);
        }