public PatchPreviewForm(string sourceXml, string patchXml, Dictionary <string, string> roles) { InitializeComponent(); this.ConfigureDialog(); renderRoles(rolesLabel, roles); var result = SitecorePatcher.ApplyWithRoles(sourceXml, patchXml, "preview.patch.config", roles); var xml = XDocument.Parse(result); richTextBox.Text = xml.ToString(); foreach (var line in richTextBox.Lines) { if (line.Contains("preview.patch.config")) { int idx = richTextBox.Find(line); richTextBox.Select(idx, line.Length); richTextBox.SelectionColor = Color.Red; } } richTextBox.Select(0, 0); }
public void IntegrationTest_RoleNamespace_IsHandledCorrectly() { var xml = System.IO.File.ReadAllText(@"..\..\ExampleXml\role-namespace.config"); var sitecoreConfig = XDocument.Parse(xml); var patches = new BasePatch[] { new SetAttribute("/sitecore/sc.variable[@name='mediaFolder' and @role:require='Standalone']", "value", "~/StandAloneData"), }; var sut = new PatchGenerator(sitecoreConfig); var patchData = sut.GeneratePatchFile(patches); var patchElement = patchData .Element("configuration") .Element("sitecore") .Element("sc.variable"); Assert.IsNotNull(patchElement); Assert.AreEqual(4, patchElement.Attributes().Count()); Assert.AreEqual("mediaFolder", patchElement.Attribute("name").Value); var roles = new Dictionary <string, string>() { { "role", "Standalone" } }; var newXml = SitecorePatcher.ApplyWithRoles(xml, patchData.ToString(), "testpatch.config", roles); Assert.IsFalse(string.IsNullOrWhiteSpace(newXml)); var newXDoc = XDocument.Parse(newXml); var newElement = newXDoc.XPathSelectElement("/sitecore/sc.variable[@name='mediaFolder']"); Assert.IsNotNull(newElement); Assert.AreEqual(3, newElement.Attributes().Count()); Assert.AreEqual("~/StandAloneData", newElement.Attribute("value").Value); }