/// <summary>
        /// Process a result.
        /// </summary>
        /// <param name="result">The result data.</param>
        private void ProcessResult(ScenarioResult result)
        {
            TestClassData  tac = GetClassModel(result.TestClass);
            TestMethodData tmd = GetMethodModel(result.TestMethod, tac);

            tmd.IsRunning = false;

            tmd.IsNotable = !tmd.Passed;

            if (_d == null)
            {
                return;
            }

            // Link to previous
            tmd.PreviousResult = _lastResult;
            _lastResult        = tmd;

            _d.RunScenarios++;
            if (result.Result != TestOutcome.Passed)
            {
                _d.FailedScenarios++;

                // Link to previous failure
                tmd.PreviousFailingResult = _lastFailingResult;
                _lastFailingResult        = tmd;

                // Automatically check the item for the user
                tmd.IsChecked = true;
            }

            tmd.Result = result;
        }
        /// <summary>
        /// Process the test class starting event.
        /// </summary>
        /// <param name="sender">The source object.</param>
        /// <param name="e">The event data.</param>
        private void OnTestClassStarting(object sender, TestClassStartingEventArgs e)
        {
            TestClassData tac = GetClassModel(e.TestClass);

            tac.IsExpanded = true;

            _d.CurrentTest = e.TestClass.Name;
        }
        /// <summary>
        /// Process the test class complete event.
        /// </summary>
        /// <param name="sender">The source object.</param>
        /// <param name="e">The event data.</param>
        private void OnTestClassCompleted(object sender, TestClassCompletedEventArgs e)
        {
            TestClassData tac = GetClassModel(e.TestClass);

            if (tac != null)
            {
                tac.CollapseUnlessFailures();
            }
        }
    /// <summary>
    /// Initializes a new instance of the TestMethodData type.
    /// </summary>
    /// <param name="testMethod">The test method metadata.</param>
    /// <param name="parent">The test class that is the parent object.</param>
    public TestMethodData(ITestMethod testMethod, TestClassData parent)
    {
      if (testMethod == null)
      {
        throw new ArgumentNullException("testMethod");
      }

      _parent = parent;
      _metadata = testMethod;
    }
Exemple #5
0
        /// <summary>
        /// Initializes a new instance of the TestMethodData type.
        /// </summary>
        /// <param name="testMethod">The test method metadata.</param>
        /// <param name="parent">The test class that is the parent object.</param>
        public TestMethodData(ITestMethod testMethod, TestClassData parent)
        {
            if (testMethod == null)
            {
                throw new ArgumentNullException("testMethod");
            }

            _parent   = parent;
            _metadata = testMethod;
        }
        /// <summary>
        /// Process the start of a test method.
        /// </summary>
        /// <param name="sender">The source object.</param>
        /// <param name="e">The event data.</param>
        private void OnTestMethodStarting(object sender, TestMethodStartingEventArgs e)
        {
            TestClassData  tac = GetClassModel(e.TestClass);
            TestMethodData tmd = GetMethodModel(e.TestMethod, tac);

            if (!tac.IsExpanded)
            {
                tac.IsExpanded = true;
            }
            tmd.IsRunning = true;

            _d.CurrentTestMethod = e.TestMethod.Name;
        }
        /// <summary>
        /// Gets or creates the data model object for a test method.
        /// </summary>
        /// <param name="testMethod">The test method.</param>
        /// <param name="parentTestClass">The parent test class data object.</param>
        /// <returns>Returns the data object.</returns>
        public TestMethodData GetMethodModel(ITestMethod testMethod, TestClassData parentTestClass)
        {
            TestMethodData data;

            if (!_methodData.TryGetValue(testMethod, out data))
            {
                data = new TestMethodData(testMethod, parentTestClass);
                _methodData.Add(testMethod, data);

                // Make sure in parent collection
                parentTestClass.TestMethods.Add(data);
            }

            return(data);
        }
        /// <summary>
        /// Gets or creates the data model object for a test class.
        /// </summary>
        /// <param name="testClass">The test class.</param>
        /// <returns>Returns the data object.</returns>
        public TestClassData GetClassModel(ITestClass testClass)
        {
            TestClassData data;

            if (!_classData.TryGetValue(testClass, out data))
            {
                TestAssemblyData tad = GetAssemblyModel(testClass.Assembly);
                data = new TestClassData(testClass, tad);
                _classData.Add(testClass, data);

                // Make sure in parent collection
                tad.TestClasses.Add(data);
            }

            return(data);
        }
Exemple #9
0
        /// <summary>
        /// Gets or creates the data model object for a test method.
        /// </summary>
        /// <param name="testMethod">The test method.</param>
        /// <param name="parentTestClass">The parent test class data object.</param>
        /// <returns>Returns the data object.</returns>
        public TestMethodData GetMethodModel(ITestMethod testMethod, TestClassData parentTestClass)
        {
            TestMethodData data;
            if (!_methodData.TryGetValue(testMethod, out data))
            {
                data = new TestMethodData(testMethod, parentTestClass);
                _methodData.Add(testMethod, data);

                // Make sure in parent collection
                parentTestClass.TestMethods.Add(data);
            }

            return data;
        }
Exemple #10
0
        /// <summary>
        /// Gets or creates the data model object for a test class.
        /// </summary>
        /// <param name="testClass">The test class.</param>
        /// <returns>Returns the data object.</returns>
        public TestClassData GetClassModel(ITestClass testClass)
        {
            TestClassData data;
            if (!_classData.TryGetValue(testClass, out data))
            {
                TestAssemblyData tad = GetAssemblyModel(testClass.Assembly);
                data = new TestClassData(testClass, tad);
                _classData.Add(testClass, data);

                // Make sure in parent collection
                tad.TestClasses.Add(data);
            }

            return data;
        }