Exemplo n.º 1
0
        public TestVerdict ListenersService(string listenerConfig)
        {
            try
            {
                Setup();

                var bob = new TestListenerCollection();

                TestListeners.ReadFromFile(listenerConfig);
                var listeners = TestListeners.TestListenerCollection.ToArray();

                _listenerEventsClient.InitializeService(listeners, null);

                TestMessage += "Completed!";
                TestVerdict  = TestVerdict.Pass;
            }
            catch (Exception e)
            {
                TestMessage += e.ToString();
                TestVerdict  = TestVerdict.Error;
            }
            finally
            {
            }

            return(TestVerdict);
        }
 private void initializeTestListeners()
 {
     try
     {
         if (!string.IsNullOrEmpty(Program.TestListenersFile))
         {
             m_testListenersUri = new Uri(TestProperties.ExpandString(Program.TestListenersFile));
             TestListeners.ReadFromFile(m_testListenersUri.LocalPath);
         }
     }
     catch (FileNotFoundException)
     {
         MessageBox.Show(
             string.Format("Unable to locate test listeners file \"{0}\".\r\n\r\nPlease verify the file path.", Program.TestListenersFile),
             "Quintity TestEngineer", MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
     catch (SerializationException)
     {
         MessageBox.Show(
             string.Format("Unable to read test listeners \"{0}\".\r\n\r\nPlease verify the file is a valid test properties file.", Program.TestListenersFile),
             "Quintity TestEngineer", MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
     catch (UriFormatException)
     {
         MessageBox.Show(
             string.Format("Unable to read test listeners \"{0}\".\r\n\r\nPlease verify the file is a valid test properties file.", Program.TestListenersFile),
             "Quintity TestEngineer", MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
     catch (Exception e)
     {
         MessageBox.Show(e.Message, "Quintity TestEngineer", MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
 }
        void m_listenersEditorDlg_FormClosed(object sender, FormClosedEventArgs e)
        {
            if (_promptListenerReload)
            {
                _promptListenerReload = false;

                var result = MessageBox.Show(this,
                                             string.Format("The currently loaded test listeners file has changed:\r\n\r\n\"{0}\".\r\n\r\nDo you wish to reload it?",
                                                           m_testListenersUri.LocalPath),
                                             "Quintity TestEngineer", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

                if (result == DialogResult.Yes)
                {
                    TestListeners.ReadFromFile(m_testListenersUri.LocalPath);
                }
            }
        }
        private static bool initializeTestListeners(string testListenersFile)
        {
            bool success = false;

            try
            {
                if (!string.IsNullOrEmpty(testListenersFile))
                {
                    //throw new ArgumentException("The test listener file cannot be a null or empty value");
                    var testListenersUri = new Uri(TestProperties.ExpandString(testListenersFile));
                    TestListeners.ReadFromFile(testListenersUri.LocalPath);
                }

                success = true;
            }
            catch (FileNotFoundException)
            {
                LogEvent.Fatal(
                    string.Format("Unable to locate test listeners file \"{0}\".\r\n\r\nPlease verify the file path.", testListenersFile));

                exitCode = ExitCode.TestListenersError;
            }
            catch (SerializationException)
            {
                LogEvent.Fatal(
                    string.Format("Unable to read test listeners \"{0}\".\r\n\r\nPlease verify the file is a valid test listeners file.", testListenersFile));

                exitCode = ExitCode.TestListenersError;
            }
            catch (UriFormatException)
            {
                LogEvent.Fatal(
                    string.Format("Unable to read test listeners \"{0}\".\r\n\r\nPlease verify the file is a valid test listeners file.", testListenersFile));

                exitCode = ExitCode.TestListenersError;
            }
            catch (Exception e)
            {
                LogEvent.Fatal(e.Message);

                exitCode = ExitCode.TestListenersError;
            }

            return(success);
        }