Пример #1
0
        public void EmptyReport_RunsSuccessfully()
        {
            var emptyFilePath = Path.Combine(RepositoryPaths.GetSamplesPath(), "opencover", "Sample1", "EmptyReport.xml");
            var results       = DryRunCoverallsWithInputFile(emptyFilePath);

            Assert.Equal(0, results.ExitCode);
        }
Пример #2
0
        public void EmptyReport_MultipleMode_RunsSuccessfully()
        {
            var emptyFilePath = Path.Combine(RepositoryPaths.GetSamplesPath(), "OpenCover", "EmptyReport.xml");
            var results       = DryRunCoverallsMultiModeWithInputFile(emptyFilePath);

            CoverallsAssert.RanSuccessfully(results);
        }
Пример #3
0
        public void ReportWithOneFile_RunsSuccessfully()
        {
            string sampleFolderPath   = Path.Combine(RepositoryPaths.GetSamplesPath(), "opencover", "Sample2");
            var    sampleCoverageFile = Path.Combine(sampleFolderPath, "SingleFileReport.xml");
            var    sampleClassFile    = Path.Combine(sampleFolderPath, "SingleFileReportSourceFile.txt");
            var    coverageFilePath   = TestFolders.GetTempFilePath(Guid.NewGuid() + ".xml");
            var    classFilePath      = TestFolders.GetTempFilePath(Guid.NewGuid() + ".cs");

            File.Copy(sampleClassFile, classFilePath);
            var doc       = XDocument.Load(sampleCoverageFile);
            var classFile = doc.XPathSelectElements("//CoverageSession/Modules/Module/Files/File").FirstOrDefault(e => e.Attribute("fullPath").Value.EndsWith("Class1.cs"));

            classFile.Attribute("fullPath").SetValue(classFilePath);
            doc.Save(coverageFilePath);

            var results = DryRunCoverallsWithInputFile(coverageFilePath);

            Assert.Equal(0, results.ExitCode);
        }
Пример #4
0
        private static string BuildReportWithOneFile()
        {
            var sampleFolderPath   = Path.Combine(RepositoryPaths.GetSamplesPath(), "OpenCover");
            var sampleCoverageFile = Path.Combine(sampleFolderPath, "SingleFileReport.xml");
            var sampleClassFile    = Path.Combine(sampleFolderPath, "SingleFileReportSourceFile.txt");
            var coverageFilePath   = TestFolders.GetTempFilePath(Guid.NewGuid() + ".xml");
            var classFilePath      = TestFolders.GetTempFilePath(Guid.NewGuid() + ".cs");

            File.Copy(sampleClassFile, classFilePath);
            var doc       = XDocument.Load(sampleCoverageFile);
            var classFile =
                doc.XPathSelectElements("//CoverageSession/Modules/Module/Files/File")
                .FirstOrDefault(e => e.Attribute("fullPath").Value.EndsWith("Class1.cs", StringComparison.Ordinal));

            classFile.Attribute("fullPath").SetValue(classFilePath);
            using (var stream = File.OpenWrite(coverageFilePath))
            {
                doc.Save(stream);
            }

            return(coverageFilePath);
        }