예제 #1
0
        public void TestViewsSharingParent()
        {
            var parent = new TestView();
            var childA = new TestView();
            var childB = new TestView();

            parent.AddSubview(childA);
            parent.AddSubview(childB);

            Constrain(childA, childB, (a, b) =>
            {
                a.Width.Equal(b.Width);
            });

            Assert.That(parent.Constraints.Length, Is.EqualTo(1), "Should handle views that share a parent");
        }
예제 #2
0
        public void TestAsymmetricViewHierarchies()
        {
            var grandparent = new TestView();
            var parentA     = new TestView();
            var parentB     = new TestView();
            var childA      = new TestView();

            grandparent.AddSubview(parentA);
            grandparent.AddSubview(parentB);
            parentA.AddSubview(childA);

            Constrain(childA, parentB, (a, b) =>
            {
                a.Width.Equal(b.Width);
            });

            Assert.That(grandparent.Constraints.Length, Is.EqualTo(1), "Should handle asymmetric view hierachies");
        }
예제 #3
0
        public void SetUp()
        {
            var superview = new TestView(new CGRect(0, 0, 400, 400));

            var viewA = new TestView(new CGRect(0, 0, 200, 200));

            superview.AddSubview(viewA);

            var viewB = new TestView(new CGRect(0, 0, 200, 200));

            superview.AddSubview(viewB);

            Constrain(viewA, viewB, (a, b) =>
            {
                a.Top.Equal(b.Top);
                a.Bottom.Equal(b.Bottom);
            });

            weak_viewA     = new WeakReference <TestView>(viewA);
            weak_viewB     = new WeakReference <TestView>(viewB);
            weak_superview = new WeakReference <TestView>(superview);
        }
예제 #4
0
        public void TestParentChildRelationship()
        {
            var parent = new TestView();
            var child  = new TestView();

            parent.AddSubview(child);

            Constrain(parent, child, (p, c) =>
            {
                p.Width.Equal(c.Width);
            });

            Assert.That(parent.Constraints.Length, Is.EqualTo(1), "Should handle a direct parent-child-relationship");
        }
예제 #5
0
        public void TestGrandparentChildRelationship()
        {
            var grandparent = new TestView();
            var parent      = new TestView();
            var child       = new TestView();

            grandparent.AddSubview(parent);
            parent.AddSubview(child);

            Constrain(grandparent, child, (g, c) =>
            {
                g.Width.Equal(c.Width);
            });

            Assert.That(grandparent.Constraints.Length, Is.EqualTo(1), "Should handle a grandparent-child-relationship");
        }