private static void Compare(CommandLineOptions args, IResultsComparerProvider comparerProvider, IReporterProvider reporterProvider) { try { IResultsComparer comparer = string.IsNullOrEmpty(args.Comparer) ? comparerProvider.GetForFile(args.BasePath) : comparerProvider.GetById(args.Comparer); Console.WriteLine($"Comparer selected: {comparer.Name}\n"); ComparerOptions options = new() { StatisticalTestThreshold = args.StatisticalTestThreshold, NoiseThreshold = args.NoiseThreshold, FullId = args.FullId, TopCount = args.TopCount, Filters = args.Filters, Metric = args.Metric }; ComparerResults results = comparer.CompareResults(args.BasePath, args.DiffPath, options); IReporter reporter = reporterProvider.GetDefault(); Stream output = Console.OpenStandardOutput(); reporter.GenerateReport(results, output, options, leaveStreamOpen: true); } catch (Exception ex) { Console.Error.WriteLine($"Error: {ex.Message}"); } }
public void ComparerReportFilesAndGenerateMarkdownReport(string comparerId, ComparerOptions options, string basePath, string diffPath, string reportPath) { IResultsComparerProvider comparerProvider = ComparerProviderFactory.CreateDefaultProvider(); IResultsComparer comparer = comparerProvider.GetById(comparerId); ComparerResults results = comparer.CompareResults(basePath, diffPath, options); MarkdownReporter reporter = new(); using MemoryStream output = new(); reporter.GenerateReport(results, output, options, leaveStreamOpen: true); output.Seek(0, SeekOrigin.Begin); string expectedReport = File.ReadAllText(reportPath); string actualReport = new StreamReader(output).ReadToEnd(); Assert.Equal(expectedReport, actualReport); }