Beispiel #1
0
        public void AddingItemShouldSetChildrenAndParent()
        {
            Invoke(() =>
            {
                var stackLayout = new StackLayout();

                var items = new Control[] { new Label {
                                                ID = "label"
                                            }, new Button(), new TextBox() };

                foreach (var item in items)
                {
                    stackLayout.Items.Add(item);
                }

                CollectionAssert.AreEqual(items, stackLayout.Children, "#1. Items do not match");

                foreach (var item in items)
                {
                    Assert.AreEqual(stackLayout, item.Parent, "#2. Items should have parent set to stack layout");
                }

                Assert.AreSame(stackLayout.FindChild <Label>("label"), items[0], "#3. FindChild should work without loading the stack layout");

                stackLayout.Items.Clear();
                foreach (var item in items)
                {
                    Assert.IsNull(item.Parent, "#4. Items should have parent cleared when removed from stack layout");
                }
            });
        }
Beispiel #2
0
		public void AddingItemShouldSetChildrenAndParent()
		{
			TestUtils.Invoke(() =>
			{
				var stackLayout = new StackLayout();

				var items = new Control[] { new Label { ID = "label" }, new Button(), new TextBox() };

				foreach (var item in items)
					stackLayout.Items.Add(item);

				CollectionAssert.AreEqual(items, stackLayout.Children, "#1. Items do not match");

				foreach (var item in items)
					Assert.AreEqual(stackLayout, item.Parent, "#2. Items should have parent set to stack layout");

				Assert.AreSame(stackLayout.FindChild<Label>("label"), items[0], "#3. FindChild should work without loading the stack layout");

				stackLayout.Items.Clear();
				foreach (var item in items)
					Assert.IsNull(item.Parent, "#4. Items should have parent cleared when removed from stack layout");

			});
		}