/// <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); }
/// <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, _testMethod); return; } _testMethod.DecorateInstance(_instance); _testMethod.WriteLine += delegate(object sender, StringEventArgs e) { LogWriter.DebugWriteLine(e.Value); }; // Log Start Enqueue(LogStartMessage); // [Bug] attributes that are not fixed modify test method logic bool known_issue = false; foreach (BugAttribute bug in ReflectionUtility.GetAttributes(_testMethod.Method, typeof(BugAttribute))) { if (bug == null) { continue; } if (!bug.Fixed) { if (bug.Platforms != null) { foreach (PlatformID id in bug.Platforms) { if (id == Environment.OSVersion.Platform) { _bugAttributePresent = true; break; } } } else { _bugAttributePresent = true; } #if SILVERLIGHT if (_bugAttributePresent && bug.RuntimeVersion != 0) { if (bug.RuntimeVersion != Int32.Parse(Deployment.Current.RuntimeVersion.Split('.')[0])) { _bugAttributePresent = false; } } #endif if (_bugAttributePresent) { Enqueue(() => LogWriter.KnownIssue(bug.Description)); break; } } } // [TestInitialize] if (_testClass.TestInitializeMethod != null) { EnqueueMethodDispatcher(_testClass.TestInitializeMethod); } // Track the approximate starting time - actual start time is >= 1 dispatcher interval Enqueue(() => _started = DateTime.Now); // [TestMethod] - actual test scenario UnitTestMethodContainer mthd = new UnitTestMethodContainer(TestHarness, _instance, _testMethod.Method, _testMethod, TestGranularity.TestScenario); mthd.UnhandledException += new EventHandler <UnhandledExceptionEventArgs>(UnhandledMethodException); mthd.Complete += new EventHandler(CompleteMethod); Enqueue(mthd); // [TestCleanup] if (_testClass.TestCleanupMethod != null) { EnqueueMethodDispatcher(_testClass.TestCleanupMethod); } // Log End Enqueue(LogEndMessage); // Silverlight-specific calls FirstInvokeOptional(); }