Ejemplo n.º 1
0
        public void ExcludedFunctionIsExcluded()
        {
            string config = "<ccm>" +
                            "  <exclude>" +
                            "    <function>Foo2</function> " +
                            "    <function>Bar2</function> " +
                            "  </exclude>" +
                            "</ccm>";

            XmlDocument doc = new XmlDocument();

            doc.LoadXml(config);

            ConfigurationFile file = new ConfigurationFile(doc);

            string code1 = "void Foo() {}";
            string code2 = "void Bar() {}";
            string code3 = "void Foo2() {}";
            string code4 = "void Bar2() {}";

            Driver driver = new Driver(file);

            driver.StartAnalyze(TestUtil.GetTextStream(code1), "file1.h");
            driver.StartAnalyze(TestUtil.GetTextStream(code2), "file2.h");
            driver.StartAnalyze(TestUtil.GetTextStream(code3), "file3.h");
            driver.StartAnalyze(TestUtil.GetTextStream(code4), "file4.h");
            driver.WaitForWorkThreadsToFinish();

            DriverTests.AssertMetric(driver.Metrics, "Foo()", 1, "file1.h");
            DriverTests.AssertMetric(driver.Metrics, "Bar()", 1, "file2.h");

            Assert.AreEqual(2, driver.Metrics.Count);
        }
Ejemplo n.º 2
0
        public void SingleStreamIsAnalyzed()
        {
            string code = "void Foo() {}";

            Driver driver = new Driver();

            driver.StartAnalyze(TestUtil.GetTextStream(code), "file1.h");
            driver.WaitForWorkThreadsToFinish();

            DriverTests.AssertMetric(driver.Metrics, "Foo()", 1, "file1.h");
        }
Ejemplo n.º 3
0
        public void MultipleStreamsAnalyzed()
        {
            string code1 = "void Foo() {}";
            string code2 = "void Bar() {}";
            string code3 = "void Foo2() {}";
            string code4 = "void Bar2() {}";

            Driver driver = new Driver();

            driver.StartAnalyze(TestUtil.GetTextStream(code1), "file1.h");
            driver.StartAnalyze(TestUtil.GetTextStream(code2), "file2.cpp");
            driver.StartAnalyze(TestUtil.GetTextStream(code3), "file3.cs");
            driver.StartAnalyze(TestUtil.GetTextStream(code4), "file4.h");
            driver.WaitForWorkThreadsToFinish();

            DriverTests.AssertMetric(driver.Metrics, "Foo()", 1, "file1.h");
            DriverTests.AssertMetric(driver.Metrics, "Bar()", 1, "file2.cpp");
            DriverTests.AssertMetric(driver.Metrics, "Foo2()", 1, "file3.cs");
            DriverTests.AssertMetric(driver.Metrics, "Bar2()", 1, "file4.h");
        }