Example #1
0
        public void UpdateToolTip()
        {
            if (IsTestStep())
            {
                var testStep = TestScriptObject as TestStep;

                ToolTipText =
                    string.Format("Title:  {0}\r\nTest type:  {1}\r\nStatus:  {2}\r\nDescription:  {3}\r\nExpected:  {4}{5}",
                                  testStep.Title,
                                  testStep.TestType.ToString(),
                                  testStep.Status,
                                  testStep.Description != null ? testStep.Description : "None",
                                  testStep.ExpectedBehavior != null ? testStep.ExpectedBehavior : "None",
                                  testStep.TestType == TestType.Automated ? "\r\n\r\n" + testStep.TestAutomationDefinition.ToString() : null);
            }
            else
            {
                // Provide file path if test suite.
                var fileText = TestScriptObject is TestSuite ? $"File:  {TestProperties.ExpandString(((TestSuite)TestScriptObject).FilePath)}" : string.Empty;

                ToolTipText = string.Format("Title:  {0}\r\nStatus:  {1}\r\n{2}\r\nDescription:  {3}",
                                            TestScriptObject.Title,
                                            TestScriptObject.Status,
                                            fileText,
                                            TestScriptObject.Description != null ? TestScriptObject.Description : "None");
            }
        }
        public void saveAsTestSuite()
        {
            try
            {
                m_saveFileDialog.Title            = "Save Test Suite As";
                m_saveFileDialog.InitialDirectory = TestProperties.TestSuites;
                m_saveFileDialog.RestoreDirectory = true;
                m_saveFileDialog.Filter           = "Test suites (*.ste)|*.ste";
                m_saveFileDialog.FilterIndex      = 1;

                DialogResult result = m_saveFileDialog.ShowDialog();

                if (result == DialogResult.OK)
                {
                    TestSuite testSuite = new TestSuite(m_testTreeView.GetTestSuite(), m_saveFileDialog.FileName, null);

                    saveTestSuite(testSuite);
                    m_testTreeView.RootNode.TestScriptObject = testSuite;
                    m_testTreeView.RootNode.TestScriptResult = null;

                    // Clean up UI
                    m_testSuiteUri = new Uri(TestProperties.ExpandString(testSuite.FilePath));
                    setCaption();
                    m_fileSaveAsMenuItem.Enabled  = false;
                    m_saveToolStripButton.Enabled = false;
                }
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message, "Quintity TestEngineer", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        private void openTestProperitesFile()
        {
            var openFileDialog = new OpenFileDialog();

            try
            {
                openFileDialog.Title            = "Quintity TestFramework - Load Test Properties";
                openFileDialog.InitialDirectory = TestProperties.ExpandString("[TestHome]\\TestProperties");
                openFileDialog.RestoreDirectory = true;
                openFileDialog.Filter           = "Test properties (*.props)|*.props|All files (*.*)|*.*";
                openFileDialog.FilterIndex      = 1;
                openFileDialog.FileName         = null;

                if (DialogResult.OK == openFileDialog.ShowDialog())
                {
                    newTestProperties(openFileDialog.FileName);
                }
            }
            catch (Exception e)
            {
                MessageBox.Show(this, $"An error has occurred loading file \"{openFileDialog.FileName}\":" +
                                $"{Environment.NewLine}{Environment.NewLine}{e.Message}{Environment.NewLine}{Environment.NewLine}" +
                                "Please select another file.", "Quintity TestFramework",
                                MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
 private void initializeTestProfile()
 {
     try
     {
         if (!string.IsNullOrEmpty(Program.TestPerformanceFile))
         {
             m_testProfileUri           = new Uri(TestProperties.ExpandString(Program.TestPerformanceFile));
             m_testTreeView.TestProfile = TestProfile.ReadFromFile(m_testProfileUri.LocalPath);
         }
     }
     catch (FileNotFoundException)
     {
         MessageBox.Show(
             string.Format("Unable to locate test performance file \"{0}\".\r\n\r\nPlease verify the file path.", Program.TestPerformanceFile),
             "Quintity TestEngineer", MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
     catch (SerializationException)
     {
         MessageBox.Show(
             string.Format("Unable to read test performance \"{0}\".\r\n\r\nPlease verify the file is a valid test performance file.", Program.TestPerformanceFile),
             "Quintity TestEngineer", MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
     catch (UriFormatException)
     {
         MessageBox.Show(
             string.Format("Unable to read test performance \"{0}\".\r\n\r\nPlease verify the file is a valid test performance file.", Program.TestPerformanceFile),
             "Quintity TestEngineer", MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
     catch (Exception e)
     {
         MessageBox.Show(e.Message, "Quintity TestEngineer", MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
 }
        /// <summary>
        /// Gets new Save As file name via common dialog
        /// </summary>
        /// <returns></returns>
        private string getNewFileName()
        {
            SaveFileDialog m_saveFileDialog = new SaveFileDialog();

            m_saveFileDialog.Title            = "Save Test Properties";
            m_saveFileDialog.InitialDirectory = TestProperties.ExpandString(TestProperties.GetPropertyValueAsString("TestProperties"));
            m_saveFileDialog.RestoreDirectory = true;
            m_saveFileDialog.Filter           = "Test properties (*.props)|*.props";
            m_saveFileDialog.FilterIndex      = 1;

            DialogResult result = m_saveFileDialog.ShowDialog();

            return(m_saveFileDialog.FileName);
        }
 private void initializeTestSuite()
 {
     if (!string.IsNullOrEmpty(Program.TestSuiteFile))
     {
         if (null == loadTestSuite(TestProperties.ExpandString(Program.TestSuiteFile)))
         {
             openTestSuite();
         }
     }
     else
     {
         m_testTreeView.DisplayDefaultScreen();
     }
 }
Example #7
0
 private void initializeTestSuite()
 {
     if (!string.IsNullOrEmpty(Program.TestSuiteFile))
     {
         if (null == loadTestSuite(TestProperties.ExpandString(Program.TestSuiteFile)))
         {
             openTestSuite();
         }
     }
     else
     {
         newTestSuite();
     }
 }
        public override object EditValue(System.ComponentModel.ITypeDescriptorContext context, System.IServiceProvider provider, object value)
        {
            try
            {
                edSvc = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));

                if (edSvc != null)
                {
                    ListBox listbox = new ListBox();

                    listbox.SelectedIndexChanged += bx_SelectedIndexChanged;

                    var listener = context.Instance as TestListenerDescriptor;

                    if (!string.IsNullOrEmpty(listener.Assembly))
                    {
                        Assembly assembly = Assembly.LoadFrom(TestProperties.ExpandString(listener.Assembly));

                        Type[] types = assembly.GetTypes();

                        foreach (Type type in types)
                        {
                            if (TestListener.IsTestListenerType(type))
                            {
                                listbox.Items.Add(type.FullName);
                            }
                        }

                        edSvc.DropDownControl(listbox);
                    }

                    return(listbox.SelectedItem != null ? ((string)(listbox.SelectedItem)) : value);
                }
            }
            catch (Exception e)
            {
                if (e is System.Reflection.ReflectionTypeLoadException)
                {
                    var typeLoadException = e as ReflectionTypeLoadException;
                    var loaderExceptions  = typeLoadException.LoaderExceptions;
                }

                //TestListenersEditorDialog.DisplayErrorMessage(e.Message);
            }

            return(value);
        }
Example #9
0
        public static void ReadFromFile(string testListenersFile)
        {
            Uri testListenersUri = new Uri(testListenersFile);

            _testListenersCollection = TestListenerCollection.DeserializeFromFile(testListenersUri.LocalPath);

            // Expand each assembly path.
            foreach (TestListenerDescriptor listener in _testListenersCollection)
            {
                if (listener.Assembly != null)
                {
                    listener.Assembly = TestProperties.ExpandString(listener.Assembly);
                }
            }

            TestListenersFile = testListenersFile;
        }
        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);
        }
Example #11
0
        private static TestSuite loadTestSuite(string testSuiteFile)
        {
            TestSuite testSuite = null;

            try
            {
                if (string.IsNullOrEmpty(testSuiteFile))
                {
                    throw new ArgumentException("The test suite cannot be a null or empty value");
                }

                testSuiteFile = TestProperties.ExpandString(testSuiteFile);
                testSuite     = TestSuite.DeserializeFromFile(testSuiteFile);
            }
            catch (FileNotFoundException)
            {
                LogEvent.Fatal(
                    string.Format("Unable to locate test suite file \"{0}\".\r\n\r\nPlease verify the file path.", testSuiteFile));

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

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

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

                exitCode = ExitCode.TestSuiteError;
            }

            return(testSuite);
        }
        private static TestProfile initializeTestProfile(string testPerformanceFile)
        {
            TestProfile testProfile = null;

            try
            {
                if (!string.IsNullOrEmpty(testPerformanceFile))
                {
                    var testProfileUri = new Uri(TestProperties.ExpandString(testPerformanceFile));
                    testProfile = TestProfile.ReadFromFile(testProfileUri.LocalPath);
                }
            }
            catch (FileNotFoundException)
            {
                LogEvent.Fatal(
                    string.Format("Unable to locate test performance file \"{0}\".\r\n\r\nPlease verify the file path.", testPerformanceFile));

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

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

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

                exitCode = ExitCode.TestProfileError;
            }

            return(testProfile);
        }
        private void m_loadTestPropertiesMenuItem_Click(object sender, EventArgs e)
        {
            m_openFileDialog.Title            = "Load Test Properties";
            m_openFileDialog.InitialDirectory = TestProperties.ExpandString("[TestHome]\\TestProperties");
            m_openFileDialog.RestoreDirectory = true;
            m_openFileDialog.Filter           = "Test properties (*.props)|*.props|All files (*.*)|*.*";
            m_openFileDialog.FilterIndex      = 1;
            m_openFileDialog.FileName         = null;

            if (DialogResult.OK == m_openFileDialog.ShowDialog())
            {
                Uri testProperties = loadTestProperties(m_openFileDialog.FileName);

                if (testProperties != null)
                {
                    m_testPropertiesUri = testProperties;
                    m_testPropertiesStatusBarLabel.Text = m_testPropertiesUri.LocalPath;
                }
            }
        }
Example #14
0
        public void saveAsTestSuite()
        {
            try
            {
                var testSuite = m_testTreeView.GetTestSuite();

                m_saveFileDialog.Title            = "Save Test Suite As";
                m_saveFileDialog.FileName         = string.IsNullOrEmpty(testSuite.FileName) ? string.Empty : $"Copy of {testSuite.Title}";
                m_saveFileDialog.InitialDirectory = TestProperties.TestSuites;
                m_saveFileDialog.RestoreDirectory = true;
                m_saveFileDialog.Filter           = "Test suites (*.ste)|*.ste";
                m_saveFileDialog.FilterIndex      = 1;

                DialogResult result = m_saveFileDialog.ShowDialog();

                if (result == DialogResult.OK)
                {
                    testSuite.FileSaveAs(m_saveFileDialog.FileName);

                    //saveTestSuite(testSuite);
                    m_testTreeView.RootNode.TestScriptObject = testSuite;
                    m_testTreeView.RootNode.TestScriptResult = null;

                    // Clean up UI
                    m_testSuiteUri = new Uri(TestProperties.ExpandString(testSuite.FilePath));
                    m_testTreeView.ResetHasChangedFlags();

                    m_fileSaveMenuItem.Enabled = false;
                    //m_fileSaveAsMenuItem.Enabled = false;
                    m_saveToolStripButton.Enabled = false;

                    m_testPropertyGrid.SelectedObject = m_testTreeView.RootNode.TestScriptObject;

                    setCaption();
                }
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message, "Quintity TestEngineer", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        public static TestListenerCollection DeserializeFromFile(string filePath)
        {
            FileStream             reader        = null;
            TestListenerCollection testListeners = null;

            try
            {
                // Create DataContractSerializer.
                System.Runtime.Serialization.DataContractSerializer serializer =
                    new System.Runtime.Serialization.DataContractSerializer(typeof(TestListenerCollection));

                // Create a file stream to read into.
                reader = new FileStream(filePath, FileMode.Open, FileAccess.Read);

                // Read into object.
                testListeners = serializer.ReadObject(reader) as TestListenerCollection;

                // Fixup assembly path to TestListeners definition.
                foreach (TestListenerDescriptor descriptor in testListeners)
                {
                    TestProperties.ExpandString(descriptor.Assembly);

                    descriptor.Parameters = descriptor.Parameters ?? new Dictionary <string, string>();
                }
            }
            catch
            {
                throw;
            }
            finally
            {
                if (reader != null)
                {
                    // Close file.
                    reader.Close();
                }
            }

            return(testListeners);
        }
Example #16
0
        /// <summary>
        /// Iterates through the test listener collection for active listeners s
        /// expanding each parameter value for subsequent use.
        /// </summary>
        /// <param name="testListeners">The passed in test listener collection.</param>
        /// <returns>Fixed up collection.</returns>
        private TestListenerCollection fixupTestListeners(TestListenerCollection testListeners)
        {
            var activeListeners = testListeners.FindAll(x => x.Status == Status.Active && x.Parameters != null);

            foreach (var activeListener in activeListeners)
            {
                // Create new collection to hold updated values.
                var newParameters = new Dictionary <string, string>();

                foreach (var parameter in activeListener.Parameters)
                {
                    var key           = parameter.Key;
                    var expandedValue = TestProperties.ExpandString(parameter.Value);
                    newParameters.Add(key, expandedValue);
                }

                // Replace old collection with fixedup collection.
                activeListener.Parameters = newParameters;
            }

            // Return fixed up collection
            return(new TestListenerCollection(activeListeners));
        }