public void TestStoreProcedure(string testFile) { var currentConsoleOut = Console.Out; string path = Path.Combine(_testDirectoryPath, testFile); var ruleExceptions = new List <IRuleException>(); var reporter = new ConsoleReporter(); var startTime = DateTime.Now; using (TextReader textReader = File.OpenText(path)) { var pluginContext = new PluginContext(path, ruleExceptions, textReader); IPlugin plugin = new MyPlugin(); plugin.PerformAction(pluginContext, reporter); } var endtime = DateTime.Now; var duration = startTime - endtime; using (var consoleOutput = new ConsoleOutput()) { reporter.ReportResults(duration, 4); NonBlockingConsole.Consumer(); var consoleOutputValues = consoleOutput.GetOuput().Split('\n'); var result = consoleOutputValues?.Where(x => x.Trim().EndsWith("Errors.")) .FirstOrDefault(); switch (testFile) { case "usp_GetCurrency1.sql": Assert.AreEqual("2 Errors.", result); break; case "usp_GetCurrency2.sql": Assert.AreEqual("0 Errors.", result); break; case "usp_GetCurrency.sql": Assert.AreEqual("1 Errors.", result); break; case "usp_GetCurrency3.sql": Assert.AreEqual("2 Errors.", result); break; } } Assert.AreEqual(currentConsoleOut, Console.Out); }