public void Document_is_loaded() { var proc = new XamlPostProcessor(); proc.LoadDocument("<test></test>"); Assert.IsTrue(proc.IsDocumentLoaded); }
public void Should_get_document_namespaces() { var proc = new XamlPostProcessor(); proc.LoadDocument($"<root xmlns:a='{Uri}'></root>"); var nss = proc.GetDocumentNamespaces(); Assert.AreEqual(2, nss.Count); Assert.AreEqual(Uri, nss["a"]); }
public void Document_is_not_loaded_after_reset() { var proc = new XamlPostProcessor(); proc.LoadDocument("<test></test>"); Assert.IsTrue(proc.IsDocumentLoaded); proc.Reset(); Assert.IsFalse(proc.IsDocumentLoaded); }
public void Property_values_and_property_element_values_are_same() { var proc = new XamlPostProcessor(); proc.LoadElementDefaults(XAMLTests.Nulls_ContentPage_Defaults); proc.LoadElementDefaults(XAMLTests.Nulls_Label_Defaults); proc.LoadDocument(XAMLTests.Nulls_Input); var doc = proc.Process(); var els = doc?.Document?.Root?.Elements().ToArray(); Assert.AreEqual(1, els?.Length); }
public void Should_remove_all_default_attributes_and_elements() { var proc = new XamlPostProcessor(); proc.LoadElementDefaults(XAMLTests.Button_Defaults); proc.LoadElementDefaults(XAMLTests.Button_Page_Defaults); proc.LoadDocument(XAMLTests.Button_Page); var doc = proc.Process(); var root = GetRoot(doc); var e1 = root.Elements().FirstOrDefault(); Assert.AreEqual("ContentPage", root.Name.LocalName); Assert.IsTrue(e1?.IsEmpty); }
public void Should_rename_design_surface_elements() { var proc = new XamlPostProcessor(); var doc = proc.LoadDocument(XAMLTests.DesignSurfaceElement); var all = doc.Document?.Root?.DescendantsAndSelf().ToArray(); proc.RenameDesignSurfaceElements(); Assert.AreEqual(XamlPostProcessor.ContentPageElement, doc.Document?.Root?.Name.LocalName); var parent = all.Any(e => e.Name.LocalName == "ContentPage.Parent"); Assert.IsTrue(parent, "Parent"); var other = all.Any(e => e.Name.LocalName == "Other"); Assert.IsTrue(other, "Other"); }
public void Should_retain_attached_property_in_original_and_not_in_modified_version() { var xtr = new XamlTreeReader(XAMLTests.AP_Test1_Page); xtr.Read(); var proc = new XamlPostProcessor(); proc.LoadElementDefaults(XAMLTests.AP_Test1_Entry_Defaults); proc.LoadElementDefaults(XAMLTests.AP_Test1_Page_Default); proc.LoadDocument(XAMLTests.AP_Test1_Page_Modified, xtr.All); var doc = proc.Process(); var els = doc.Descendants().ToArray(); var ap1 = els[1].Attributes().FirstOrDefault(a => a.Name.LocalName == "AP.Test1"); var ap2 = els[2].Attributes().FirstOrDefault(a => a.Name.LocalName == "AP.Test1"); Assert.AreEqual("165", ap1.Value); Assert.IsNull(ap2); }
public void Should_only_detect_changes() { var proc = new XamlPostProcessor(); proc.LoadElementDefaults(XAMLTests.Entry_Defaults); proc.LoadElementDefaults(XAMLTests.Entry_Page_Defaults); proc.LoadDocument(XAMLTests.Entry_Page); var doc = proc.Process(); var root = GetRoot(doc); var entry = root.Elements().First(); var attribs = entry.Attributes().ToArray(); var isEnabled = GetAttribute(attribs, "IsEnabled"); var margin = GetAttribute(attribs, "Margin"); var placeholder = GetAttribute(attribs, "Placeholder"); Assert.AreEqual(5, attribs.Length); Assert.AreEqual("False", isEnabled.Value); Assert.AreEqual("30", margin.Value); Assert.AreEqual("Test", placeholder.Value); }