Esempio n. 1
0
        public void TestContent()
        {
            CastDate currentDate = new CastDate {
                Time = 1484953200000
            };
            ReportData reportData = TestUtility.PrepareApplicationReportData("ReportGenerator",
                                                                             null, @".\Data\RuleListBCTC.json", "AED/applications/3/snapshots/6", "PreVersion 1.5.0 sprint 2 shot 2", "V-1.5.0_Sprint 2_2", currentDate,
                                                                             null, null, null, null, null, null);

            reportData = TestUtility.AddQIBusinessCriteriaConfiguration(reportData, @".\Data\QIBusinessCriteriaConf.json");
            reportData.RuleExplorer    = new RuleBLLStub();
            reportData.CurrentSnapshot = TestUtility.AddSameTechCritRulesViolations(reportData.CurrentSnapshot, @".\Data\TechCrit61009Violations.json");

            var component = new CastReporting.Reporting.Block.Table.TCImprovementOpportunity();
            Dictionary <string, string> config = new Dictionary <string, string>
            {
                { "PAR", "60011" }
            };
            var table = component.Content(reportData, config);

            var expectedData = new List <string>();

            expectedData.AddRange(new List <string> {
                "Technical criterion name", "# Violations", "Total Checks", "Grade"
            });
            expectedData.AddRange(new List <string> {
                "Complexity - Algorithmic and Control Structure Complexity", "443", "17,056", "3.56"
            });
            TestUtility.AssertTableContent(table, expectedData, 4, 2);
        }
Esempio n. 2
0
        public void TestLimitCount()
        {
            CastDate currentDate = new CastDate {
                Time = 1484953200000
            };
            ReportData reportData = TestUtility.PrepareApplicationReportData("ReportGenerator",
                                                                             null, @".\Data\RuleListBCTC.json", "AED/applications/3/snapshots/6", "PreVersion 1.5.0 sprint 2 shot 2", "V-1.5.0_Sprint 2_2", currentDate,
                                                                             null, null, null, null, null, null);

            reportData.RuleExplorer    = new RuleBLLStub();
            reportData.CurrentSnapshot = TestUtility.AddSameTechCritRulesViolations(reportData.CurrentSnapshot, @".\Data\TechCrit61009Violations.json");

            var component = new RulesList();
            Dictionary <string, string> config = new Dictionary <string, string>
            {
                { "PAR", "60011" },
                { "COUNT", "2" }
            };
            var table = component.Content(reportData, config);

            var expectedData = new List <string>();

            expectedData.AddRange(new List <string> {
                "Criticality", "Weight", "Grade", "Technical Criterion", "Rule Name", "# Viol.", "Successful Checks"
            });
            expectedData.AddRange(new List <string> {
                "µ", "9", "3.56", "Complexity - Algorithmic and Control Structure Complexity", "Action Mappings should have few forwards", "58", "3,117"
            });
            expectedData.AddRange(new List <string> {
                "", "45", "3.56", "Complexity - Algorithmic and Control Structure Complexity", "Avoid accessing data by using the position and length", "123", "1,234"
            });
            TestUtility.AssertTableContent(table, expectedData, 7, 3);
        }
Esempio n. 3
0
        public void TestNoConfig()
        {
            CastDate currentDate = new CastDate {
                Time = 1484953200000
            };
            CastDate previousDate = new CastDate {
                Time = 1484866800000
            };
            ReportData reportData = TestUtility.PrepareApplicationReportData("ReportGenerator",
                                                                             null, @".\Data\current.json", "AED/applications/3/snapshots/6", "PreVersion 1.5.0 sprint 2 shot 2", "V-1.5.0_Sprint 2_2", currentDate,
                                                                             null, @".\Data\previous.json", "AED/applications/3/snapshots/5", "PreVersion 1.4.0 sprint 1 shot 2", "V-1.4.0_Sprint 1_2", previousDate);

            reportData.RuleExplorer = new RuleBLLStub();

            TestUtility.AddSameTechCritRulesViolations(reportData.CurrentSnapshot, @".\Data\current.json");
            TestUtility.AddSameTechCritRulesViolations(reportData.PreviousSnapshot, @".\Data\previous.json");

            var component = new CastReporting.Reporting.Block.Table.RulesListLargestVariation();
            var table     = component.Content(reportData, null);

            var expectedData = new List <string>();

            expectedData.AddRange(new List <string> {
                "Weight", "Variation", "Rule Name"
            });
            expectedData.AddRange(new List <string> {
                "120", "25", "Avoid using 'System.err' and 'System.out' outside a try catch block"
            });
            expectedData.AddRange(new List <string> {
                "22", "4", "Track Classes referencing Database objects"
            });
            TestUtility.AssertTableContent(table, expectedData, 3, 3);
        }
