Beispiel #1
0
        public void SetAndRestoreCurrentUICulture()
        {
            Assert.AreEqual(currentUICulture, TestExecutionContext.CurrentContext.CurrentUICulture, "UICulture not in initial context");

            TestExecutionContext.Save();

            try
            {
                CultureInfo otherCulture =
                    new CultureInfo(currentUICulture.Name == "fr-FR" ? "en-GB" : "fr-FR");
                TestExecutionContext.CurrentContext.CurrentUICulture = otherCulture;
                Assert.AreEqual(otherCulture, CultureInfo.CurrentUICulture, "UICulture was not set");
                Assert.AreEqual(otherCulture, TestExecutionContext.CurrentContext.CurrentUICulture, "UICulture not in new context");
            }
            finally
            {
                TestExecutionContext.Restore();
            }

            Assert.AreEqual(currentUICulture, CultureInfo.CurrentUICulture, "UICulture was not restored");
            Assert.AreEqual(currentUICulture, TestExecutionContext.CurrentContext.CurrentUICulture, "UICulture not in final context");
        }
Beispiel #2
0
        public void Complete()
        {
            var frame = this.testStack.Pop();

            TestExecutionContext context = frame.Item1;
            long       startTicks        = frame.Item2;
            TestResult result            = frame.Item3;

#if (CLR_2_0 || CLR_4_0) && !SILVERLIGHT && !NETCF_2_0
            long   tickCount = Stopwatch.GetTimestamp() - startTicks;
            double seconds   = (double)tickCount / Stopwatch.Frequency;
            result.Duration = TimeSpan.FromSeconds(seconds);
#else
            result.Duration = DateTime.Now - Context.StartTime;
#endif

            result.AssertCount = context.AssertCount;

            context.Listener.TestFinished(result);

            context              = context.Restore();
            context.AssertCount += result.AssertCount;
        }