Ejemplo n.º 1
0
        public void TestWriteAPISpec_InvalidParam2()
        {
            param = new ReflectionEngineParameters();
            param.AssemblyFileNames = new string[0];

            engine.WriteAPISpec(param, "<apispec/>");
        }
Ejemplo n.º 2
0
        public void TestWriteAPISpec_NotExistAssemblyFile()
        {
            param = new ReflectionEngineParameters();
            param.AssemblyFileNames = new string[] { "non-exist.dll" };

            engine.WriteAPISpec(param, "<apispec/>");
        }
        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.");
        }
Ejemplo n.º 4
0
        public void SetUp()
        {
            engine = new ReflectionEngine();

            param = new ReflectionEngineParameters();
            param.AssemblyFileNames = new string[] { "TopCoder.LoggingWrapper.dll" };
            param.ReferencePaths    = new string[] { "../../test_files/failuretests" };
        }
Ejemplo n.º 5
0
        /// <summary>
        /// <para>This method creates a new instance of CSharpAPIProcessor from the the given set of inputted switches
        /// and the configuration node.</para>
        /// <para>The default switch keys are:</para>
        /// <list type="bullet">
        /// <item>
        /// <term>assemblies</term>
        /// <description>the set of assemblies to analyze. This switch is mandatory.</description>
        /// </item>
        /// <item>
        /// <term>docFiles</term>
        /// <description>The set of /doc XML files to analyze. /doc XML files are generated by compiler and
        /// contain inline documentation. Optional.</description>
        /// </item>
        /// <item>
        /// <term>modules</term>
        /// <description>
        /// The set of modules to analyze. Using this to screen only interested modules. Optional.
        /// </description>
        /// </item>
        /// <item>
        /// <term>typePrefixes</term>
        /// <description>
        /// The set of prefixes of types to analyze. Using this to screen only interested namespaces or types. Optional.
        /// </description>
        /// </item>
        /// <item>
        /// <term>documentPrivates</term>
        /// <description>Whether to list private types and members. Optional.</description>
        /// </item>
        /// </list>
        ///
        /// <para>Besides the inputted switches, the following Configuration API properties are supported:</para>
        /// <list type="bullet">
        /// <item>
        /// <term>reference_paths</term>
        /// <description>
        /// property defines the set of paths where to search for the dependent assemblies. Optional.
        /// </description>
        /// </item>
        /// <item>
        /// <term>logger_namespace</term>
        /// <description>property defines the configuration namespace of the logger to be used by
        /// CSharpAPIProcessor. Optional.</description>
        /// </item>
        /// </list>
        /// </summary>
        /// <param name="configuration">the configuration node to use</param>
        /// <param name="inputtedSwitches">the switches entered</param>
        /// <exception cref="ArgumentNullException">if any argument is null</exception>
        /// <exception cref="ArgumentException">if inputtedSwitches contains a null element</exception>
        /// <exception cref="XmlProcessorFactoryException">if anything else goes wrong</exception>
        public override IXmlProcessor NewXmlProcessor(CommandLineSwitch[] inputtedSwitches,
                                                      IConfiguration configuration)
        {
            Helper.ValidateNotNull(configuration, "configuration");
            Helper.ValidateArray(inputtedSwitches, "inputtedSwitches", true, false, true, false);

            try
            {
                ReflectionEngineParameters rep = new ReflectionEngineParameters();
                //Set the ReflectionEngineParameters properties.
                foreach (CommandLineSwitch inputtedSwitch in inputtedSwitches)
                {
                    string[] result = inputtedSwitch.Result as string[];

                    if (inputtedSwitch.Switch == "assemblies")
                    {
                        rep.AssemblyFileNames = result;
                    }
                    else if (inputtedSwitch.Switch == "docFiles")
                    {
                        rep.SlashDocFileNames = result;
                    }
                    else if (inputtedSwitch.Switch == "modules")
                    {
                        rep.ModuleNames = result;
                    }
                    else if (inputtedSwitch.Switch == "typePrefixes")
                    {
                        rep.TypePrefixes = result;
                    }
                    else if (inputtedSwitch.Switch == "documentPrivates")
                    {
                        rep.DocumentPrivates = true;
                    }
                }

                //Add the reference paths from configuration
                string[] refPaths = configuration.GetAttribute("reference_paths") as string[];
                if (refPaths != null)
                {
                    rep.ReferencePaths = refPaths;
                }

                //Add the logger namespace from configuration
                string loggerNs = configuration.GetSimpleAttribute("logger_namespace") as string;
                if (loggerNs != null)
                {
                    rep.LoggerNamespace = loggerNs;
                }

                return(new CSharpAPIProcessor(rep));
            }
            catch (Exception e)
            {
                throw new XmlProcessorFactoryException("Unable to create new xml processor.", e);
            }
        }
Ejemplo n.º 6
0
        public void SetUp()
        {
            ConfigManager.GetInstance().LoadFile("../../test_files/logger.xml");

            rep = new ReflectionEngineParameters();
            rep.AssemblyFileNames = new string[] { UnitTestHelper.MOCKLIBPATH };
            rep.ReferencePaths    = new string[] { UnitTestHelper.REFPATH };
            rep.SlashDocFileNames = new string[] { UnitTestHelper.MOCKXMLPATH };
            rep.LoggerNamespace   = "MyLoggerNamespace";
            rep.DocumentPrivates  = true;

            csap = new CSharpAPIProcessor(rep);
        }
