Esempio n. 1
0
        public void Should_remove_child_of_stacklayout_by_using_its_xenwidget()
        {
            var child = new Entry {
                Placeholder = "text"
            };
            var layout = new StackLayout();

            layout.Children.Add(child);
            var page = new ContentPage {
                Content = layout
            };

            var mgr = new XamarinDesignSurfaceManager();

            mgr.SetDesignSurface(page);

            var childPair  = mgr[child.Id.ToString()];
            var layoutPair = mgr[layout.Id.ToString()];

            Assert.IsNotEmpty(layoutPair.XenWidget.Children, "The stacklayouts xenwidget should have children.");

            var removed = mgr.Remove(childPair.XenWidget);

            Assert.IsTrue(removed, "Removed wasn't true.");
            Assert.IsEmpty(layout.Children, "The stacklayout has children.");
            Assert.IsEmpty(layoutPair.XenWidget.Children, "The stacklayout has children.");
        }
Esempio n. 2
0
        public void Removing_root_xenwidget()
        {
            var page = new ContentPage();
            var mgr  = new XamarinDesignSurfaceManager();
            var root = mgr.SetDesignSurface(page);

            Assert.Throws <InvalidOperationException>(() => mgr.Remove(root));
        }
Esempio n. 3
0
        public void Should_remove_only_design_surface_child_by_using_its_xenwidget()
        {
            var label = new Label {
                Text = "value"
            };
            var page = new ContentPage {
                Content = label
            };
            var mgr  = new XamarinDesignSurfaceManager();
            var root = mgr.SetDesignSurface(page);

            var labelPair = mgr[label.Id.ToString()];
            var removed   = mgr.Remove(labelPair.XenWidget);

            Assert.IsTrue(removed, "Removed wasn't true.");
            Assert.IsEmpty(mgr.Root.Children, "mgr.Root.Children should be empty.");
            Assert.IsEmpty(root.Children, "root.Children should be empty.");
            Assert.IsNull(page.Content, "Page content should be null.");
        }