public static IEnumerable <LocalizedElement> LocalizeStatements( CoverageInfo covInfo, TestInfo testInfo, string metricsFilePath) { var calcMetricFunc = LoadMetricFunc(metricsFilePath); var maxStatementCount = covInfo.StatementIndexAndTargets.Count(); var currentStatementCount = 1; foreach (var stmt in covInfo.StatementIndexAndTargets) { var id = stmt.Item1; var element = stmt.Item2; var passedTestCases = testInfo.TestCases.Where(t => t.Passed); var executedAndPassedTestCases = passedTestCases.Where(t => t.Statements.Contains(id)); var failedTestCases = testInfo.TestCases.Where(t => !t.Passed); var executedAndFailedTestCases = failedTestCases.Where(t => t.Statements.Contains(id)); var localized = new LocalizedElement { ExecutedAndPassed = executedAndPassedTestCases.Count(), Passed = passedTestCases.Count(), ExecutedAndFailed = executedAndFailedTestCases.Count(), Failed = failedTestCases.Count(), Element = element, }; var metrics = calcMetricFunc( localized.ExecutedAndPassed, localized.Passed, localized.ExecutedAndFailed, localized.Failed).Cast <double>().ToList(); localized.Values = metrics.ToList(); yield return(localized); Console.Write("Calculating: " + currentStatementCount + " / " + maxStatementCount + "\r"); currentStatementCount++; } }
public static IEnumerable<LocalizedElement> LocalizeStatements( CoverageInfo covInfo, TestInfo testInfo, string metricsFilePath) { var calcMetricFunc = LoadMetricFunc(metricsFilePath); var maxStatementCount = covInfo.StatementIndexAndTargets.Count(); var currentStatementCount = 1; foreach (var stmt in covInfo.StatementIndexAndTargets) { var id = stmt.Item1; var element = stmt.Item2; var passedTestCases = testInfo.TestCases.Where(t => t.Passed); var executedAndPassedTestCases = passedTestCases.Where(t => t.Statements.Contains(id)); var failedTestCases = testInfo.TestCases.Where(t => !t.Passed); var executedAndFailedTestCases = failedTestCases.Where(t => t.Statements.Contains(id)); var localized = new LocalizedElement { ExecutedAndPassed = executedAndPassedTestCases.Count(), Passed = passedTestCases.Count(), ExecutedAndFailed = executedAndFailedTestCases.Count(), Failed = failedTestCases.Count(), Element = element, }; var metrics = calcMetricFunc( localized.ExecutedAndPassed, localized.Passed, localized.ExecutedAndFailed, localized.Failed).Cast<double>().ToList(); localized.Values = metrics.ToList(); yield return localized; Console.Write("Calculating: " + currentStatementCount + " / " + maxStatementCount + "\r"); currentStatementCount++; } }