コード例 #1
0
            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);
            }
コード例 #2
0
            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);
            }
コード例 #3
0
            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);
            }
コード例 #4
0
            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);
            }
コード例 #5
0
            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);
            }
コード例 #6
0
            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);
            }
コード例 #7
0
        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);
            }
        }
コード例 #8
0
        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);
                }
            }
        }