public void ShouldWriteMetricInfoIntoBody()
        {
            var results    = new MetricResultBuilder().CreateMetricResult();
            var fileWriter = new FileWriter();
            var report     = new HtmlFailedReport(fileWriter, "reportFailedtest.html");

            Assert.DoesNotThrow(() => report.Generate(results));
        }
Пример #2
0
        public void GenerateSampleMetricResult()
        {
            var instance           = new XmlReport(new MemoryFileWriter(), null);
            var sampleMetricResult = new MetricResultBuilder().CreateMetricResult();

            instance.Generate(sampleMetricResult);
            AssertAreEqual(@"
<metrics>
    <metric name=""Test Metric"">
        <class name=""Test Class 1"">
            <method name=""Test Method1"" pass=""false"" result=""12"" />
            <method name=""Test Method2"" pass=""true"" result=""5"" />
        </class>
        <class name=""Test Class 1"">
            <method name=""Test Method1"" pass=""false"" result=""12"" />
            <method name=""Test Method2"" pass=""true"" result=""5"" />
        </class>
    </metric>
</metrics>", instance);
        }
Пример #3
0
        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());
        }