public void PublicAddChildNodes_AllLevelsToInclude_ReturnsWholeNodeCollection() { var model = new DummyNavigationModel(PageSelectionMode.CurrentPageChildren, -1, true, "MyClass"); model.CurrentNode = this.siteMapNode; model.PublicAddChildNodes(this.siteMapNode, true); var resultParentNode = model.Nodes.First(); this.AssertParentNode(resultParentNode, model.Nodes); for (int i = 0; i < DummySiteMapProvider.ChildNodesCount; i++) { var title = string.Format(System.Globalization.CultureInfo.InvariantCulture, DummySiteMapProvider.ChildTitleFormat, i); var url = string.Format(System.Globalization.CultureInfo.InvariantCulture, DummySiteMapProvider.ChildUrlFormat, i); var resultNode = resultParentNode.ChildNodes[i]; this.AssertNodeViewModel(title, url, DummySiteMapProvider.ChildNodesCount, resultNode); for (int j = 0; j < DummySiteMapProvider.ChildNodesCount; j++) { var childTitle = string.Format(System.Globalization.CultureInfo.InvariantCulture, DummySiteMapProvider.ChildTitleFormat, j); var childUrl = string.Format(System.Globalization.CultureInfo.InvariantCulture, DummySiteMapProvider.ChildUrlFormat, j); var childResultNode = resultNode.ChildNodes[j]; this.AssertNodeViewModel(childTitle, childUrl, 0, childResultNode); } } }
public void PublicAddChildNodes_WithoutParentNode_RestrictsNodeCollectionWithoutParentNode() { var model = new DummyNavigationModel(PageSelectionMode.CurrentPageChildren, 2, true, "MyClass"); model.CurrentNode = this.siteMapNode; model.PublicAddChildNodes(this.siteMapNode, false); Assert.IsNotNull(model.Nodes, "The node collection is not initialized."); Assert.AreEqual(DummySiteMapProvider.ChildNodesCount, model.Nodes.Count(), "The node collection should contain 3 node at the parent level."); for (int i = 0; i < DummySiteMapProvider.ChildNodesCount; i++) { var resultParentNode = model.Nodes[i]; for (int j = 0; j < DummySiteMapProvider.ChildNodesCount; j++) { var title = string.Format(System.Globalization.CultureInfo.InvariantCulture, DummySiteMapProvider.ChildTitleFormat, j); var url = string.Format(System.Globalization.CultureInfo.InvariantCulture, DummySiteMapProvider.ChildUrlFormat, j); var resultNode = resultParentNode.ChildNodes[j]; this.AssertNodeViewModel(title, url, 0, resultNode); } } }