public void TestNavigation() { rootNode = rootNode.AsSubdivision(); ProductBrand brandGoogle = ProductDimensions.CreateBrand("google"); ProductBrand brandOther = ProductDimensions.CreateBrand(null); ProductCanonicalCondition conditionNew = ProductDimensions.CreateCanonicalCondition(ProductCanonicalConditionCondition.NEW); ProductCanonicalCondition conditionUsed = ProductDimensions.CreateCanonicalCondition(ProductCanonicalConditionCondition.USED); ProductCanonicalCondition conditionOther = ProductDimensions.CreateCanonicalCondition(); // Build up the brand = Google node under the root. ProductPartitionNode brandGoogleNode = rootNode.AddChild(brandGoogle).AsSubdivision(); brandGoogleNode.AddChild(conditionNew); brandGoogleNode.AddChild(conditionUsed); brandGoogleNode.AddChild(conditionOther); Assert.True(brandGoogleNode.HasChild(conditionNew), "HasChild should return true for existing child dimension."); Assert.AreSame(brandGoogleNode, brandGoogleNode.GetChild(conditionNew).Parent, "parent->GetChild->getParent should return parent."); Assert.True(brandGoogleNode.HasChild(conditionUsed), "HasChild should return true for existing child dimension."); Assert.AreSame(brandGoogleNode, brandGoogleNode.GetChild(conditionUsed).Parent, "parent->GetChild->getParent should return parent."); Assert.True(brandGoogleNode.HasChild(conditionOther), "HasChild should return true for existing child dimension."); Assert.AreSame(brandGoogleNode, brandGoogleNode.GetChild(conditionOther).Parent, "parent->GetChild->getParent should return parent."); // Build up the brand = null (other) node under the root. ProductPartitionNode brandOtherNode = rootNode.AddChild(brandOther).AsSubdivision(); brandOtherNode.AddChild(conditionNew); Assert.True(brandOtherNode.HasChild(conditionNew), "HasChild should return true for existing child dimension."); Assert.AreSame(brandOtherNode, brandOtherNode.GetChild(conditionNew).Parent, "parent->GetChild->getParent should return parent."); Assert.False(brandOtherNode.HasChild(conditionUsed), "HasChild should return false for nonexistent child dimension."); Assert.False(brandOtherNode.HasChild(conditionOther), "HasChild should return false for nonexistent child dimension."); brandOtherNode.AddChild(conditionOther); Assert.True(brandOtherNode.HasChild(conditionOther), "HasChild should return true for existing child dimension."); Assert.AreSame(brandOtherNode, brandOtherNode.GetChild(conditionOther).Parent, "parent->GetChild->getParent should return parent."); // Remove one of the children of brand = null. brandOtherNode.RemoveChild(conditionOther); Assert.False(brandOtherNode.HasChild(conditionOther), "HasChild should return false for a removed child dimension."); // Remove the rest of the children of brand = null. brandOtherNode.RemoveAllChildren(); Assert.False(brandOtherNode.HasChild(conditionNew), "HasChild should return false for any removed child dimension."); Assert.False(brandOtherNode.HasChild(conditionUsed), "HasChild should return false for any removed child dimension."); }