Ejemplo n.º 1
0
        public void PatchInsert_PatchGenerator_Accepts_Insert()
        {
            var ins = new PatchInsert("/sitecore/sites", ElementInsertPosition.After, "*[@name='a']", new XElement("site", new XAttribute("name", "c")));
            var xml = XDocument.Parse("<sitecore><sites><site name=\"a\"/><site name=\"b\"/></sites></sitecore>");

            var sut = new PatchGenerator(xml);

            var result = sut.GeneratePatchFile(new BasePatch[] { ins });

            var sites = result
                        .Element("configuration")
                        .Element("sitecore")
                        .Element("sites")
                        .Elements("site");

            Assert.AreEqual(1, sites.Count());

            var newSite = result
                          .Element("configuration")
                          .Element("sitecore")
                          .Element("sites")
                          .Element("site");

            Assert.IsNotNull(newSite);
            Assert.AreEqual("c", newSite.Attribute("name").Value);

            Assert.IsNotNull(newSite.Attribute(Namespaces.Patch + "after"));
        }
Ejemplo n.º 2
0
        public void PatchInsert_Constructor_ValidPatchXml_Works()
        {
            var newElement = new XElement("test");
            var sut        = new PatchInsert("/sites/site", ElementInsertPosition.Before, "//*[]", newElement);

            Assert.AreEqual("test", sut.NewElement.Name);
        }
Ejemplo n.º 3
0
        private void okButton_Click(object sender, EventArgs e)
        {
            var xml = XElement.Parse(newElementTextBox.Text);

            var patchInsert = new PatchInsert(
                parentXPathTextBox.Text,
                (ElementInsertPosition)positionComboBox.SelectedItem,
                orderXPathTextBox.Text,
                xml
                );

            Patch = new PatchItem(patchInsert, _treeNode);
        }
Ejemplo n.º 4
0
        public void PatchInsert_Constructor_EmptyOrder_Throws()
        {
            var newElement = new XElement("test");

            var sut = new PatchInsert("/sites/site", ElementInsertPosition.Before, string.Empty, newElement);
        }
Ejemplo n.º 5
0
 public void PatchInsert_Constructor_NullPatchXml_Throws()
 {
     var sut = new PatchInsert("/sites/site", ElementInsertPosition.Before, "//*[]", null);
 }
Ejemplo n.º 6
0
        public void PatchInsert_Constructor_EmptyPath_Throws()
        {
            var newElement = new XElement("test");

            var sut = new PatchInsert(string.Empty, ElementInsertPosition.Before, "//*[]", newElement);
        }