Exemple #1
0
        public void GetFollowingSiblingsAndSelf_NullNode_ArgumentNullExceptionThrown()
        {
            // Create a valid ITreeWalker.
            NodeWalker <int> walker = new NodeWalker <int>();

            // Assert that 'GetFollowingSiblingsAndSelf' throws an 'ArgumentNullException' when the node is null.
            Assert.Throws <ArgumentNullException>("node", () => walker.GetFollowingSiblingsAndSelf(null).ToArray());
        }
Exemple #2
0
        public void GetFollowingSiblingsAndSelf_NullWalker_ArgumentNullExceptionThrown()
        {
            // Get a valid tree.
            var tree = TestTreeFactory.GetSimpleTree();

            // Create a null ITreeWalker.
            NodeWalker <int> walker = null;

            // Assert that 'GetFollowingSiblingsAndSelf' throws an 'ArgumentNullException' when the tree walker
            // is null.
            Assert.Throws <ArgumentNullException>("walker", () => walker.GetFollowingSiblingsAndSelf(tree).ToArray());
        }
Exemple #3
0
        public void GetFollowingSiblingsAndSelf(int[] path, int[] expectedResult)
        {
            // Get a valid tree.
            var tree = TestTreeFactory.GetSimpleTree();

            // Get a valid ITreeWalker.
            NodeWalker <int> walker = new NodeWalker <int>();

            foreach (int i in path)
            {
                tree = tree[i];
            }

            // For each node in the tree assert that 'GetFollowingSiblingsAndSelf' returns the correct
            // elements.
            Assert.Equal(
                expectedResult,
                walker.GetFollowingSiblingsAndSelf(tree).Select(x => x.Value));
        }