コード例 #1
0
        public void ContentProperties_should_be_found_and_set()
        {
            var writer = new TestXamlWriter();

            var page = new ContentPage
            {
                Content = new StackLayout
                {
                    Children =
                    {
                        new Label()
                    }
                }
            };

            var xaml = writer.Save(page);

            var doc       = XDocument.Parse(xaml);
            var stackNode = doc.Root.Elements().First();
            var labelNode = stackNode.Elements().First();

            Assert.IsTrue(stackNode.Attributes().Any(a => a.Name.LocalName == "WidthRequest"));
            Assert.IsTrue(labelNode.Attributes().Any(a => a.Name.LocalName == "WidthRequest"));

            Assert.AreEqual("StackLayout", stackNode.Name.LocalName);
            Assert.AreEqual("Label", labelNode.Name.LocalName);
        }
コード例 #2
0
        public void Font_should_be_empty_string()
        {
            var writer = new TestXamlWriter();
            var label  = new Label();
            var xaml   = writer.Save(label);

            XamlAssert.AreEqual(xaml, "Font", "", ""&quot?");
        }
コード例 #3
0
        public void Source_property_xnull()
        {
            var writer = new TestXamlWriter();
            var img    = new Image();
            var xaml   = writer.Save(img);

            XamlAssert.AreEqual(xaml, "Source", "{x:Null}");
        }
コード例 #4
0
        public void Should_serialize_contentlayout_property()
        {
            var writer = new TestXamlWriter();
            var btn    = new Button();
            var xaml   = writer.Save(btn);

            XamlAssert.AreEqual(xaml, "ContentLayout", "Left, 10");
        }
コード例 #5
0
        public void Keyboard_default()
        {
            var writer = new TestXamlWriter();
            var entry  = new Entry();

            var xaml = writer.Save(entry);

            XamlAssert.AreEqual(xaml, "Keyboard", "Default");
        }
コード例 #6
0
        public void Default_set()
        {
            var writer = new TestXamlWriter();

            var label = new Label();
            var xaml  = writer.Save(label);

            XamlAssert.AreEqual(xaml, "VerticalOptions", "Fill");
        }
コード例 #7
0
        public void Source_property_set_to_filename()
        {
            const string file   = "filename.png";
            var          writer = new TestXamlWriter();
            var          img    = new Image {
                Source = ImageSource.FromFile(file)
            };
            var xaml = writer.Save(img);

            XamlAssert.AreEqual(xaml, "Source", file);
        }
コード例 #8
0
        public void Should_set_blue_to_hex_value()
        {
            var writer = new TestXamlWriter();

            var page = new ContentPage {
                BackgroundColor = Color.Blue
            };
            var xaml = writer.Save(page);

            XamlAssert.AreEqual(xaml, "BackgroundColor", "#0000FF");
        }
コード例 #9
0
        public void Source_property_set_to_uri()
        {
            const string url    = "http://www.doesntexist.com/pic.png";
            var          writer = new TestXamlWriter();
            var          img    = new Image {
                Source = ImageSource.FromUri(new Uri(url))
            };
            var xaml = writer.Save(img);

            XamlAssert.AreEqual(xaml, "Source", url);
        }
コード例 #10
0
        public void Set_rectangle_property_value()
        {
            var writer = new TestXamlWriter();
            var view   = new RectangleView
            {
                TestProp = new Rectangle(5.5, 10.1, 15, 20)
            };

            var xaml = writer.Save(view);

            XamlAssert.AreEqual(xaml, "TestProp", "5.5, 10.1, 15, 20");
        }
コード例 #11
0
        public void Padding_value_should_be_converted_to_string()
        {
            var writer = new TestXamlWriter();
            var page   = new ContentPage
            {
                Padding = new Thickness(5, 10, 15, 20)
            };

            var xaml = writer.Save(page);

            XamlAssert.AreEqual(xaml, "Padding", "5,10,15,20");
        }
コード例 #12
0
        public void Keyboard_chat()
        {
            var writer = new TestXamlWriter();
            var entry  = new Entry
            {
                Keyboard = Keyboard.Chat
            };

            var xaml = writer.Save(entry);

            XamlAssert.AreEqual(xaml, "Keyboard", "Chat");
        }
コード例 #13
0
        public void Set_to_Center()
        {
            var writer = new TestXamlWriter();

            var label = new Label
            {
                VerticalOptions = LayoutOptions.Center
            };

            var xaml = writer.Save(label);

            XamlAssert.AreEqual(xaml, "VerticalOptions", "Center");
        }
コード例 #14
0
        public void Should_serialize_filename()
        {
            var writer = new TestXamlWriter();

            var btn = new Button
            {
                Image = (FileImageSource)ImageSource.FromFile("test.png")
            };

            var xaml = writer.Save(btn);

            XamlAssert.AreEqual(xaml, "Image", "test.png");
        }
コード例 #15
0
        public void Set_to_EndAndExpand()
        {
            var writer = new TestXamlWriter();

            var label = new Label
            {
                VerticalOptions = LayoutOptions.EndAndExpand
            };

            var xaml = writer.Save(label);

            XamlAssert.AreEqual(xaml, "VerticalOptions", "EndAndExpand");
        }
コード例 #16
0
        public void Should_serialize_fontsize()
        {
            var writer = new TestXamlWriter();

            var btn = new Button
            {
                FontSize = 25
            };

            var xaml = writer.Save(btn);

            XamlAssert.AreEqual(xaml, "FontSize", "25", "FontSize converter was not executed?");
        }
コード例 #17
0
        public void Family_and_size_set()
        {
            var writer = new TestXamlWriter();
            var label  = new Label
            {
                FontAttributes = FontAttributes.Bold,
                Font           = Font.OfSize("Droid Sans Mono", 24)
            };

            var xaml = writer.Save(label);

            XamlAssert.AreEqual(xaml, "Font", "Droid Sans Mono, None, 24");
        }
コード例 #18
0
        public void Should_set_and_retrieve_hex_value()
        {
            var          writer = new TestXamlWriter();
            const string hex    = "#FFB254";
            var          color  = Color.FromHex(hex);

            var page = new ContentPage {
                BackgroundColor = color
            };
            var xaml = writer.Save(page);

            XamlAssert.AreEqual(xaml, "BackgroundColor", hex);
        }
コード例 #19
0
        public void Size_and_attributes_set()
        {
            var writer = new TestXamlWriter();
            var label  = new Label
            {
                FontAttributes = FontAttributes.Bold,
                Font           = Font.SystemFontOfSize(18, FontAttributes.Bold)
            };

            var xaml = writer.Save(label);

            XamlAssert.AreEqual(xaml, "FontSize", "18", "Font Size");
            XamlAssert.AreEqual(xaml, "FontAttributes", "Bold", "Attributes");
        }
コード例 #20
0
        public void Should_set_red_to_hex_value()
        {
            const string url    = "http://www.test.com/test.html";
            var          writer = new TestXamlWriter();

            var page = new WebView
            {
                Source = new UrlWebViewSource {
                    Url = url
                }
            };

            var xaml = writer.Save(page);

            XamlAssert.AreEqual(xaml, "Source", url);
        }
コード例 #21
0
        public void Should_serialize_gridlength()
        {
            var writer = new TestXamlWriter();

            var grid = new Grid();

            grid.Children.Add(new Label());

            var page = new ContentPage
            {
                Content = grid
            };

            var xaml = writer.Save(page);

            Assert.Fail();
        }