public void TestNewXmlProcessor()
        {
            //Get the switches
            IConfiguration    config = UnitTestHelper.GetConfig();
            CommandLineParser clp    = new CommandLineParser();

            capf.ConfigureCommandLineParser(clp, config);

            List <CommandLineSwitch> lst = new List <CommandLineSwitch>();
            IEnumerator en = clp.AvailableSwitches.GetEnumerator();

            while (en.MoveNext())
            {
                lst.Add(en.Current as CommandLineSwitch);
            }
            IXmlProcessor xmlProc = capf.NewXmlProcessor(lst.ToArray(), config);

            Assert.AreEqual(xmlProc.GetType(), typeof(CSharpAPIProcessor), "Wrong return type.");
            CSharpAPIProcessor csProc = (CSharpAPIProcessor)xmlProc;

            ReflectionEngineParameters rep = (ReflectionEngineParameters)
                                             UnitTestHelper.GetPrivateField(csProc, "rep");

            Assert.IsNotNull(rep, "ReflectionEngineParameters instance not set properly.");
        }
        public void TestConfigureCommandLineParser()
        {
            IConfiguration    config = UnitTestHelper.GetConfig();
            CommandLineParser clp    = new CommandLineParser();

            capf.ConfigureCommandLineParser(clp, config);

            //The switches must be added correctly
            Assert.AreEqual(clp.AvailableSwitches.Count, 5, "Incorrect number of switches added.");

            string[] switchNames = new string[] {
                "assemblies", "docFiles", "modules", "documentPrivates", "typePrefixes"
            };

            for (int i = 0; i < 5; i++)
            {
                bool        found = false;
                IEnumerator en    = clp.AvailableSwitches.GetEnumerator();
                while (en.MoveNext())
                {
                    CommandLineSwitch cSwitch = en.Current as CommandLineSwitch;
                    if (cSwitch.Switch.Equals(switchNames[i]))
                    {
                        found = true;
                        break;
                    }
                }

                Assert.IsTrue(found, "missing switch: " + switchNames[i]);
            }
        }
Exemplo n.º 3
0
        public void DemoTest_CommandLine()
        {
            //Create CommandLineProcessor
            IConfiguration       config    = UnitTestHelper.GetConfig();
            CommandLineProcessor processor = new CommandLineProcessor(config);

            // to run the processor we need an argument array.
            // this one will analyze MockLibrary.dll with the inline documentation
            // provided by MockLibrary.xml. Only the types whose namespace
            // starts with ‘MockLibrary’ are listed. And we also generate the API for
            // private elements.
            string[] args = new string[5];
            args[0] = "/assemblies:" + UnitTestHelper.MOCKLIBPATH;
            args[1] = "/docFiles:" + UnitTestHelper.MOCKXMLPATH;
            args[2] = "/modules:MockLibrary.dll";
            args[3] = "/typePrefixes:MockLibrary";
            args[4] = "/documentPrivates";

            // create a new XmlDocument with root <apispec>
            XmlDocument apiSpec = new XmlDocument();

            apiSpec.LoadXml("<apispec></apispec>");

            // generate the API spec to apiSpec XmlDocument
            processor.ProcessDocument(args, apiSpec);
        }
        public void TestNewXmlProcessorFail4()
        {
            IConfiguration config = UnitTestHelper.GetConfig();

            config["processor_factory_config"].SetAttribute("reference_paths", new string[] { "" });
            capf.NewXmlProcessor(new CommandLineSwitch[] { new CommandLineSwitch("abc") },
                                 config["processor_factory_config"]);
        }
 public void TestNewXmlProcessorFail3()
 {
     capf.NewXmlProcessor(new CommandLineSwitch[] { null }, UnitTestHelper.GetConfig());
 }
 public void TestNewXmlProcessorFail1()
 {
     capf.NewXmlProcessor((CommandLineSwitch[])null, UnitTestHelper.GetConfig());
 }
 public void TestConfigureCommandLineParserFail1()
 {
     capf.ConfigureCommandLineParser(null, UnitTestHelper.GetConfig());
 }