public void RewriteLastRunWithCoverageData(DbCodeCoverage codeCoverage) { var codeCoverageFilePath = Path.Combine(_outputDir, "sqlcc.js"); var codeCoverages = GetCodeCoverageFile(codeCoverageFilePath); var lastCodeCoverage = codeCoverages.LastOrDefault(); codeCoverage.Name = lastCodeCoverage.Name; codeCoverage.StartDate = lastCodeCoverage.StartDate; codeCoverages.RemoveAt(codeCoverages.Count - 1); codeCoverages.Add(codeCoverage); SaveCodeCoverageFile(codeCoverages, codeCoverageFilePath); }
public void Execute() { var codeCoverageProcessor = new CodeCoverageProcessor(_dbCodeFormatter, _codeHighlighter); var codeCover = new DbCodeCoverage(); codeCover.Name = _traceName; codeCover.TotalObjects = _dbProvider.GetAllObjects(); codeCover.TraceCodeSegments = _dbProvider.GetTraceCodeSegments(_traceName); codeCoverageProcessor.ProcessAllCoverage(codeCover); _outputProvider.SetUp(_traceName); _outputProvider.SaveResults(codeCover); }
public override bool SaveResults(DbCodeCoverage codeCoverage) { codeCoverage.EndDate = DateTime.Now; var baseLocation = _outputDir; var codeCoverageLocation = Path.Combine(baseLocation, codeCoverage.Name); Directory.CreateDirectory(codeCoverageLocation); WriteCodeCoverageMetaData(codeCoverage, codeCoverageLocation); WriteAllDbObjectFiles(codeCoverage.TotalObjects, baseLocation, codeCoverageLocation); RewriteLastRunWithCoverageData(codeCoverage); return true; }
public void ProcessAllCoverage(DbCodeCoverage codeCover) { foreach (var obj in codeCover.TotalObjects) { obj.CoveredSegments = codeCover.TraceCodeSegments.Where(p => p.ObjectName.Equals(obj.Name)).ToList(); obj.Set(ProcessObjectCoverage(obj)); obj.CodeHighlighted = _highlightCodeProvider.HighlightCode(obj.Code, obj.CoveredSegments); codeCover.TotalLoc += obj.TotalLoc; codeCover.TotalFloc += obj.TotalFloc; codeCover.TotalCharacters += obj.TotalCharacters; codeCover.TotalFunctionalCharacters += obj.TotalFunctionalCharacters; codeCover.CoveredCharacters += (int)Math.Round(obj.TotalFunctionalCharacters * obj.CoveredPercent); codeCover.CoveredLinesOfCode += (int)Math.Round(obj.TotalLoc * obj.CoveredPercent); } codeCover.CoveredPercent = ((decimal)codeCover.CoveredCharacters / codeCover.TotalFunctionalCharacters); }
public void Execute() { Console.WriteLine("Generating results..."); var codeCoverageProcessor = new CodeCoverageProcessor(_dbCodeFormatter, _codeHighlighter); var codeCover = new DbCodeCoverage(); Console.WriteLine(" Getting all database objects..."); codeCover.Name = _traceName; codeCover.TotalObjects = _dbProvider.GetAllObjects(); codeCover.TraceCodeSegments = _dbProvider.GetTraceCodeSegments(_traceName); Console.WriteLine(" Parsing coverage for {0} database objects...", codeCover.TotalObjects.Count); codeCoverageProcessor.ProcessAllCoverage(codeCover); Console.WriteLine(" Saving output results..."); _outputProvider.SetUp(_traceName); _outputProvider.SaveResults(codeCover); Console.WriteLine("Results generated."); }
public void ProcessAllCoverage(DbCodeCoverage codeCover) { var total = codeCover.TotalObjects.Count; int count = 0; foreach (var obj in codeCover.TotalObjects) { count += 1; Console.WriteLine(" Parsing object ({0} of {1}): {2}", count, total, obj.Name); obj.CoveredSegments = codeCover.TraceCodeSegments.Where(p => p.ObjectName.Equals(obj.Name)).ToList(); obj.Set(ProcessObjectCoverage(obj)); obj.CodeHighlighted = _highlightCodeProvider.HighlightCode(obj.Code, obj.CoveredSegments); codeCover.TotalLoc += obj.TotalLoc; codeCover.TotalFloc += obj.TotalFloc; codeCover.TotalCharacters += obj.TotalCharacters; codeCover.TotalFunctionalCharacters += obj.TotalFunctionalCharacters; codeCover.CoveredCharacters += (int)Math.Round(obj.TotalFunctionalCharacters * obj.CoveredPercent); codeCover.CoveredLinesOfCode += (int)Math.Round(obj.TotalLoc * obj.CoveredPercent); } codeCover.CoveredPercent = ((decimal)codeCover.CoveredCharacters / codeCover.TotalFunctionalCharacters); }
private void WriteCodeCoverageMetaData(DbCodeCoverage codeCoverage, string location) { var json = "sqlcc_objects['" + codeCoverage.Name + "']=" + JsonHelper.JsonSerializer(codeCoverage.TotalObjects); File.WriteAllText(Path.Combine(location, "sqlcc.js"), json); }
public abstract bool SaveResults(DbCodeCoverage codeCoverage);