Esempio n. 4
0
        public void TestDecreaseNumberNoPrevious()
        {
            CastDate currentDate = new CastDate {
                Time = 1484953200000
            };
            ReportData reportData = TestUtility.PrepareApplicationReportData("ReportGenerator",
                                                                             null, @".\Data\current.json", "AED/applications/3/snapshots/6", "PreVersion 1.5.0 sprint 2 shot 2", "V-1.5.0_Sprint 2_2", currentDate,
                                                                             null, null, null, null, null, null);

            reportData.RuleExplorer = new RuleBLLStub();

            TestUtility.AddSameTechCritRulesViolations(reportData.CurrentSnapshot, @".\Data\current.json");

            var component = new CastReporting.Reporting.Block.Table.RulesListLargestVariation();
            Dictionary <string, string> config = new Dictionary <string, string>
            {
                { "BCID", "60016" },
                { "VARIATION", "decrease" },
                { "DATA", "number" },
                { "COUNT", "3" }
            };
            var table = component.Content(reportData, config);

            var expectedData = new List <string>();

            expectedData.AddRange(new List <string> {
                "Weight", "Variation", "Rule Name"
            });
            expectedData.AddRange(new List <string> {
                "No enabled item", "", ""
            });
            TestUtility.AssertTableContent(table, expectedData, 3, 2);
        }
Esempio n. 5
0
        public void TestContent()
        {
            CastDate currentDate = new CastDate {
                Time = 1484953200000
            };
            ReportData reportData = TestUtility.PrepareApplicationReportData("ReportGenerator",
                                                                             null, @".\Data\RuleListBCTC.json", "AED/applications/3/snapshots/6", "PreVersion 1.5.0 sprint 2 shot 2", "V-1.5.0_Sprint 2_2", currentDate,
                                                                             null, null, null, null, null, null);

            reportData.RuleExplorer    = new RuleBLLStub();
            reportData.CurrentSnapshot = TestUtility.AddSameTechCritRulesViolations(reportData.CurrentSnapshot, @".\Data\TechCrit61009Violations.json");
            reportData = TestUtility.AddCriticalRuleViolations(reportData, 60011, @".\Data\cc60011.json", null);
            reportData = TestUtility.AddNonCriticalRuleViolations(reportData, 60011, @".\Data\nc60011.json", null);


            var component = new TechnicalCriteriaRules();
            Dictionary <string, string> config = new Dictionary <string, string>
            {
                { "BZID", "60011" },
                { "TCID", "61009" }
            };
            var table = component.Content(reportData, config);

            var expectedData = new List <string>();

            expectedData.AddRange(new List <string> {
                "Rule Name", "Description", "# Violations"
            });
            expectedData.AddRange(new List <string> {
                "Avoid hiding static Methods", "Hiding Static Methods is not allowed. This Quality Rule retrieves all static methods that are redefined in subclasses i.e. \"implicitly hidden\". A Static Method MyMethod of Class MySuperClass is \"implicitly hidden\" in Subclass MySubClass if MySubClass contains a similar declaration of MyMethod (i.e. same signature).", "124"
            });
            expectedData.AddRange(new List <string> {
                "Avoid accessing data by using the position and length", "This rule searches for Cobol programs accessing part of data by using a position and a length.", "123"
            });
            expectedData.AddRange(new List <string> {
                "Action Mappings should have few forwards", "All Action Mappings with more than 5 forward will be listed.", "58"
            });
            expectedData.AddRange(new List <string> {
                "Avoid unreferenced Tables", "List of schema tables that are not called", "58"
            });
            expectedData.AddRange(new List <string> {
                "Avoid Artifacts with High Cyclomatic Complexity", "Retrieves all Artifacts having a Cyclomatic Complexity greater than the specified threshold . Cyclomatic Complexity is a measure of the complexity of the control structure of an Artifact. It is the number of linearly independent paths and therefore, the minimum number of independent paths when executing the software. \nThe threshold is a parameter and can be changed at will.", "35"
            });
            TestUtility.AssertTableContent(table, expectedData, 3, 6);
        }
