public void ShouldRunAllMetricsAndGenerateReport() { var typeDefnintions = new TypeDefinitionListBuilder().CreateTypeDefinitionList(); var metricResults = new MetricResultBuilder().CreateMetricResult(); var assemblySearcher = MockRepository.GenerateMock<IAssemblySearcher>(); var metric1 = MockRepository.GenerateMock<IMetricCalculator>(); var metric2 = MockRepository.GenerateMock<IMetricCalculator>(); var report = MockRepository.GenerateMock<IReport>(); assemblySearcher.Expect(x => x.GetAllTypes()) .Repeat.AtLeastOnce() .Return(typeDefnintions); metric1.Expect(x => x.Calculate(new List<TypeDefinition>())) .IgnoreArguments() .Return(metricResults); metric2.Expect(x => x.Calculate(new List<TypeDefinition>())) .IgnoreArguments() .Return(metricResults); //report.Expect(x => x.Generate(metricResults, "")).IgnoreArguments(); var dMetric = new DrivenMetrics(assemblySearcher, report, new[] {metric1, metric2}); dMetric.RunAllMetricsAndGenerateReport(); assemblySearcher.AssertWasCalled(x => x.GetAllTypes(), options => options .IgnoreArguments() .Repeat .AtLeastOnce()); metric1.AssertWasCalled(x => x.Calculate(new List<TypeDefinition>()), options => options.IgnoreArguments()); metric2.AssertWasCalled(x => x.Calculate(new List<TypeDefinition>()), options => options.IgnoreArguments()); //report.AssertWasCalled(x => x.Generate(metricResults, ""), options => options.IgnoreArguments()); }
public DrivenMetrics Create(string[] assemblyNames, IMetricCalculator[] metrics, string reportFilePath, IReport htmlReport) { var assemblies = new List <AssemblyDefinition>(); foreach (var assemblyName in assemblyNames) { var assemblyLoader = new AssemblyLoader(assemblyName); var assembly = assemblyLoader.Load(); assemblies.Add(assembly); } var methodFinder = new AssemblySearcher(assemblies.ToArray()); var drivenMetric = new DrivenMetrics(methodFinder, htmlReport, metrics); return(drivenMetric); }
public DrivenMetrics Create(string[] assemblyNames, string reportFilePath) { var assemblies = new List <AssemblyDefinition>(); foreach (var assemblyName in assemblyNames) { var assemblyLoader = new AssemblyLoader(assemblyName); var assembly = assemblyLoader.Load(); assemblies.Add(assembly); } var methodFinder = new AssemblySearcher(assemblies.ToArray()); //var htmlReport = new HtmlReport(new FileWriter(), reportFilePath); var htmlReport = new HtmlFailedReport(new FileWriter(), reportFilePath); var numberOfLines = new NumberOfLinesCalculator(20); var cyclomicCompexity = new ILCyclomicComplextityCalculator(20); var drivenMetric = new DrivenMetrics(methodFinder, htmlReport, new IMetricCalculator[] { numberOfLines, cyclomicCompexity }); return(drivenMetric); }
public DrivenMetrics Create(string[] assemblyNames, string reportFilePath) { var assemblies = new List<AssemblyDefinition>(); foreach (var assemblyName in assemblyNames) { var assemblyLoader = new AssemblyLoader(assemblyName); var assembly = assemblyLoader.Load(); assemblies.Add(assembly); } var methodFinder = new AssemblySearcher(assemblies.ToArray()); //var htmlReport = new HtmlReport(new FileWriter(), reportFilePath); var htmlReport = new HtmlFailedReport(new FileWriter(), reportFilePath); var numberOfLines = new NumberOfLinesCalculator(20); var cyclomicCompexity = new ILCyclomicComplextityCalculator(20); var drivenMetric = new DrivenMetrics(methodFinder, htmlReport, new IMetricCalculator[] { numberOfLines, cyclomicCompexity }); return drivenMetric; }
public DrivenMetrics Create(string[] assemblyNames, IMetricCalculator[] metrics, string reportFilePath, IReport htmlReport) { var assemblies = new List<AssemblyDefinition>(); foreach (var assemblyName in assemblyNames) { var assemblyLoader = new AssemblyLoader(assemblyName); var assembly = assemblyLoader.Load(); assemblies.Add(assembly); } var methodFinder = new AssemblySearcher(assemblies.ToArray()); var drivenMetric = new DrivenMetrics(methodFinder, htmlReport, metrics); return drivenMetric; }