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

            Assert.Throws <ArgumentNullException>("node", () => walker.GetParent(null));
        }
        public void GetParent_NullTreeWalker_ThrowsArgumentNullException()
        {
            // Get a valid tree.
            var tree =
                Node.Create(0).AddChildren(
                    Node.Create(1));

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

            Assert.Throws <ArgumentNullException>("walker", () => walker.GetParent(tree));
        }
        public void GetParent_NodeDoesNotHaveParent_ReturnsNull()
        {
            // Get a valid tree.
            var tree =
                Node.Create(0).AddChildren(
                    Node.Create(1));

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

            Assert.Throws <InvalidOperationException>(() => walker.GetParent(tree));
        }
        public void GetParent_NodeHasParent_ReturnsNode()
        {
            // Get a valid tree.
            var tree =
                Node.Create(0).AddChildren(
                    Node.Create(1));

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

            Node <int> parent = walker.GetParent(tree[0]);

            Assert.Equal(0, parent.Value);
        }