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); }
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); }