public void ActivatingAGroup() { var a = Constrain(view1, (view) => { view.Width.Equal(100); view.Height.Equal(100); }); var b = Constrain(view1, (view) => { view.Width.Equal(200); view.Height.Equal(200); }); a.Active = false; b.Active = false; // Should update the view a.Active = true; view1.LayoutIfNeeded(); Assert.AreEqual(100, view1.Frame.Height); Assert.AreEqual(100, view1.Frame.Width); a.Active = false; b.Active = true; window.LayoutIfNeeded(); Assert.AreEqual(200, view1.Frame.Height); Assert.AreEqual(200, view1.Frame.Width); }
public void LayoutProxySizeShouldSupportRelativeEqualities() { Constrain(view, view => { view.Size.Equal(view.Superview.Size); }); window.LayoutIfNeeded(); Assert.That(view.Frame.Size, Is.EqualTo(new CGSize(400, 400))); }
public void LayoutProxyCenterRelativeEq() { Constrain(view, view => { view.Center.Equal(view.Superview.Center); }); window.LayoutIfNeeded(); Assert.That(view.Frame, Is.EqualTo(new CGRect(100, 100, 200, 200)), "LayoutProxy.Center should support relative equalities"); }
public void LayoutProxyEdgesEqualities() { Constrain(view, v => { v.Edges.Equal(v.Superview.Edges); }); window.LayoutIfNeeded(); Assert.That(view.Frame, Is.EqualTo(view.Superview.Frame), "should support relative equalities"); }
public void LayoutProxyTop() { // Should support relative equalities Constrain(view, (v) => { v.Top.Equal(v.Superview.Top); }); window.LayoutIfNeeded(); Assert.That(view.Frame.GetMinY(), Is.EqualTo(0), "Should support relative equalities"); // Clear vars for next assertion SetUp(); // Should support relative equalities Constrain(view, (v) => { v.Top.LessThanOrEqualTo(v.Superview.Top); v.Top.GreaterThanOrEqualTo(v.Superview.Top); }); window.LayoutIfNeeded(); Assert.That(view.Frame.GetMinY(), Is.EqualTo(0), "Should support relative inequalities"); // Clear vars for next assertion SetUp(); // Should support relative equalities Constrain(view, (v) => { v.Top.Equal(v.Superview.Top + 100); }); window.LayoutIfNeeded(); Assert.That(view.Frame.GetMinY(), Is.EqualTo(100), "Should support addition"); // Clear vars for next assertion SetUp(); // Should support relative equalities Constrain(view, (v) => { v.Top.Equal(v.Superview.Top - 100); }); window.LayoutIfNeeded(); Assert.That(view.Frame.GetMinY(), Is.EqualTo(-100), "Should support substraction"); }
public void LayoutProxyWidth() { // Should support relative equalities Constrain(view, (x) => { x.Width.Equal(x.Superview.Width); }); window.LayoutIfNeeded(); Assert.That(view.Frame.Width, Is.EqualTo(400), "Should support relative equalities."); // Reset test variables SetUp(); // Should support relative inequalities Constrain(view, (x) => { x.Width.LessThanOrEqualTo(x.Superview.Width); x.Width.GreaterThanOrEqualTo(x.Superview.Width); }); window.LayoutIfNeeded(); Assert.That(view.Frame.Width, Is.EqualTo(400), "Should support relative inequalities."); // Reset test variables SetUp(); // Should support addition Constrain(view, (x) => { x.Width.Equal(x.Superview.Width + 100); }); window.LayoutIfNeeded(); Assert.That(view.Frame.Width, Is.EqualTo(500), "Should support addition."); // Reset test variables SetUp(); // Should support substraction Constrain(view, (x) => { x.Width.Equal(x.Superview.Width - 100); }); window.LayoutIfNeeded(); Assert.That(view.Frame.Width, Is.EqualTo(300), "Should support substraction."); // Reset test variables SetUp(); // Should support multiplication Constrain(view, (x) => { x.Width.Equal(x.Superview.Width * 2); }); window.LayoutIfNeeded(); Assert.That(view.Frame.Width, Is.EqualTo(800), "Should support multiplication."); // Reset test variables SetUp(); // Should support division Constrain(view, (x) => { x.Width.Equal(x.Superview.Width / 2); }); window.LayoutIfNeeded(); Assert.That(view.Frame.Width, Is.EqualTo(200), "Should support division."); // Reset test variables SetUp(); // Should support complex expressions Constrain(view, (x) => { x.Width.Equal(x.Superview.Width / 2 + 100); }); window.LayoutIfNeeded(); Assert.That(view.Frame.Width, Is.EqualTo(300), "Should support complex expressions."); // Reset test variables SetUp(); // Should support numerical equalities Constrain(view, (x) => { x.Width.Equal(200); }); window.LayoutIfNeeded(); Assert.That(view.Frame.Width, Is.EqualTo(200), "Should support numerical equalities."); }