コード例 #1
0
        public void ChildrenProvidedOnConstructionAreAdded()
        {
            // Initialize and node with several children.
            List <IParameterTreeNode> children =
                Enumerable.Range(0, 3).Select(index => AndNodeTest.CreateNode(index.ToString())).ToList();
            var andNode = new AndNode(children);

            // Add an additional one.
            andNode.AddChild(AndNodeTest.CreateNode("additional"));

            // Make sure the original ones are returned by the GetChildren method.
            var storedChildren = andNode.Children;

            Assert.True(
                children.All(child => storedChildren.Contains(child)),
                $"Not all of {TestUtils.PrintList(children)} have been stored in the node's children: {TestUtils.PrintList(storedChildren)}.");
        }
コード例 #2
0
        public void ChildrenAreReturnedCorrectly()
        {
            var andNode = new AndNode();

            // Add several children...
            var childIdentifiers = new List <string> {
                "a", "b", "c", "d"
            };
            var children = new List <IParameterTreeNode>();

            for (int i = 0; i < childIdentifiers.Count; i++)
            {
                IParameterTreeNode child = AndNodeTest.CreateNode(childIdentifiers[i]);
                children.Add(child);
                andNode.AddChild(child);
            }

            // ..and compare them with the returned set when querying for the node's children.
            Assert.True(
                TestUtils.SetsAreEquivalent(children, andNode.Children),
                $"Added children {TestUtils.PrintList(children)}, but return value was {TestUtils.PrintList(andNode.Children)}");
        }