/// <summary> /// Restores the last saved context and puts /// any saved settings back into effect. /// </summary> public static void Restore() { current.ReverseChanges(); current = current.prior; }
public ContextDictionary(TestExecutionContext context) { _context = context; }
/// <summary> /// Initializes a new instance of the <see cref="TestExecutionContext"/> class. /// </summary> /// <param name="other">An existing instance of TestExecutionContext.</param> public TestExecutionContext(TestExecutionContext other) { this.prior = other; this.tracing = other.tracing; //this.logging = other.logging; this.outWriter = other.outWriter; this.errorWriter = other.errorWriter; this.traceWriter = other.traceWriter; this.logCapture = other.logCapture; this.testCaseTimeout = other.testCaseTimeout; this.currentTest = other.currentTest; this.currentResult = other.currentResult; this.testPackage = other.testPackage; this.currentDirectory = Environment.CurrentDirectory; this.currentCulture = CultureInfo.CurrentCulture; this.currentUICulture = CultureInfo.CurrentUICulture; this.currentPrincipal = Thread.CurrentPrincipal; }
/// <summary> /// Saves the old context and makes a fresh one /// current without changing any settings. /// </summary> public static void Save() { TestExecutionContext.current = new TestExecutionContext(current); }
public ContextDictionary(TestExecutionContext context) { _context = context; }
/// <summary> /// Initializes a new instance of the <see cref="TestExecutionContext"/> class. /// </summary> public TestExecutionContext() { this.prior = null; this.tracing = false; //this.logging = false; this.outWriter = Console.Out; this.errorWriter = Console.Error; this.traceWriter = null; this.logCapture = new Log4NetCapture(); this.testCaseTimeout = 0; this.currentDirectory = Environment.CurrentDirectory; this.currentCulture = CultureInfo.CurrentCulture; this.currentUICulture = CultureInfo.CurrentUICulture; this.currentPrincipal = Thread.CurrentPrincipal; }
/// <summary> /// Saves the old context and makes a fresh one /// current without changing any settings. /// </summary> public static void Save() { current = new TestExecutionContext(current); SaveInCallContext(); }
/// <summary> /// Restores the last saved context and puts /// any saved settings back into effect. /// </summary> public static void Restore() { current.ReverseChanges(); current = current.prior; SaveInCallContext(); }
private TestResult RunTestInContext() { TestExecutionContext.Save(); TestExecutionContext.CurrentContext.CurrentTest = this; if (this.Parent != null) { this.Fixture = this.Parent.Fixture; TestSuite suite = this.Parent as TestSuite; if (suite != null) { this.setUpMethods = suite.GetSetUpMethods(); this.tearDownMethods = suite.GetTearDownMethods(); #if CLR_2_0 || CLR_4_0 this.suiteActions = suite.GetTestActions(); #endif } } try { #if CLR_2_0 || CLR_4_0 this.actions = ActionsHelper.GetActionsFromAttributeProvider(method); #endif // Temporary... to allow for tests that directly execute a test case); if (Fixture == null && !method.IsStatic) { Fixture = Reflect.Construct(this.FixtureType); } if (this.Properties["_SETCULTURE"] != null) { TestExecutionContext.CurrentContext.CurrentCulture = new System.Globalization.CultureInfo((string)Properties["_SETCULTURE"]); } else if (this.Properties["SetCulture"] != null) // In case we are running NUnitLite tests { TestExecutionContext.CurrentContext.CurrentCulture = new System.Globalization.CultureInfo((string)Properties["SetCulture"]); } if (this.Properties["_SETUICULTURE"] != null) { TestExecutionContext.CurrentContext.CurrentUICulture = new System.Globalization.CultureInfo((string)Properties["_SETUICULTURE"]); } if (this.Properties["SetUICulture"] != null) // In case we are running NUnitLite tests { TestExecutionContext.CurrentContext.CurrentUICulture = new System.Globalization.CultureInfo((string)Properties["SetUICulture"]); } return(RunRepeatedTest()); } catch (Exception ex) { log.Debug("TestMethod: Caught " + ex.GetType().Name); if (ex is ThreadAbortException) { Thread.ResetAbort(); } TestResult testResult = new TestResult(this); RecordException(ex, testResult, FailureSite.Test); return(testResult); } finally { Fixture = null; TestExecutionContext.Restore(); } }
/// <summary> /// Restores the last saved context and puts /// any saved settings back into effect. /// </summary> public static void Restore() { current.ReverseChanges(); current = current.prior; #if CLR_2_0 || CLR_4_0 CallContext.LogicalSetData("NUnit.Framework.TestContext", current.contextDictionary); #else CallContext.SetData("NUnit.Framework.TestContext", current.contextDictionary); #endif }
/// <summary> /// Saves the old context and makes a fresh one /// current without changing any settings. /// </summary> public static void Save() { current = new TestExecutionContext(current); #if CLR_2_0 || CLR_4_0 CallContext.LogicalSetData("NUnit.Framework.TestContext", current.contextDictionary); #else CallContext.SetData("NUnit.Framework.TestContext", current.contextDictionary); #endif }
/// <summary> /// Restores the last saved context and puts /// any saved settings back into effect. /// </summary> public static void Restore() { current.ReverseChanges(); current = current.prior; SaveInCallContext(); }
/// <summary> /// Saves the old context and makes a fresh one /// current without changing any settings. /// </summary> public static void Save() { current = new TestExecutionContext(current); SaveInCallContext(); }