本文整理汇总了C#中IParser.ProcessFile方法的典型用法代码示例。如果您正苦于以下问题:C# IParser.ProcessFile方法的具体用法?C# IParser.ProcessFile怎么用?C# IParser.ProcessFile使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IParser
的用法示例。
在下文中一共展示了IParser.ProcessFile方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BuildReport
private Report BuildReport(string resultsFile, string outputFile)
{
testFileParser = ParserFactory.LoadParser(resultsFile);
if (testFileParser == null)
return null;
Report report = testFileParser.ProcessFile();
if (report == null)
return null;
string html = HTML.File.Base;
if (report.Total > 0)
{
try
{
// do the replacing here
html = html.Replace(ReportHelper.MarkupFlag("totalTests"), report.Total.ToString())
.Replace(ReportHelper.MarkupFlag("passed"), report.Passed.ToString())
.Replace(ReportHelper.MarkupFlag("failed"), report.Failed.ToString())
.Replace(ReportHelper.MarkupFlag("inconclusive"), report.Inconclusive.ToString())
.Replace(ReportHelper.MarkupFlag("skipped"), report.Skipped.ToString())
.Replace(ReportHelper.MarkupFlag("errors"), report.Errors.ToString())
.Replace(ReportHelper.MarkupFlag("inXml"), Path.GetFullPath(report.FileName))
.Replace(ReportHelper.MarkupFlag("duration"), report.Duration.ToString())
.Replace(ReportHelper.MarkupFlag("result"), report.Status.ToString())
.Replace(ReportHelper.MarkupFlag("name"), report.AssemblyName);
foreach (KeyValuePair<string, string> pair in report.RunInfo.Info)
{
html = html.Replace(ReportHelper.MarkupFlag("runinfo"), HTML.File.RunInfoRow + ReportHelper.MarkupFlag("runinfo"))
.Replace(ReportHelper.MarkupFlag("runInfoParam"), pair.Key)
.Replace(ReportHelper.MarkupFlag("runInfoValue"), pair.Value);
}
html = BuildSuiteBlocks(report, html, outputFile);
}
catch (Exception ex)
{
logger.Fatal("Something weird happened: " + ex.Message);
return null;
}
}
else
{
// replace OPTIONALCSS here with css to hide elements
html = html.Replace(ReportHelper.MarkupFlag("noTestsMessage"), HTML.File.NoTestsMessage)
.Replace(ReportHelper.MarkupFlag("optionalCss"), HTML.File.NoTestsCSS + ReportHelper.MarkupFlag("optionalCss"))
.Replace(ReportHelper.MarkupFlag("inXml"), Path.GetFileName(resultsFile));
}
// finally, save the source as the output file
if (source == null)
File.WriteAllText(outputFile, html.Apply(theme));
else
source.SourceFiles.Add(outputFile, html.Apply(theme));
return report;
}
示例2: BuildReport
private Report BuildReport(string resultsFile, string outputFile)
{
_testFileParser = ParserFactory.LoadParser(resultsFile);
if (_testFileParser == null)
return null;
Report report = _testFileParser.ProcessFile();
if (report == null)
return null;
string html = HTML.File.Base;
if (report.Total > 0)
{
try
{
foreach (var fixture in report.TestFixtures)
{
int passed = fixture.Passed;
int failed = fixture.Failed + fixture.Errors;
int other = fixture.Inconclusive + fixture.Skipped;
string runResult;
if (fixture.Status == Status.Inconclusive || fixture.Status == Status.Skipped || fixture.Status == Status.Unknown)
{
runResult = "other";
}
else
{
runResult = fixture.Status.ToString();
}
html = html.Replace(ReportHelper.MarkupFlag("insertFixtureResult"), HTML.File.Row)
.Replace(ReportHelper.MarkupFlag("testFixture"), fixture.Name)
.Replace(ReportHelper.MarkupFlag("testFixtureResult"), runResult.ToLower())
.Replace(ReportHelper.MarkupFlag("totalFixtureTests"), fixture.Total.ToString())
.Replace(ReportHelper.MarkupFlag("totalTestsPassed"), passed.ToString())
.Replace(ReportHelper.MarkupFlag("totalTestsFailed"), failed.ToString())
.Replace(ReportHelper.MarkupFlag("allOtherTestsInFixture"), other.ToString())
.Replace(ReportHelper.MarkupFlag("passedPercentage"), (Convert.ToInt32(passed) * 100 / Convert.ToInt32(fixture.Total)).ToString())
.Replace(ReportHelper.MarkupFlag("failedPercentage"), (Convert.ToInt32(failed) * 100 / Convert.ToInt32(fixture.Total)).ToString())
.Replace(ReportHelper.MarkupFlag("othersPercentage"), (Convert.ToInt32(other) * 100 / Convert.ToInt32(fixture.Total)).ToString());
}
html = html.Replace(ReportHelper.MarkupFlag("fixtureLevelTotal"), report.Total.ToString())
.Replace(ReportHelper.MarkupFlag("fixtureLevelPassedTests"), report.Passed.ToString())
.Replace(ReportHelper.MarkupFlag("fixtureLevelFailedTests"), (report.Errors + report.Failed).ToString())
.Replace(ReportHelper.MarkupFlag("fixtureLevelOtherTests"), (report.Inconclusive + report.Skipped).ToString())
.Replace(ReportHelper.MarkupFlag("totalTests"), report.Total.ToString())
.Replace(ReportHelper.MarkupFlag("passed"), report.Passed.ToString())
.Replace(ReportHelper.MarkupFlag("failed"), report.Failed.ToString())
.Replace(ReportHelper.MarkupFlag("inconclusive"), report.Inconclusive.ToString())
.Replace(ReportHelper.MarkupFlag("skipped"), report.Skipped.ToString())
.Replace(ReportHelper.MarkupFlag("errors"), report.Errors.ToString())
.Replace(ReportHelper.MarkupFlag("inXml"), Path.GetFullPath(report.FileName))
.Replace(ReportHelper.MarkupFlag("duration"), report.Duration.ToString())
.Replace(ReportHelper.MarkupFlag("result"), report.Status.ToString())
.Replace(ReportHelper.MarkupFlag("name"), report.AssemblyName);
foreach (KeyValuePair<string, string> pair in report.RunInfo.Info)
{
html = html.Replace(ReportHelper.MarkupFlag("runinfo"), HTML.File.RunInfoRow + ReportHelper.MarkupFlag("runinfo"))
.Replace(ReportHelper.MarkupFlag("runInfoParam"), pair.Key)
.Replace(ReportHelper.MarkupFlag("runInfoValue"), pair.Value);
}
html = BuildSuiteBlocks(report, html, outputFile);
}
catch (Exception ex)
{
Console.WriteLine("Something weird happened: " + ex.Message);
return null;
}
}
else
{
// replace OPTIONALCSS here with css to hide elements
html = html.Replace(ReportHelper.MarkupFlag("noTestsMessage"), HTML.File.NoTestsMessage)
.Replace(ReportHelper.MarkupFlag("optionalCss"), HTML.File.NoTestsCss + ReportHelper.MarkupFlag("optionalCss"))
.Replace(ReportHelper.MarkupFlag("inXml"), Path.GetFileName(resultsFile));
}
// finally, save the source as the output file
if (_source == null)
File.WriteAllText(outputFile, html.Apply(_theme));
else
_source.SourceFiles.Add(outputFile, html.Apply(_theme));
return report;
}