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); }
public void Font_should_be_empty_string() { var writer = new TestXamlWriter(); var label = new Label(); var xaml = writer.Save(label); XamlAssert.AreEqual(xaml, "Font", "", """?"); }
public void Source_property_xnull() { var writer = new TestXamlWriter(); var img = new Image(); var xaml = writer.Save(img); XamlAssert.AreEqual(xaml, "Source", "{x:Null}"); }
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"); }
public void Keyboard_default() { var writer = new TestXamlWriter(); var entry = new Entry(); var xaml = writer.Save(entry); XamlAssert.AreEqual(xaml, "Keyboard", "Default"); }
public void Default_set() { var writer = new TestXamlWriter(); var label = new Label(); var xaml = writer.Save(label); XamlAssert.AreEqual(xaml, "VerticalOptions", "Fill"); }
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); }
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"); }
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); }
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"); }
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"); }
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"); }
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"); }
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"); }
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"); }
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?"); }
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"); }
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); }
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"); }
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); }
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(); }