public void Generate_ZeroBounds_ThrowsException()
        {
            TestClassWithEmptyHelpAttributes instance = new TestClassWithEmptyHelpAttributes();
            HelpProcessor <TestClassWithEmptyHelpAttributes> processor = new HelpProcessor <TestClassWithEmptyHelpAttributes>(instance);

            Assert.Throws <HelpGeneratorException>(() => { processor.Generate(0); });
        }
        public void Generate_TestClassHelpSectionAndSummary_ResultIsLongtHelp()
        {
            String expected = "\r\nUsage:\r\n\r\n" +
                              "  testhost.x86.exe [options]\r\n\r\nOptions:\r\n\r\n" +
                              "  Section A\r\n\r\n" +
                              "  --switcha1  Switch 1 in section A.\r\n\r\n" +
                              "  --switcha2  Switch 2 in section A.\r\n\r\n" +
                              "  --switcha3  Switch 3 in section A.\r\n\r\n" +
                              "  Section B\r\n\r\n" +
                              "  --switchb1  Switch 1 in section B.\r\n\r\n" +
                              "  --switchb2  Switch 2 in section B.\r\n\r\n";

            TestClassHelpSectionAndSummary instance = new TestClassHelpSectionAndSummary();
            HelpProcessor <TestClassHelpSectionAndSummary> processor = new HelpProcessor <TestClassHelpSectionAndSummary>(instance);

            processor.Generate();

            System.Diagnostics.Debug.WriteLine("------------------------");
            System.Diagnostics.Debug.WriteLine(processor.Results);
            System.Diagnostics.Debug.WriteLine("------------------------");
            System.Diagnostics.Debug.WriteLine(expected);
            System.Diagnostics.Debug.WriteLine("------------------------");

            Assert.AreEqual(processor.Results, expected);
        }
        public void Initialize_TestClassUntaggedProperties_ResultIsZeroSettingsCount()
        {
            TestClassUntaggedProperties instance = new TestClassUntaggedProperties();
            HelpProcessor <TestClassUntaggedProperties> processor = new HelpProcessor <TestClassUntaggedProperties>(instance);

            processor.Initialize();
            Assert.AreEqual(processor.Settings.Count, 0);
        }
        public void Initialize_TestClassThreeHelpSummaryAndParameters_ResultIsThreeSettingsCount()
        {
            TestClassThreeHelpSummaryAndParameters instance = new TestClassThreeHelpSummaryAndParameters();
            HelpProcessor <TestClassThreeHelpSummaryAndParameters> processor = new HelpProcessor <TestClassThreeHelpSummaryAndParameters>(instance);

            processor.Initialize();
            Assert.AreEqual(processor.Settings.Count, 3);
        }
        public void Initialize_TestClassOnlyHelpLicense_ResultIsLicenseNotNull()
        {
            TestClassOnlyHelpLicense instance = new TestClassOnlyHelpLicense();
            HelpProcessor <TestClassOnlyHelpLicense> processor = new HelpProcessor <TestClassOnlyHelpLicense>(instance);

            processor.Initialize();
            Assert.AreNotEqual(processor.License, null);
        }
        public void Initialize_TestClassOnlyHelpClosure_ResultIsClosureNotNull()
        {
            TestClassOnlyHelpClosure instance = new TestClassOnlyHelpClosure();
            HelpProcessor <TestClassOnlyHelpClosure> processor = new HelpProcessor <TestClassOnlyHelpClosure>(instance);

            processor.Initialize();
            Assert.AreNotEqual(processor.Closure, null);
        }
        public void Generate_TestClassWithEmptyHelpAttributes_ResultIsEmpty()
        {
            TestClassWithEmptyHelpAttributes instance = new TestClassWithEmptyHelpAttributes();
            HelpProcessor <TestClassWithEmptyHelpAttributes> processor = new HelpProcessor <TestClassWithEmptyHelpAttributes>(instance);

            processor.Generate();
            Assert.AreEqual(processor.Results, String.Empty);
        }
        public void Initialize_TestClassOnlyTwoHelpUtilize_ResultIsTwoUtilizeCount()
        {
            TestClassOnlyTwoHelpUtilize instance = new TestClassOnlyTwoHelpUtilize();
            HelpProcessor <TestClassOnlyTwoHelpUtilize> processor = new HelpProcessor <TestClassOnlyTwoHelpUtilize>(instance);

            processor.Initialize();
            Assert.AreEqual(processor.Utilizes.Count, 2);
        }
        public void Generate_TestClassTwoEmptyUtilize_ResultIsTwoWithDefaultUsages()
        {
            String expected = "\r\nUsage:\r\n\r\n  testhost.x86.exe [options]\r\n  testhost.x86.exe [options]\r\n\r\n";

            TestClassTwoEmptyUtilize instance = new TestClassTwoEmptyUtilize();
            HelpProcessor <TestClassTwoEmptyUtilize> processor = new HelpProcessor <TestClassTwoEmptyUtilize>(instance);

            processor.Generate();

            Assert.AreEqual(processor.Results, expected);
        }
        public void Generate_TestClassTwoContentUtilizeHeadingOther_ResultIsTwoInDefaultUsageInSameSection()
        {
            String expected = "\r\nOther:\r\n\r\n  Content AAA\r\n  Content BBB\r\n\r\n";

            TestClassTwoContentUtilizeHeadingOther instance = new TestClassTwoContentUtilizeHeadingOther();
            HelpProcessor <TestClassTwoContentUtilizeHeadingOther> processor = new HelpProcessor <TestClassTwoContentUtilizeHeadingOther>(instance);

            processor.Generate();

            Assert.AreEqual(processor.Results, expected);
        }
        public void Generate_TestClassTwoContentUtilize_ResultIsTwoWithOtherUsages()
        {
            String expected = "\r\nUsage:\r\n\r\n  Content AAA\r\n  Content BBB\r\n\r\n";

            TestClassTwoContentUtilize instance = new TestClassTwoContentUtilize();
            HelpProcessor <TestClassTwoContentUtilize> processor = new HelpProcessor <TestClassTwoContentUtilize>(instance);

            processor.Generate();

            Assert.AreEqual(processor.Results, expected);
        }
        public void Generate_TestClassTwoContentUtilizeWithSection_ResultIsTwoDifferentUsagesInSameHeader()
        {
            String expected = "\r\nUsage:\r\n\r\n  Hello:\r\n    Content AAA\r\n    Content BBB\r\n\r\n";

            TestClassTwoContentUtilizeWithSection instance = new TestClassTwoContentUtilizeWithSection();
            HelpProcessor <TestClassTwoContentUtilizeWithSection> processor = new HelpProcessor <TestClassTwoContentUtilizeWithSection>(instance);

            processor.Generate();

            Assert.AreEqual(processor.Results, expected);
        }
        public void Generate_TestClassUtilizeFullFeatured_ResultIsAsExpected()
        {
            String expected = "\r\nUsage:\r\n\r\n  D-A\r\n  D-B\r\n  D-C\r\n  D-D\r\n\r\nH-1\r\n\r\n  U-1.0.1\r\n  U-1.0.2\r\n  " +
                              "C-1.1\r\n    U-1.1.1\r\n    U-1.1.2\r\n    U-1.1.3\r\n  C-1.2\r\n    U-1.2.1\r\n    U-1.2.2\r\n    U-1.2.3\r\n\r\nH-2\r\n\r\n  " +
                              "C-1.1\r\n    U-2.1.1\r\n    U-2.1.2\r\n    U-2.1.3\r\n  C-1.2\r\n    U-2.2.1\r\n    U-2.2.2\r\n    U-2.2.3\r\n  U-2.0.1\r\n  U-2.0.2\r\n\r\n";

            TestClassUtilizeFullFeatured instance = new TestClassUtilizeFullFeatured();
            HelpProcessor <TestClassUtilizeFullFeatured> processor = new HelpProcessor <TestClassUtilizeFullFeatured>(instance);

            processor.Generate();

            Assert.AreEqual(processor.Results, expected);
        }
        public void Generate_TestClassWithShortCopyright_ResultIsShortHelp()
        {
            String expected = "\r\nCopyright (c) company\r\n\r\n" +
                              "Usage:\r\n\r\n  testhost.x86.exe [options]\r\n\r\nOptions:\r\n\r\n" +
                              "  --property1  \r\n\r\n  --property2  \r\n\r\n";

            TestClassWithShortCopyright instance = new TestClassWithShortCopyright();
            HelpProcessor <TestClassWithShortCopyright> processor = new HelpProcessor <TestClassWithShortCopyright>(instance);

            processor.Generate();

            Assert.AreEqual(processor.Results, expected);
        }
        public void Generate_TestClassWithShortEpilogue_ResultIsShortHelp()
        {
            String expected = "\r\nUsage:\r\n\r\n  testhost.x86.exe [options]\r\n\r\nOptions:\r\n\r\n" +
                              "  --property1  \r\n\r\n  --property2  \r\n\r\n" +
                              "This is a pretty short epilogue.\r\n";

            TestClassWithShortEpilogue instance = new TestClassWithShortEpilogue();
            HelpProcessor <TestClassWithShortEpilogue> processor = new HelpProcessor <TestClassWithShortEpilogue>(instance);

            processor.Generate();

            Assert.AreEqual(processor.Results, expected);
        }
        public void Generate_TestClassWithMinimumHelpAttributes_ResultIsMinimumHelp()
        {
            String expected = "\r\nUsage:\r\n\r\n" +
                              "  testhost.x86.exe [options]\r\n\r\nOptions:\r\n\r\n" +
                              "  --property1  \r\n\r\n" +
                              "  --property2  \r\n\r\n";

            TestClassWithMinimumHelpAttributes instance = new TestClassWithMinimumHelpAttributes();
            HelpProcessor <TestClassWithMinimumHelpAttributes> processor = new HelpProcessor <TestClassWithMinimumHelpAttributes>(instance);

            processor.Generate();

            Assert.AreEqual(processor.Results, expected);
        }
        public void Generate_TestClassWithShortHelpSummary_ResultIsShortHelp()
        {
            String expected = "\r\nUsage:\r\n\r\n" +
                              "  testhost.x86.exe [options]\r\n\r\nOptions:\r\n\r\n" +
                              "  --property1  Short help on switch 1.\r\n\r\n" +
                              "  --property2  Short help on option 2.\r\n\r\n";

            TestClassWithShortHelpSummary instance = new TestClassWithShortHelpSummary();
            HelpProcessor <TestClassWithShortHelpSummary> processor = new HelpProcessor <TestClassWithShortHelpSummary>(instance);

            processor.Generate();

            Assert.AreEqual(processor.Results, expected);
        }
        public void Generate_TestClassHelpSummaryAndOptionArguments_ResultIsLongtHelp()
        {
            String expected = "\r\nUsage:\r\n\r\n" +
                              "  testhost.x86.exe [options]\r\n\r\nOptions:\r\n\r\n" +
                              "  --string-option [-so] str-val  String option with additional arguments in\r\n" +
                              "                                 help output.\r\n\r\n" +
                              "  --int-option [-io] num-val     Integer option with additional arguments in\r\n" +
                              "                                 help output.\r\n\r\n";

            TestClassHelpSummaryAndOptionArguments instance = new TestClassHelpSummaryAndOptionArguments();
            HelpProcessor <TestClassHelpSummaryAndOptionArguments> processor = new HelpProcessor <TestClassHelpSummaryAndOptionArguments>(instance);

            processor.Generate();

            Assert.AreEqual(processor.Results, expected);
        }
        public void Generate_TestClassWithLongHelpSummaryDifferentParameterLength_ResultIsLongtHelp()
        {
            String expected = "\r\nUsage:\r\n\r\n" +
                              "  testhost.x86.exe [options]\r\n\r\nOptions:\r\n\r\n" +
                              "  --less          Long help on switch 1. Long help on switch 1. Long help on\r\n" +
                              "                  switch 1. Long help on switch 1. Long help on switch 1.\r\n" +
                              "                  Long help on switch 1.\r\n\r\n" +
                              "  --a-bit-longer  Long help on option 2. Long help on option 2. Long help on\r\n" +
                              "                  option 2. Long help on option 2.\r\n\r\n";

            TestClassWithLongHelpSummaryDifferentParameterLength instance = new TestClassWithLongHelpSummaryDifferentParameterLength();
            HelpProcessor <TestClassWithLongHelpSummaryDifferentParameterLength> processor = new HelpProcessor <TestClassWithLongHelpSummaryDifferentParameterLength>(instance);

            processor.Generate();

            Assert.AreEqual(processor.Results, expected);
        }
        public void Generate_TestClassSummaryTwoHeadings_ResultIsAsExpected()
        {
            String expected = "\r\nHeading-1:\r\n\r\n" +
                              "  --prop-1-head-1 [-p1h1]  Property 1 in heading 1\r\n\r\n" +
                              "  --prop-2-head-1 [-p2h1]  Property 2 in heading 1\r\n\r\n" +
                              "Heading-2:\r\n\r\n" +
                              "  --prop-1-head-2 [-p1h2]  Property 1 in heading 2\r\n\r\n" +
                              "  --prop-2-head-2 [-p2h2]  Property 2 in heading 2\r\n\r\n" +
                              "  --prop-3-head-2 [-p3h2]  Property 3 in heading 2\r\n\r\n";

            TestClassSummaryTwoHeadings instance = new TestClassSummaryTwoHeadings();
            HelpProcessor <TestClassSummaryTwoHeadings> processor = new HelpProcessor <TestClassSummaryTwoHeadings>(instance);

            processor.Generate();

            Assert.AreEqual(processor.Results, expected);
        }
        public void Generate_TestClassWithLongCopyrightPrologueEpilogue_ResultIsLongHelp()
        {
            String expected = "\r\nCopyright (c) company. Test data set 1 to fill the line up to its end. Test\r\n" +
                              "data set 2 to fill the line up to its end.\r\n\r\n" +
                              "This is a pretty short prologue. Test data set 1 to fill the line up to its\r\n" +
                              "end. Test data set 2 to fill the line up to its end.\r\n\r\n" +
                              "Usage:\r\n\r\n  testhost.x86.exe [options]\r\n\r\n" +
                              "Options:\r\n\r\n  --property1  \r\n\r\n  --property2  \r\n\r\n" +
                              "This is a pretty short epilogue. Test data set 1 to fill the line up to its\r\n" +
                              "end. Test data set 2 to fill the line up to its end.\r\n";

            TestClassWithLongCopyrightPrologueEpilogue instance = new TestClassWithLongCopyrightPrologueEpilogue();
            HelpProcessor <TestClassWithLongCopyrightPrologueEpilogue> processor = new HelpProcessor <TestClassWithLongCopyrightPrologueEpilogue>(instance);

            processor.Generate();

            Assert.AreEqual(processor.Results, expected);
        }
        public void Generate_TestClassSummaryTwoHeadingsTwoSections_ResultIsAsExpected()
        {
            String expected = "\r\nHeading-1:\r\n\r\n" +
                              "  Section-1\r\n\r\n" +
                              "  --prop-1-head-1-sect-1 [-p1h1s1]  Property 1 in heading 1 and section 1\r\n\r\n" +
                              "  --prop-2-head-1-sect-1 [-p2h1s1]  Property 2 in heading 1 and section 1\r\n\r\n" +
                              "  Section-2\r\n\r\n" +
                              "  --prop-1-head-1-sect-2 [-p1h1s2]  Property 1 in heading 1 and section 2\r\n\r\n" +
                              "  --prop-2-head-1-sect-2 [-p2h1s2]  Property 2 in heading 1 and section 2\r\n\r\n" +
                              "Heading-2:\r\n\r\n" +
                              "  Section-1\r\n\r\n" +
                              "  --prop-1-head-2-sect-1 [-p1h2s1]  Property 1 in heading 2 and section 1\r\n\r\n" +
                              "  --prop-2-head-2-sect-1 [-p2h2s1]  Property 2 in heading 2 and section 1\r\n\r\n" +
                              "  Section-2\r\n\r\n" +
                              "  --prop-1-head-2-sect-2 [-p1h2s2]  Property 1 in heading 2 and section 2\r\n\r\n" +
                              "  --prop-2-head-2-sect-2 [-p2h2s2]  Property 2 in heading 2 and section 2\r\n\r\n";

            TestClassSummaryTwoHeadingsTwoSections instance = new TestClassSummaryTwoHeadingsTwoSections();
            HelpProcessor <TestClassSummaryTwoHeadingsTwoSections> processor = new HelpProcessor <TestClassSummaryTwoHeadingsTwoSections>(instance);

            processor.Generate();

            Assert.AreEqual(processor.Results, expected);
        }