Esempio n. 6
0
        public void TestIncreaseNumber()
        {
            CastDate currentDate = new CastDate {
                Time = 1484953200000
            };
            CastDate previousDate = new CastDate {
                Time = 1484866800000
            };
            ReportData reportData = TestUtility.PrepareApplicationReportData("ReportGenerator",
                                                                             null, @".\Data\current.json", "AED/applications/3/snapshots/6", "PreVersion 1.5.0 sprint 2 shot 2", "V-1.5.0_Sprint 2_2", currentDate,
                                                                             null, @".\Data\previous.json", "AED/applications/3/snapshots/5", "PreVersion 1.4.0 sprint 1 shot 2", "V-1.4.0_Sprint 1_2", previousDate);

            reportData.RuleExplorer = new RuleBLLStub();

            TestUtility.AddSameTechCritRulesViolations(reportData.CurrentSnapshot, @".\Data\current.json");
            TestUtility.AddSameTechCritRulesViolations(reportData.PreviousSnapshot, @".\Data\previous.json");

            var component = new CastReporting.Reporting.Block.Table.RulesListLargestVariation();
            Dictionary <string, string> config = new Dictionary <string, string>
            {
                { "BCID", "60016" },
                { "VARIATION", "increase" },
                { "DATA", "number" },
                { "COUNT", "3" }
            };
            var table = component.Content(reportData, config);

            var expectedData = new List <string>();

            expectedData.AddRange(new List <string> {
                "Weight", "Variation", "Rule Name"
            });
            expectedData.AddRange(new List <string> {
                "96", "163", "Avoid direct definition of JavaScript Functions in a Web page"
            });
            expectedData.AddRange(new List <string> {
                "160", "54", "Avoid catching an exception of type Exception, RuntimeException, or Throwable"
            });
            expectedData.AddRange(new List <string> {
                "160", "38", "The exception Exception should never been thrown. Always Subclass Exception and throw the subclassed Classes."
            });
            TestUtility.AssertTableContent(table, expectedData, 3, 4);
        }
Esempio n. 7
0
        public void TestDecreasePercent()
        {
            CastDate currentDate = new CastDate {
                Time = 1484953200000
            };
            CastDate previousDate = new CastDate {
                Time = 1484866800000
            };
            ReportData reportData = TestUtility.PrepareApplicationReportData("ReportGenerator",
                                                                             null, @".\Data\current.json", "AED/applications/3/snapshots/6", "PreVersion 1.5.0 sprint 2 shot 2", "V-1.5.0_Sprint 2_2", currentDate,
                                                                             null, @".\Data\previous.json", "AED/applications/3/snapshots/5", "PreVersion 1.4.0 sprint 1 shot 2", "V-1.4.0_Sprint 1_2", previousDate);

            reportData.RuleExplorer = new RuleBLLStub();

            TestUtility.AddSameTechCritRulesViolations(reportData.CurrentSnapshot, @".\Data\current.json");
            TestUtility.AddSameTechCritRulesViolations(reportData.PreviousSnapshot, @".\Data\previous.json");

            var component = new CastReporting.Reporting.Block.Table.RulesListLargestVariation();
            Dictionary <string, string> config = new Dictionary <string, string>
            {
                { "BCID", "60016" },
                { "VARIATION", "decrease" },
                { "DATA", "percent" },
                { "COUNT", "3" }
            };
            var table = component.Content(reportData, config);

            var expectedData = new List <string>();

            expectedData.AddRange(new List <string> {
                "Weight", "Variation", "Rule Name"
            });
            expectedData.AddRange(new List <string> {
                "22", "+0.94 %", "Track Classes referencing Database objects"
            });
            expectedData.AddRange(new List <string> {
                "96", "+0.68 %", "Use of style sheets"
            });
            expectedData.AddRange(new List <string> {
                "160", "+0.19 %", "Avoid catching an exception of type Exception, RuntimeException, or Throwable"
            });
            TestUtility.AssertTableContent(table, expectedData, 3, 4);
        }
