Example #1
0
		public void TestPackWithoutChild ()
		{
			Frame frame = new Frame ();

			var parent = new NaiveLayout ();

			bool thrown = false;
			try {
				parent.Children.Add (frame);
			} catch {
				thrown = true;
			}

			Assert.False (thrown);
		}
Example #2
0
		public void BindingsApplyAfterViewAddedToParentWithContextSet()
		{
			var parent = new NaiveLayout();
			parent.BindingContext = new MockViewModel { Text = "test" };

			var child = new Entry();
			child.SetBinding (Entry.TextProperty, new Binding ("Text"));

			parent.Children.Add (child);

			Assert.That (child.BindingContext, Is.SameAs (parent.BindingContext));
			Assert.That (child.Text, Is.EqualTo ("test"));
		}
Example #3
0
		public void TestBindingContextChaining ()
		{
			View child;
			var group = new NaiveLayout {
				Children = { (child = new View ()) }
			};

			var context = new object ();
			group.BindingContext = context;

			Assert.AreEqual (context, child.BindingContext);
		}
Example #4
0
		public void TestAncestorRemoved ()
		{
			var ancestor = new View ();
			var child = new NaiveLayout {Children = {ancestor}};
			var view = new NaiveLayout {Children = {child}};

			bool removed = false;
			view.DescendantRemoved += (sender, arg) => removed = true;

			child.Children.Remove (ancestor);
			Assert.True (removed, "AncestorRemoved must fire when removing a child from an ancestor of a view.");
		}
Example #5
0
		public void TestAncestorAdded ()
		{
			var child = new NaiveLayout ();
			var view = new NaiveLayout {Children = {child}};

			bool added = false;
			view.DescendantAdded += (sender, arg) => added = true;

			child.Children.Add (new View ());

			Assert.True (added, "AncestorAdded must fire when adding a child to an ancestor of a view.");
		}
Example #6
0
		public void TestDoubleSetParent ()
		{
			var view = new ParentSignalView ();
			var parent = new NaiveLayout {Children = {view}};

			view.ParentSet = false;
			view.Parent = parent;

			Assert.False (view.ParentSet, "OnParentSet should not be called in the event the parent is already properly set");
		}