Пример #1
0
        public void ParameterDefinition_Constructor_Sets_Default_Formatter()
        {
            var parameterDefinition = new ParameterDefinition("name", "label");

            Assert.IsNotNull(parameterDefinition.Formatter);
            Assert.AreEqual("testing", parameterDefinition.Formatter("testing"));
        }
Пример #2
0
        public void ParameterDefinition_Constructor_Sets_Optional_Properties()
        {
            Func <string, string> formatter = s => s + "great";
            var parameterDefinition         = new ParameterDefinition("name", "label", formatter, true);

            Assert.AreEqual(true, parameterDefinition.IsRegexMatch);
            Assert.AreEqual(formatter, parameterDefinition.Formatter);
            Assert.AreEqual("so great", parameterDefinition.Formatter("so "));
        }
 /// <summary>
 /// Format and write a parameter to the current writer.
 /// </summary>
 /// <param name="parameterDefinition">Parameter to write out.</param>
 /// <param name="rawValue">Raw value of the parameter to format before writing.</param>
 private void WriteParameter(ParameterDefinition parameterDefinition, string rawValue)
 {
     var formattedValue = parameterDefinition.Formatter(rawValue);
     if (!String.IsNullOrWhiteSpace(formattedValue))
         writer(parameterDefinition.Label.PadRight(24) + ": " + formattedValue);
 }