Esempio n. 8
0
        public void TestIncreasePercent()
        {
            CastDate currentDate = new CastDate {
                Time = 1484953200000
            };
            CastDate previousDate = new CastDate {
                Time = 1484866800000
            };
            ReportData reportData = TestUtility.PrepareApplicationReportData("ReportGenerator",
                                                                             null, @".\Data\current.json", "AED/applications/3/snapshots/6", "PreVersion 1.5.0 sprint 2 shot 2", "V-1.5.0_Sprint 2_2", currentDate,
                                                                             null, @".\Data\previous.json", "AED/applications/3/snapshots/5", "PreVersion 1.4.0 sprint 1 shot 2", "V-1.4.0_Sprint 1_2", previousDate);

            reportData.RuleExplorer = new RuleBLLStub();

            TestUtility.AddSameTechCritRulesViolations(reportData.CurrentSnapshot, @".\Data\current.json");
            TestUtility.AddSameTechCritRulesViolations(reportData.PreviousSnapshot, @".\Data\previous.json");

            var component = new CastReporting.Reporting.Block.Table.RulesListLargestVariation();
            Dictionary <string, string> config = new Dictionary <string, string>
            {
                { "BCID", "60016" },
                { "VARIATION", "increase" },
                { "DATA", "percent" },
                { "COUNT", "3" }
            };
            var table = component.Content(reportData, config);

            var expectedData = new List <string>();

            expectedData.AddRange(new List <string> {
                "Weight", "Variation", "Rule Name"
            });
            expectedData.AddRange(new List <string> {
                "80", "+100 %", "Provide a private default Constructor for utility Classes"
            });
            expectedData.AddRange(new List <string> {
                "96", "+0.27 %", "Avoid direct definition of JavaScript Functions in a Web page"
            });
            TestUtility.AssertTableContent(table, expectedData, 3, 3);
        }
Esempio n. 9
0
        public void TestLimitCount()
        {
            CastDate currentDate = new CastDate {
                Time = 1484953200000
            };
            ReportData reportData = TestUtility.PrepareApplicationReportData("ReportGenerator",
                                                                             null, @".\Data\RuleListBCTC.json", "AED/applications/3/snapshots/6", "PreVersion 1.5.0 sprint 2 shot 2", "V-1.5.0_Sprint 2_2", currentDate,
                                                                             null, null, null, null, null, null);

            reportData.RuleExplorer    = new RuleBLLStub();
            reportData.CurrentSnapshot = TestUtility.AddSameTechCritRulesViolations(reportData.CurrentSnapshot, @".\Data\TechCrit61009Violations.json");
            reportData = TestUtility.AddCriticalRuleViolations(reportData, 60011, @".\Data\cc60011.json", null);
            reportData = TestUtility.AddNonCriticalRuleViolations(reportData, 60011, @".\Data\nc60011.json", null);

            var component = new TechnicalCriteriaRules();
            Dictionary <string, string> config = new Dictionary <string, string>
            {
                { "BZID", "60011" },
                { "TCID", "61009" },
                { "CNT", "2" }
            };
            var table = component.Content(reportData, config);

            var expectedData = new List <string>();

            expectedData.AddRange(new List <string> {
                "Rule Name", "Description", "# Violations"
            });
            expectedData.AddRange(new List <string> {
                "Avoid hiding static Methods", "Hiding Static Methods is not allowed. This Quality Rule retrieves all static methods that are redefined in subclasses i.e. \"implicitly hidden\". A Static Method MyMethod of Class MySuperClass is \"implicitly hidden\" in Subclass MySubClass if MySubClass contains a similar declaration of MyMethod (i.e. same signature).", "124"
            });
            expectedData.AddRange(new List <string> {
                "Avoid accessing data by using the position and length", "This rule searches for Cobol programs accessing part of data by using a position and a length.", "123"
            });
            TestUtility.AssertTableContent(table, expectedData, 3, 3);
        }