public BeginIsolationScope ( string isolationScopeName ) : IDisposable | ||
isolationScopeName | string | The name of the new isolation scope |
return | IDisposable |
public void CanAddCleanupActionAfterOneLevelWasPoppoed() { var context = new TestExecutionScopesManager("dummy", Functions.EmptyAction<IIsolationScope>()); context.BeginIsolationScope("Level1", Functions.EmptyAction<IIsolationScope>()); context.EndIsolationScope(); var cleanupCalled = false; context.AddCleanupAction(() => cleanupCalled = true); context.EndIsolationScope(); Assert.IsTrue(cleanupCalled, "Cleanup action hasn't been called"); }
public void CleanupActionInNestedIsolationLevelIsCalledOnlyOnPop() { bool cleaupWasCalled = false; var context = new TestExecutionScopesManager("dummy", ctx => { }); context.BeginIsolationScope("dummyIsolationLevel", ctx => { }); context.AddCleanupAction(() => cleaupWasCalled = true); context.EndIsolationScope(); Assert.IsTrue(cleaupWasCalled); cleaupWasCalled = false; context.EndIsolationScope(); Assert.IsFalse(cleaupWasCalled); }
public void DoesNothingIfInitializeIsNull() { bool outerCleanupIsCalled = false, innerCleanupIsCalled = false; Action<IIsolationScope> nullInitialize = null; var context = new TestExecutionScopesManager("OuterScope", nullInitialize); context.AddCleanupAction(() => outerCleanupIsCalled = true); context.BeginIsolationScope("InnerScope", nullInitialize); context.AddCleanupAction(() => innerCleanupIsCalled = true); context.EndIsolationScope(); Assert.IsTrue(innerCleanupIsCalled); context.EndIsolationScope(); Assert.IsTrue(outerCleanupIsCalled); }
public void ExceptionInNestedLevelInitialization() { var calledActions = new List<string>(); var context = new TestExecutionScopesManager("dummy", ctx => { }); context.AddCleanupAction(() => calledActions.Add("action1")); var ex = TestUtils.ExpectException<Exception>(() => context.BeginIsolationScope("nested", ctx => { context.AddCleanupAction(() => calledActions.Add("action2")); throw new Exception("DummyExceptionMessage"); })); Assert.AreEqual("DummyExceptionMessage", ex.Message); Assert.AreEqual("action2", calledActions.Content()); calledActions.Clear(); context.EndIsolationScope(); Assert.AreEqual("action1", calledActions.Content()); }