コード例 #1
0
        public void TestValidatePanoramaSettings()
        {
            var logger   = new TestLogger();
            var settings = new PanoramaSettings();

            var mainControl = new TestAppControl();

            mainControl.SetUIPanoramaSettings(settings);

            var panoramaSettingsTab = new PanoramaSettingsTab(mainControl, logger);

            Assert.IsTrue(panoramaSettingsTab.ValidateSettings());
            var log = logger.GetLog();

            Assert.IsTrue(log.Contains("Will NOT publish Skyline documents to Panorama."));

            settings.PublishToPanorama = true;
            logger.Clear();
            panoramaSettingsTab.Settings = settings;
            Assert.IsFalse(panoramaSettingsTab.ValidateSettings());
            log = logger.GetLog();
            Assert.IsTrue(log.Contains("Please specify a Panorama server URL."));
            Assert.IsTrue(log.Contains("Please specify a Panorama login name."));
            Assert.IsTrue(log.Contains("Please specify a Panorama user password."));
            Assert.IsTrue(log.Contains("Please specify a folder on the Panorama server."));
        }
コード例 #2
0
        public void TestValidateSettings()
        {
            var logger          = new TestLogger();
            var mainControl     = new TestAppControl();
            var mainSettingsTab = new MainSettingsTab(mainControl, logger);

            Assert.IsFalse(mainSettingsTab.ValidateSettings());
            var log = logger.GetLog();

            Assert.IsTrue(log.Contains("Please specify path to a Skyline file."));
            Assert.IsTrue(log.Contains("Please specify path to a folder where mass spec. files will be written."));
            Assert.IsTrue(log.Contains("Please specify a value for the \"Accumulation time window\"."));

            const string skyPath     = "C:\\dummy\\path\\Test.sky";
            const string folderPath  = "C:\\dummy\\path";
            var          accumWindow = "not a number";

            var settings = new MainSettings()
            {
                SkylineFilePath     = skyPath,
                FolderToWatch       = folderPath,
                ResultsWindowString = "not a number",
                // ImportExistingFiles = false
            };

            mainControl = new TestAppControl();
            mainControl.SetUIMainSettings(settings);

            mainSettingsTab = new MainSettingsTab(mainControl, logger);
            logger.Clear();
            Assert.IsFalse(mainSettingsTab.ValidateSettings());
            log = logger.GetLog();
            Assert.IsTrue(log.Contains(string.Format("Skyline file {0} does not exist.", skyPath)));
            Assert.IsTrue(log.Contains(string.Format("Folder {0} does not exist.", folderPath)));
            Assert.IsTrue(log.Contains(string.Format("Invalid value for \"Accumulation time window\": {0}.", accumWindow)));

            accumWindow = "-1";
            settings.ResultsWindowString = accumWindow;
            logger.Clear();
            mainSettingsTab = new MainSettingsTab(mainControl, logger);
            Assert.IsFalse(mainSettingsTab.ValidateSettings());
            log = logger.GetLog();
            Assert.IsTrue(
                log.Contains(string.Format("\"Accumulation time window\" cannot be less than {0} days.",
                                           MainSettings.ACCUM_TIME_WINDOW)));
        }
コード例 #3
0
        public void TestValidatePanoramaSettings()
        {
            var logger = new TestLogger();
            var settings = new PanoramaSettings();

            var mainControl = new TestAppControl();
            mainControl.SetUIPanoramaSettings(settings);

            var panoramaSettingsTab = new PanoramaSettingsTab(mainControl, logger);

            Assert.IsTrue(panoramaSettingsTab.ValidateSettings());
            var log = logger.GetLog();
            Assert.IsTrue(log.Contains("Will NOT publish Skyline documents to Panorama."));

            settings.PublishToPanorama = true;
            logger.Clear();
            panoramaSettingsTab.Settings = settings;
            Assert.IsFalse(panoramaSettingsTab.ValidateSettings());
            log = logger.GetLog();
            Assert.IsTrue(log.Contains("Please specify a Panorama server URL."));
            Assert.IsTrue(log.Contains("Please specify a Panorama login name."));
            Assert.IsTrue(log.Contains("Please specify a Panorama user password."));
            Assert.IsTrue(log.Contains("Please specify a folder on the Panorama server."));
        }