Ejemplo n.º 7
0
        public void TestProcessDocument_SmallAssembly()
        {
            ReflectionEngineParameters parameters = new ReflectionEngineParameters();

            parameters.AssemblyFileNames = new string[] { "../../test_files/StressTests/SmallAssembly.dll" };
            parameters.DocumentPrivates  = true;
            parameters.ReferencePaths    = new string[] { "../../test_files/StressTests" };
            parameters.SlashDocFileNames = new string[] { "../../test_files/StressTests/SmallAssembly.xml" };
            parameters.ModuleNames       = new string[] { "SmallAssembly.dll" };
            parameters.TypePrefixes      = new string[0];

            TestProcessDocument(parameters);
        }
Ejemplo n.º 8
0
        public void Setup()
        {
            ReflectionEngineParameters parameters = new ReflectionEngineParameters();

            parameters.AssemblyFileNames = new string[] { "../../test_files/accuracy/MockClass.dll" };
            parameters.DocumentPrivates  = true;
            parameters.ReferencePaths    = new string[] { "../../test_files/accuracy" };
            parameters.SlashDocFileNames = new string[] { "../../test_files/accuracy/MockClass.xml" };
            parameters.ModuleNames       = new string[] { "MockClass.dll" };
            parameters.TypePrefixes      = new string[] { "M", "S", "E", "A", "T" };

            DoResults(parameters);
        }
Ejemplo n.º 9
0
        public void TestProcessDocument_NormalAssembly()
        {
            ReflectionEngineParameters parameters = new ReflectionEngineParameters();

            parameters.AssemblyFileNames =
                new string[] { "../../test_files/StressTests/TopCoder.Util.ConfigurationManager.dll" };
            parameters.DocumentPrivates  = true;
            parameters.ReferencePaths    = new string[] { "../../test_files/StressTests" };
            parameters.SlashDocFileNames =
                new string[] { "../../test_files/StressTests/TopCoder.Util.ConfigurationManager.xml" };
            parameters.ModuleNames  = new string[] { "TopCoder.Util.ConfigurationManager.dll" };
            parameters.TypePrefixes = new string[] { "TopCoder" };

            TestProcessDocument(parameters);
        }
Ejemplo n.º 10
0
        /// <summary>
        /// Test <c>ProcessDocument(XmlDocument)</c> method.
        /// </summary>
        /// <param name="rep">Some parameter to run ReflectionEngine</param>
        private void TestProcessDocument(ReflectionEngineParameters rep)
        {
            CSharpAPIProcessor processor = new CSharpAPIProcessor(rep);

            DateTime startTime        = DateTime.Now;
            int      performanceCount = 0;

            while ((startTime + new TimeSpan(0, 0, 10)) > DateTime.Now)
            {
                XmlDocument doc = new XmlDocument();
                doc.LoadXml("<apispec/>");
                processor.ProcessDocument(doc);
                performanceCount++;
            }

            Console.WriteLine("Generator doc for assembly {0} used {1}s ( {2} times/{3} sec )",
                              rep.AssemblyFileNames, 10.0 / performanceCount, performanceCount, 10);
        }
Ejemplo n.º 11
0
        public void DemoTest_NonCommandLine1()
        {
            //Setup options
            ReflectionEngineParameters rep = new ReflectionEngineParameters();

            rep.AssemblyFileNames = new string[] { UnitTestHelper.MOCKLIBPATH };
            rep.ReferencePaths    = new string[] { UnitTestHelper.REFPATH };
            rep.SlashDocFileNames = new string[] { UnitTestHelper.MOCKXMLPATH };
            rep.DocumentPrivates  = true;

            ReflectionEngine re = new ReflectionEngine();

            //Write the API specification
            string      xml       = re.WriteAPISpec(rep, "<apispec></apispec>");
            XmlDocument xmlOutput = new XmlDocument();

            xmlOutput.LoadXml(xml);
        }
Ejemplo n.º 12
0
        /// <summary>
        /// Prepares the result fields.
        /// </summary>
        /// <param name="parameters">The parameters to use.</param>
        protected void DoResults(ReflectionEngineParameters parameters)
        {
            engine = new ReflectionEngine();

            // No existing spec, really, you can't have everything
            resultString = engine.WriteAPISpec(parameters, "<apispec><package name='IDONTEXIST'/></apispec>");

            resultDocument = new XmlDocument();
            resultDocument.LoadXml(resultString);
            resultString = resultDocument.InnerXml;

            Console.WriteLine("RESULTS FOR TEST {0}", GetType());

            Console.WriteLine();
            Console.WriteLine("You can comment out the code that creates a text version of the accuracy XML.");
            Console.WriteLine("Manual inspection might show additional, unexpected errors.");
            Console.WriteLine("Ideally, the results should be well-defined enough for one unique XML structure" +
                              "to be expected.");
            Console.WriteLine("When the component has gone through final fixes, a 'gold standard' with the output can");
            Console.WriteLine("be created for future regression testing.");

            // File.WriteAllText(@"../../test_files/accuracy/somelittlefile.xml", resultString);
        }
Ejemplo n.º 13
0
 /// <summary>
 /// <para>Creates a new instance of CSharpAPIProcessor with the given ReflectionEngineParameters instance used
 /// to create the ReflectionEngine.</para>
 /// </summary>
 /// <param name="rep">the ReflectionEngineParameters instance used to create the ReflectionEngine.</param>
 /// <exception cref="ArgumentNullException">if rep is null.</exception>
 public CSharpAPIProcessor(ReflectionEngineParameters rep)
 {
     Helper.ValidateNotNull(rep, "rep");
     this.rep = rep;
 }
 protected void SetUp()
 {
     param = new ReflectionEngineParameters();
 }
Ejemplo n.º 15
0
        protected void SetUp()
        {
            rep = new ReflectionEngineParameters();

            processor = new CSharpAPIProcessor(rep);
        }