Exemple #1
0
    public PropertyHelp(PropertyRoute propertyRoute, string?userDescription)
    {
        if (propertyRoute.PropertyRouteType != PropertyRouteType.FieldOrProperty)
        {
            throw new ArgumentException("propertyRoute should be of type Property");
        }

        this.PropertyRoute   = propertyRoute;
        this.Info            = HelpGenerator.GetPropertyHelp(propertyRoute);
        this.UserDescription = userDescription;
    }
        public void GeneratePropHelpTest()
        {
            var parser    = new CmdLineParser <TestCmdLineObj>();
            var results   = parser.Parse(new string[] { });
            var generator = new HelpGenerator(results);

            var help = generator.GetPropertyHelp(results.Properties["Name"]);

            Assert.That.Contains("/Name <String> REQUIRED", help);
            Assert.That.Contains("\tTEST DESC", help);

            // Type doesn't have a description, but the flag is set to show it.
            help = generator.GetPropertyHelp(results.Properties["Type"]);
            Assert.That.Contains("/PersonType (/Type) <Father|Mother|Child>", help);
            Assert.That.Contains("\tDefault: Father", help);

            help = generator.GetPropertyHelp(results.Properties["Children"]);
            Assert.That.Contains("/Children", help);
            Assert.That.Contains("\tDefault: [\"One\", \"Two\", \"Three\"]", help);

            help = generator.GetPropertyHelp(results.Properties["Secret"]);
            Assert.That.Contains("/Secret", help);
            Assert.IsFalse(help.Contains("Shhh!"));
        }