public void Current_RootScope_CreateAndDispose() { //-- Act var scope = new StatementScope(m_Class, m_Method, new StatementBlock()); var existsInside = StatementScope.Exists; var currentInside = StatementScope.Current; scope.Dispose(); var existsAfter = StatementScope.Exists; //-- Assert Assert.That(existsInside, Is.True); Assert.That(currentInside, Is.SameAs(scope)); Assert.That(existsAfter, Is.False); }
public void Current_NestedScope_CreateAndDispose() { //-- Arrange var rootScope = new StatementScope(m_Class, m_Method, new StatementBlock()); //-- Act var nestedScope = new StatementScope(new StatementBlock()); var existsInsideNested = StatementScope.Exists; var currentInsideNested = StatementScope.Current; var previousInsideNested = StatementScope.Current.Previous; var rootInsideNested = StatementScope.Current.Root; var depthInsideNested = StatementScope.Current.Depth; nestedScope.Dispose(); var existsAfterNested = StatementScope.Exists; var currentAfterNested = StatementScope.Current; var previousAfterNested = StatementScope.Current.Previous; var rootAfterNested = StatementScope.Current.Root; var depthAfterNested = StatementScope.Current.Depth; //-- Assert Assert.That(existsInsideNested, Is.True); Assert.That(currentInsideNested, Is.SameAs(nestedScope)); Assert.That(previousInsideNested, Is.SameAs(rootScope)); Assert.That(rootInsideNested, Is.SameAs(rootScope)); Assert.That(depthInsideNested, Is.EqualTo(1)); Assert.That(existsAfterNested, Is.True); Assert.That(currentAfterNested, Is.SameAs(rootScope)); Assert.That(previousAfterNested, Is.Null); Assert.That(rootAfterNested, Is.SameAs(rootScope)); Assert.That(depthAfterNested, Is.EqualTo(0)); }