public void AddingItemShouldSetChildrenAndParent() { TestBase.Invoke(() => { var layout = new DynamicLayout(); var items = new Control[] { new Label { ID = "label" }, new Button(), new TextBox() }; foreach (var item in items) { layout.Add(item); } CollectionAssert.AreEqual(items, layout.Children, "#1. Items do not match"); foreach (var item in items) { Assert.AreEqual(layout, item.Parent, "#2. Items should have parent set to dynamic layout"); } Assert.AreSame(layout.FindChild <Label>("label"), items[0], "#3. FindChild should work without loading the dynamic layout"); layout.Clear(); foreach (var item in items) { Assert.IsNull(item.Parent, "#4. Items should have parent removed when removed from dynamic layout"); } }); }