Beispiel #1
0
        public void TestReport()
        {
            CoverageResult result = new CoverageResult();

            result.Identifier = Guid.NewGuid().ToString();
            Lines lines = new Lines();

            lines.Add(1, new LineInfo {
                Hits = 1
            });
            lines.Add(2, new LineInfo {
                Hits = 0
            });
            Methods methods = new Methods();

            methods.Add("System.Void Coverlet.Core.Reporters.Tests.LcovReporterTests.TestReport()", lines);
            Classes classes = new Classes();

            classes.Add("Coverlet.Core.Reporters.Tests.LcovReporterTests", methods);
            Documents documents = new Documents();

            documents.Add("doc.cs", classes);
            result.Modules = new Modules();
            result.Modules.Add("module", documents);

            LcovReporter reporter = new LcovReporter();
            string       report   = reporter.Report(result);

            Assert.NotEmpty(report);
            Assert.Equal("SF:doc.cs", report.Split(Environment.NewLine)[0]);
            Assert.Equal("DA:1,1", report.Split(Environment.NewLine)[1]);
            Assert.Equal("DA:2,0", report.Split(Environment.NewLine)[2]);
            Assert.Equal("end_of_record", report.Split(Environment.NewLine)[3]);
        }
        public void TestReport()
        {
            CoverageResult result = new CoverageResult();

            result.Identifier = Guid.NewGuid().ToString();
            Lines lines = new Lines();

            lines.Add(1, new LineInfo {
                Hits = 1
            });
            lines.Add(2, new LineInfo {
                Hits = 0
            });
            Methods methods = new Methods();

            methods.Add("System.Void Coverlet.Core.Reporters.Tests.LcovReporterTests.TestReport()", lines);
            Classes classes = new Classes();

            classes.Add("Coverlet.Core.Reporters.Tests.LcovReporterTests", methods);
            Documents documents = new Documents();

            documents.Add("doc.cs", classes);
            result.Modules = new Modules();
            result.Modules.Add("module", documents);

            LcovReporter reporter = new LcovReporter();

            Assert.NotEqual(string.Empty, reporter.Report(result));
        }
        public void TestReport()
        {
            CoverageResult result = new CoverageResult();

            result.Parameters = new CoverageParameters();
            result.Identifier = Guid.NewGuid().ToString();

            Lines lines = new Lines();

            lines.Add(1, 1);
            lines.Add(2, 0);

            Branches branches = new Branches();

            branches.Add(new BranchInfo {
                Line = 1, Hits = 1, Offset = 23, EndOffset = 24, Path = 0, Ordinal = 1
            });
            branches.Add(new BranchInfo {
                Line = 1, Hits = 0, Offset = 23, EndOffset = 27, Path = 1, Ordinal = 2
            });

            Methods methods      = new Methods();
            var     methodString = "System.Void Coverlet.Core.Reporters.Tests.LcovReporterTests.TestReport()";

            methods.Add(methodString, new Method());
            methods[methodString].Lines    = lines;
            methods[methodString].Branches = branches;

            Classes classes = new Classes();

            classes.Add("Coverlet.Core.Reporters.Tests.LcovReporterTests", methods);

            Documents documents = new Documents();

            documents.Add("doc.cs", classes);
            result.Modules = new Modules();
            result.Modules.Add("module", documents);

            LcovReporter reporter = new LcovReporter();
            string       report   = reporter.Report(result, new Mock <ISourceRootTranslator>().Object);

            Assert.NotEmpty(report);
            Assert.Equal("SF:doc.cs", report.Split(Environment.NewLine)[0]);
        }