Example #1
0
        private void RunTests(ICallbackEventHandler handler, string filter)
        {
            Guard.ArgumentNotNull(filter, "filter");

            ITestResult result = Runner.Run(new TestProgressReporter(handler), TestFilter.FromXml(filter));

            // Ensure that the CallContext of the thread is not polluted
            // by our TestExecutionContext, which is not serializable.
            TestExecutionContext.ClearCurrentContext();

            handler.RaiseCallbackEvent(result.ToXml(true).OuterXml);
        }
Example #2
0
        public async Task TestExecutionContext_ShouldFlowWithAsyncExecution_ExecutedInParallel()
        {
            Func <Task <TestExecutionContext> > functionWithSeparateContext = async() =>
            {
                await YieldAsync();                         //to start both functions

                TestExecutionContext.ClearCurrentContext(); //establish new context
                var expected = TestExecutionContext.CurrentContext;
                await DelayAsync(300);

                Assert.AreSame(expected, TestExecutionContext.CurrentContext); //ensure that is still the same within given function call
                return(expected);
            };

            var results = await WhenAllAsync(functionWithSeparateContext(), functionWithSeparateContext());

            // both calls have to be successful but have different context
            Assert.AreNotSame(results[0], results[1]);
        }
Example #3
0
        private void RunTests(ICallbackEventHandler handler, string filter)
        {
            Guard.ArgumentNotNull(filter, "filter");

            TNode result = Runner.Run(new TestProgressReporter(handler), TestFilter.FromXml(filter)).ToXml(true);

            // Insert elements as first child in reverse order
            if (Settings != null) // Some platforms don't have settings
            {
                InsertSettingsElement(result, Settings);
            }
#if !PORTABLE && !SILVERLIGHT
            InsertEnvironmentElement(result);
#endif

            // Ensure that the CallContext of the thread is not polluted
            // by our TestExecutionContext, which is not serializable.
            TestExecutionContext.ClearCurrentContext();

            handler.RaiseCallbackEvent(result.OuterXml);
        }
        private void RunTests(ICallbackEventHandler handler, string filter)
        {
            try
            {
                ITestResult result = Runner.Run(new TestProgressReporter(handler), TestFilter.FromXml(filter));

                // Ensure that the CallContext of the thread is not polluted
                // by our TestExecutionContext, which is not serializable.
                TestExecutionContext.ClearCurrentContext();

                handler.RaiseCallbackEvent(result.ToXml(true).OuterXml);
            }
            catch (Exception ex)
            {
                handler.RaiseCallbackEvent(FormatErrorReport(ex));
            }
            finally
            {
                //InternalTrace.Flush();
            }
        }