public void LintingPerformedExitCodeTest(string testFile, int expectedExitCode) { // var fileLinted = false; void OutputHandler(object sender, DataReceivedEventArgs args) { // if (args.Data != null && args.Data.Contains("Linted 1 files")) // { // fileLinted = true; // } } void ErrorHandler(object sender, DataReceivedEventArgs args) { } void ExitHandler(object sender, EventArgs args) { var processExitCode = ((Process)sender).ExitCode; Assert.AreEqual(expectedExitCode, processExitCode, $"Exit code should be {expectedExitCode}"); } var path = Path.GetFullPath(Path.Combine(testDirectoryPath, $@"FunctionalTests/{testFile}")); var configFilePath = Path.GetFullPath(Path.Combine(testDirectoryPath, @"FunctionalTests/.tsqllintrc")); var process = ConsoleAppTestHelper.GetProcess($"-c {configFilePath} {path}", OutputHandler, ErrorHandler, ExitHandler); ConsoleAppTestHelper.RunApplication(process); // Assert.IsTrue(fileLinted); }
public void LintingPerformedExitCodeTest(string testFile, int expectedExitCode) { void OutputHandler(object sender, DataReceivedEventArgs args) { TestContext.Out.WriteLine(args.Data); } void ErrorHandler(object sender, DataReceivedEventArgs args) { } void ExitHandler(object sender, EventArgs args) { var processExitCode = ((Process)sender).ExitCode; Assert.AreEqual(expectedExitCode, processExitCode, $"Exit code should be {expectedExitCode}"); } var path = Path.GetFullPath(Path.Combine(testDirectoryPath, $@"FunctionalTests/{testFile}")); var configFilePath = Path.GetFullPath(Path.Combine(testDirectoryPath, @"FunctionalTests/.tsqllintrc")); var process = ConsoleAppTestHelper.GetProcess($"-c {configFilePath} {path}", OutputHandler, ErrorHandler, ExitHandler); ConsoleAppTestHelper.RunApplication(process); }
public void LoadPluginTest(string testArgs, string expectedMessage, int expectedExitCode) { var pluginLoaded = false; void OutputHandler(object sender, DataReceivedEventArgs args) { if (args.Data != null && args.Data.Contains(expectedMessage)) { pluginLoaded = true; } } void ErrorHandler(object sender, DataReceivedEventArgs args) { } void ExitHandler(object sender, EventArgs args) { var processExitCode = ((Process)sender).ExitCode; Assert.AreEqual(expectedExitCode, processExitCode, $"Exit code should be {expectedExitCode}"); } var configFilePath = Path.GetFullPath(Path.Combine(testDirectoryPath, @"FunctionalTests/.tsqllintrc-plugins")); var jsonString = File.ReadAllText(configFilePath); dynamic jsonObject = Newtonsoft.Json.JsonConvert.DeserializeObject(jsonString); jsonObject["plugins"]["test-plugin"] = ConsoleAppTestHelper.TestPluginPath; var updatedConfigFilePath = Path.Combine(testDirectoryPath, @"FunctionalTests/.tsqllintrc-plugins-updated"); File.WriteAllText(updatedConfigFilePath, jsonObject.ToString()); var process = ConsoleAppTestHelper.GetProcess($"-c {updatedConfigFilePath} {testArgs}", OutputHandler, ErrorHandler, ExitHandler); ConsoleAppTestHelper.RunApplication(process); Assert.IsTrue(pluginLoaded); // remove updated plugin config file File.Delete(updatedConfigFilePath); }
public void NoLintingPerformedExitCodeTest(string arguments, int expectedExitCode) { void OutputHandler(object sender, DataReceivedEventArgs args) { } void ErrorHandler(object sender, DataReceivedEventArgs args) { } void ExitHandler(object sender, EventArgs args) { var processExitCode = ((Process)sender).ExitCode; Assert.AreEqual(expectedExitCode, processExitCode, $"Exit code should be {expectedExitCode}"); } var process = ConsoleAppTestHelper.GetProcess(arguments, OutputHandler, ErrorHandler, ExitHandler); ConsoleAppTestHelper.RunApplication(process); }