public void It_will_set_the_child_scope_parent() { Scope scope = new Scope("fnord", 0, 0); Scope childScope = new Scope("The Child Scope", 0, 0); scope.AddChild(childScope); Assert.Equal(scope, childScope.Parent); }
public void It_will_add_the_child_scope_to_the_children_collection() { Scope scope = new Scope("fnord", 0, 0); Scope childScope = new Scope("The Child Scope", 0, 0); scope.AddChild(childScope); Assert.Contains(childScope, scope.Children); }
public void It_will_throw_if_child_scope_already_has_parent() { Scope scope = new Scope("fnord", 0, 0); Scope existingParentScope = new Scope("The Parent Scope", 0, 0); Scope childScope = new Scope("The Child Scope", 0, 0); childScope.Parent = existingParentScope; Exception ex = Record.Exception(() => scope.AddChild(childScope)); Assert.IsType<InvalidOperationException>(ex); Assert.Contains("The child scope already has a parent.", ex.Message); }
public void It_will_throw_if_child_scope_already_has_parent() { Scope scope = new Scope("fnord", 0, 0); Scope existingParentScope = new Scope("The Parent Scope", 0, 0); Scope childScope = new Scope("The Child Scope", 0, 0); childScope.Parent = existingParentScope; Exception ex = Record.Exception(() => scope.AddChild(childScope)); Assert.IsType <InvalidOperationException>(ex); Assert.Contains("The child scope already has a parent.", ex.Message); }
private static void AddScopeToNestedScopes(Scope scope, ref Scope currentScope, ICollection<Scope> capturedStyleTree) { if (scope.Index >= currentScope.Index && (scope.Index + scope.Length <= currentScope.Index + currentScope.Length)) { currentScope.AddChild(scope); currentScope = scope; } else { currentScope = currentScope.Parent; if (currentScope != null) AddScopeToNestedScopes(scope, ref currentScope, capturedStyleTree); else capturedStyleTree.Add(scope); } }
private static void AddScopeToNestedScopes(Scope scope, ref Scope currentScope, ICollection <Scope> capturedStyleTree) { if (scope.Index >= currentScope.Index && (scope.Index + scope.Length <= currentScope.Index + currentScope.Length)) { currentScope.AddChild(scope); currentScope = scope; } else { currentScope = currentScope.Parent; if (currentScope != null) { AddScopeToNestedScopes(scope, ref currentScope, capturedStyleTree); } else { capturedStyleTree.Add(scope); } } }