コード例 #4
0
        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   = new MainSettings
            {
                FolderToWatch         = testDir,
                InstrumentType        = "NoInstrument",
                ResultsWindowString   = "31",
                AcquisitionTimeString = "0"
            };

            // Start the background worker.
            var backgroundWorker = new AutoQCBackgroundWorker(appControl, processControl, logger);

            backgroundWorker.Start(mainSettings);
            Assert.IsTrue(backgroundWorker.IsRunning());

            // 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(backgroundWorker.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+", ""));
        }
コード例 #5
0
        public void TestValidateSettings()
        {
            var logger = new TestLogger();
            var mainControl = new TestAppControl();
            var mainSettingsTab = new MainSettingsTab(mainControl, logger);
            Assert.IsFalse(mainSettingsTab.ValidateSettings());
            var log = logger.GetLog();
            Assert.IsTrue(log.Contains("Please specify path to a Skyline file."));
            Assert.IsTrue(log.Contains("Please specify path to a folder where mass spec. files will be written."));
            Assert.IsTrue(log.Contains("Please specify a value for the \"Accumulation time window\"."));

            const string skyPath = "C:\\dummy\\path\\Test.sky";
            const string folderPath = "C:\\dummy\\path";
            var accumWindow = "not a number";

            var settings = new MainSettings()
            {
                SkylineFilePath = skyPath,
                FolderToWatch = folderPath,
                ResultsWindowString = "not a number",
                // ImportExistingFiles = false
            };
            mainControl = new TestAppControl();
            mainControl.SetUIMainSettings(settings);

            mainSettingsTab = new MainSettingsTab(mainControl, logger);
            logger.Clear();
            Assert.IsFalse(mainSettingsTab.ValidateSettings());
            log = logger.GetLog();
            Assert.IsTrue(log.Contains(string.Format("Skyline file {0} does not exist.", skyPath)));
            Assert.IsTrue(log.Contains(string.Format("Folder {0} does not exist.", folderPath)));
            Assert.IsTrue(log.Contains(string.Format("Invalid value for \"Accumulation time window\": {0}.", accumWindow)));

            accumWindow = "-1";
            settings.ResultsWindowString = accumWindow;
            logger.Clear();
            mainSettingsTab = new MainSettingsTab(mainControl, logger);
            Assert.IsFalse(mainSettingsTab.ValidateSettings());
            log = logger.GetLog();
            Assert.IsTrue(
                log.Contains(string.Format("\"Accumulation time window\" cannot be less than {0} days.",
                    MainSettings.ACCUM_TIME_WINDOW)));
        }
コード例 #6
0
        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 = new MainSettings
            {
                FolderToWatch = testDir,
                InstrumentType = "NoInstrument",
                ResultsWindowString = "31",
                AcquisitionTimeString = "0"
            };

            // Start the background worker.
            var backgroundWorker = new AutoQCBackgroundWorker(appControl, processControl, logger);
            backgroundWorker.Start(mainSettings);
            Assert.IsTrue(backgroundWorker.IsRunning());

            // 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(backgroundWorker.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 both times. This should stop the program.
            while (!processControl.IsDone())
            {
                Thread.Sleep(500);
            }

            // Assert.IsTrue(appControl.Waiting);
            Thread.Sleep(2 * AutoQCBackgroundWorker.WAIT_5SEC);
            Assert.IsTrue(appControl.Stopped);

            Assert.AreEqual(Regex.Replace(logger.GetLog(), @"\s+", ""),
                Regex.Replace(GetExpectedLog_ProcessNew(), @"\s+", ""));
        }