public async Task TestExecuteCommandLine() { TestUtils.InitializeInstallations(); var testRunner = new ConfigRunner(TestUtils.GetTestConfig(), new SkylineBatchLogger(TestUtils.GetTestFilePath("testLog.log"))); Assert.IsTrue(testRunner.IsStopped()); var singleCommand = new List <string> { "echo command success > " + TestUtils.GetTestFilePath("cmdTest.txt") }; await testRunner.ExecuteCommandLine(singleCommand); Assert.IsTrue(File.Exists(TestUtils.GetTestFilePath("cmdTest.txt"))); Assert.IsTrue(testRunner.IsCompleted()); var multipleCommands = new List <string> { "cd " + TestUtils.GetTestFilePath(""), "del cmdTest.txt" }; await testRunner.ExecuteCommandLine(multipleCommands); Assert.IsFalse(File.Exists(TestUtils.GetTestFilePath("cmdTest.txt"))); Assert.IsTrue(testRunner.IsCompleted()); }
public void TestBackgroundWorker_ProcessNewFiles() { // Create a test directory to monitor var dir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); Assert.IsNotNull(dir); var testDir = Path.Combine(dir, "TestBackgroundWorker"); if (Directory.Exists(testDir)) { Directory.Delete(testDir, true); } Assert.IsFalse(Directory.Exists(testDir)); Directory.CreateDirectory(testDir); Assert.IsTrue(Directory.Exists(testDir)); var appControl = new TestAppControl(); var logger = new TestLogger(); var processControl = new TestProcessControl(logger); var mainSettings = MainSettings.GetDefault(); mainSettings.FolderToWatch = testDir; mainSettings.InstrumentType = "NoInstrument"; AutoQcConfig config = new AutoQcConfig(); config.MainSettings = mainSettings; config.PanoramaSettings = PanoramaSettings.GetDefault(); config.Name = "Test Config"; config.IsEnabled = true; var configRunner = new ConfigRunner(config, appControl); // Start the background worker. // configRunner.Start(); //Thread.Sleep(1000); // Assert.IsTrue(configRunner.IsBusy()); // Create a new file in the test directory. // Thread.Sleep(1000); CreateNewFile(testDir, "test1.txt"); // // Wait till the the file has been processed. // while (!processControl.IsDone()) // { // Thread.Sleep(500); // } // Assert.IsTrue(configRunner.IsRunning()); // // // Create another file in the test directory. // Thread.Sleep(1000); // CreateNewFile(testDir, "test2.txt"); // // // Wait till the the file has been processed. // // Process4 returns exit code 1. This should put the file in the re-import queue. // while (!processControl.IsDone()) // { // Thread.Sleep(500); // } // // // Assert.IsTrue(appControl.Waiting); // Thread.Sleep(2 * AutoQCBackgroundWorker.WAIT_FOR_NEW_FILE); // //Assert.IsTrue(appControl.Waiting); // // Assert.AreEqual(Regex.Replace(logger.GetLog(), @"\s+", ""), // Regex.Replace(GetExpectedLog_ProcessNew(), @"\s+", "")); }
public void ChangeConfigUiStatus(ConfigRunner configRunner) { _runnerStatus = configRunner.GetStatus(); }