コード例 #1
0
        public void Hotspot_Metrics()
        {
            // arrage
            var assembly = new Assembly("assembly");
            var @class   = new Class("class", assembly);

            assembly.AddClass(@class);
            var method = new MethodMetric("method");

            method.AddMetric(new Metric(ReportResources.CyclomaticComplexity, null, 1));
            method.AddMetric(new Metric(ReportResources.SequenceCoverage, null, 2));
            method.AddMetric(new Metric(ReportResources.BranchCoverage, null, 3));
            method.AddMetric(new Metric(ReportResources.CrapScore, null, 4));
            @class.AddMethodMetric(method);
            var assemblies = new List <Assembly> {
                assembly
            };

            // act
            var hotspots = RiskHotspotsAnalysis.DetectHotspots(assemblies);

            // assert
            var hotspot = hotspots.First();

            Assert.AreEqual(1, hotspot.Complexity);
            Assert.AreEqual(2, hotspot.Coverage);
            Assert.AreEqual(3, hotspot.BranchCoverage);
            Assert.AreEqual(4, hotspot.CrapScore);
        }
コード例 #2
0
        public void AddMetric_AddSingleMetric_MetricIsStored()
        {
            MethodMetric sut    = new MethodMetric("Test");
            var          metric = new Metric("Metric1", null, 10);

            sut.AddMetric(metric);

            Assert.AreEqual(metric, sut.Metrics.First(), "Not equal");
            Assert.AreEqual(1, sut.Metrics.Count(), "Wrong number of metrics");
        }
コード例 #3
0
        public void AddMetric_AddSingleMetric_MetricIsStored()
        {
            MethodMetric sut    = new MethodMetric("Test", "Test", Enumerable.Empty <Metric>());
            var          metric = new Metric("Metric1", null, MetricType.CodeQuality, 10);

            sut.AddMetric(metric);

            Assert.Equal(metric, sut.Metrics.First());
            Assert.Single(sut.Metrics);
        }