Exemple #23
0
 /// <summary>
 /// Performs help generation for the given instance but uses the given length
 /// as right limit.
 /// </summary>
 /// <remarks>
 /// The extension method performs help generation for the given instance
 /// but uses the given length as right limit.
 /// </remarks>
 /// <typeparam name="TInstance">
 /// The generic type of a class that contains all help information.
 /// </typeparam>
 /// <param name="instance">
 /// The instance of a class for which help has to be generated.
 /// </param>
 /// <param name="length">
 /// The maximum length of each line inside the help output.
 /// </param>
 /// <returns>
 /// The pre-formatted help text that can be directly printed out to the
 /// user.
 /// </returns>
 public static String Generate <TInstance>(this TInstance instance, Int32 length) where TInstance : class
 {
     return(HelpProcessor <TInstance> .Generate(instance, length));
 }
        public void Initialize_TestClassIsNull_ThrowsException()
        {
            Object instance = null;

            Assert.Throws <ArgumentNullException>(() => { HelpProcessor <Object> processor = new HelpProcessor <Object>(instance); });
        }
        public void Generate_TestClassWithMinimumHelpAttributesButVeryLongParameterName_ResultIsMinimumHelpButLineBreak()
        {
            String expected = "\r\nUsage:\r\n\r\n  testhost.x86.exe [options]\r\n\r\nOptions:\r\n\r\n" +
                              "  --this-is-a-very-long-parameter-name-longer-than-line-with  \r\n" +
                              "               The summary of the very long parameter name.\r\n\r\n" +
                              "  --property2                                                 \r\n" +
                              "               The summary of the other parameter name.\r\n\r\n";

            TestClassWithMinimumHelpAttributesButVeryLongParameterName instance = new TestClassWithMinimumHelpAttributesButVeryLongParameterName();
            HelpProcessor <TestClassWithMinimumHelpAttributesButVeryLongParameterName> processor = new HelpProcessor <TestClassWithMinimumHelpAttributesButVeryLongParameterName>(instance);

            processor.Generate();

            Assert.AreEqual(processor.Results, expected);
        }
Exemple #26
0
 public void TestInitialize()
 {
     _storageService = Substitute.For <IStorageService>();
     _processor      = new HelpProcessor(_storageService);
 }