A container which is able to attach to the underlying test dispatcher stack to enable advanced asynchronous functionality, when supported.
상속: MethodContainer
        /// <summary>
        /// First invoke, plan for the method's execution.
        /// </summary>
        protected override void FirstInvoke()
        {
            // [Ignore]
            if (Provider.HasCapability(UnitTestProviderCapabilities.MethodCanIgnore) && _testMethod.Ignore)
            {
                LogWriter.Ignore(TestGranularity.TestScenario, _testMethod.Name);
                return;
            }

            _testMethod.DecorateInstance(_instance);

            _testMethod.WriteLine += (object sender, StringEventArgs e) => OnWriteLine(e);

            // Log Start
            LogStartMessage();

            // [Bug] attributes that are not fixed modify test method logic
            ICollection <Attribute> bugs = ReflectionUtility.GetAttributes(_testMethod, typeof(BugAttribute), false);

            if (bugs != null && bugs.Count > 0)
            {
                foreach (Attribute attribute in bugs)
                {
                    BugAttribute bug = attribute as BugAttribute;
                    if (!bug.Fixed)
                    {
                        _bugAttributePresent = true;
                        LogWriter.KnownIssue(bug.Description);
                    }
                }
            }

            // [TestInitialize]
            if (_testClass.TestInitializeMethod != null)
            {
                EnqueueMethodDispatcher(_testClass.TestInitializeMethod);
            }

            // Track the approximate starting time - actual start time is >= 1 dispatcher interval
            EnqueueQuick(() => _started = DateTime.Now);

            // [TestMethod] - actual test scenario
            _mainTestMethodContainer = new UnitTestMethodContainer(TestHarness, _instance, _testMethod.Method, _testMethod, TestGranularity.TestScenario);
            _mainTestMethodContainer.UnhandledException += new EventHandler <UnhandledExceptionEventArgs>(UnhandledMethodException);
            _mainTestMethodContainer.Complete           += new EventHandler(CompleteMethod);
            Enqueue(_mainTestMethodContainer);

            // [TestCleanup]
            if (_testClass.TestCleanupMethod != null)
            {
                EnqueueMethodDispatcher(_testClass.TestCleanupMethod);
            }

            // Log End
            EnqueueQuick(LogEndMessage);
        }
예제 #2
0
        /// <summary>
        /// First invoke, plan for the method's execution.
        /// </summary>
        protected override void FirstInvoke()
        {
            // [Ignore]
            if (Provider.HasCapability(UnitTestProviderCapabilities.MethodCanIgnore) && _testMethod.Ignore)
            {
                LogWriter.Ignore(TestGranularity.TestScenario, _testMethod.Name);
                return;
            }

            _testMethod.DecorateInstance(_instance);

            _testMethod.WriteLine += (object sender, StringEventArgs e) => OnWriteLine(e);

            // Log Start
            LogStartMessage();

            // [Bug] attributes that are not fixed modify test method logic
            ICollection<Attribute> bugs = ReflectionUtility.GetAttributes(_testMethod, typeof(BugAttribute), false);
            if (bugs != null && bugs.Count > 0)
            {
                foreach (Attribute attribute in bugs)
                {
                    BugAttribute bug = attribute as BugAttribute;
                    if (!bug.Fixed)
                    {
                        _bugAttributePresent = true;
                        LogWriter.KnownIssue(bug.Description);
                    }
                }
            }

            // [TestInitialize]
            if (_testClass.TestInitializeMethod != null)
            {
                EnqueueMethodDispatcher(_testClass.TestInitializeMethod);
            }

            // Track the approximate starting time - actual start time is >= 1 dispatcher interval
            EnqueueQuick(() => _started = DateTime.Now);

            // [TestMethod] - actual test scenario
            _mainTestMethodContainer = new UnitTestMethodContainer(TestHarness, _instance, _testMethod.Method, _testMethod, TestGranularity.TestScenario);
            _mainTestMethodContainer.UnhandledException += new EventHandler<UnhandledExceptionEventArgs>(UnhandledMethodException);
            _mainTestMethodContainer.Complete += new EventHandler(CompleteMethod);
            Enqueue(_mainTestMethodContainer);

            // [TestCleanup]
            if (_testClass.TestCleanupMethod != null)
            {
                EnqueueMethodDispatcher(_testClass.TestCleanupMethod);
            }

            // Log End
            EnqueueQuick(LogEndMessage);
        }