private void GenerateScopeTree(DHCPv6Scope scope, ICollection <DHCPv6ScopeTreeViewItem> parentChildren) { List <DHCPv6ScopeTreeViewItem> childItems = new List <DHCPv6ScopeTreeViewItem>(); var node = new DHCPv6ScopeTreeViewItem { Id = scope.Id, StartAddress = scope.AddressRelatedProperties.Start.ToString(), EndAddress = scope.AddressRelatedProperties.End.ToString(), Name = scope.Name, ChildScopes = childItems, }; parentChildren.Add(node); if (scope.GetChildScopes().Any()) { foreach (var item in scope.GetChildScopes()) { GenerateScopeTree(item, childItems); } } }
private void CheckTreeItem(DHCPv6Scope item, DHCPv6ScopeTreeViewItem viewItem) { Assert.Equal(item.Name, viewItem.Name); Assert.Equal(item.Id, viewItem.Id); Assert.Equal(item.AddressRelatedProperties.Start.ToString(), viewItem.StartAddress); Assert.Equal(item.AddressRelatedProperties.End.ToString(), viewItem.EndAddress); if (item.GetChildScopes().Any() == true) { Assert.Equal(item.GetChildScopes().Count(), viewItem.ChildScopes.Count()); Int32 index = 0; foreach (var childScope in item.GetChildScopes()) { var childViewItem = viewItem.ChildScopes.ElementAt(index); CheckTreeItem(childScope, childViewItem); index++; } } else { Assert.Empty(viewItem.ChildScopes); } }