public void DoNotCreatePartialOutputFileIfExceptionDuringProcessWhenIndicated() { Assert.Throws <ArgumentException>(() => UpdateFile.Update(@"TestUpdateFiles\TestSubstitution5.xml", @"TestUpdateFiles\TestConfig1.xml")); var fileName = @"TestUpdateFiles\TestConfig1.xml_partial"; Assert.False(File.Exists(fileName)); }
public void JsonTest_WithFilePath() { dynamic newJson = JObject.Parse(UpdateFile.Update( @"TestUpdateFiles\TestSubstitution37.xml", @"TestUpdateFiles\TestJson01.json" )); Assert.AreEqual("C:\\Temp", (string)newJson.Data); }
public void SubstituteInNameSpacedFile() { var newConfig = XDocument.Parse(UpdateFile.Update(@"TestUpdateFiles\TestSubstitution3.xml", @"TestUpdateFiles\TestConfig2.xml")); var nms = new XmlNamespaceManager(new NameTable()); nms.AddNamespace("c", "http://madeup.com"); Assert.AreEqual("newvalue", newConfig.XPathSelectElement("/c:root/c:value", nms).Value); }
public void ChangeValueOfAttributeWithFixedSub() { var newConfig = XDocument.Parse(UpdateFile.Update( @"TestUpdateFiles\TestSubstitution7.xml", @"TestUpdateFiles\TestConfig3.xml" )); Assert.AreEqual("after", newConfig.XPathSelectElement("/root/value").Attribute("myAttr").Value); }
public void CreatePartialOutputFileIfExceptionDuringProcessWhenIndicated() { Assert.Throws <NDjangoWrapper.NDjangoWrapperException>(() => UpdateFile.Update(@"TestUpdateFiles\TestSubstitution5.xml", @"TestUpdateFiles\TestConfig1.xml", outputFailureContext: true)); var fileName = @"TestUpdateFiles\TestConfig1.xml_partial"; Assert.IsTrue(File.Exists(fileName)); }
public void RemoveChildrenIfEmptyReplacementSpecified() { var newConfig = XDocument.Parse(UpdateFile.Update( @"TestUpdateFiles\TestSubstitution8.xml", @"TestUpdateFiles\TestConfig3.xml" )); Assert.AreEqual("", newConfig.XPathSelectElement("/root/value").Value); }
public void DoNotChangeChildrenUnlessNewValueSpecified() { var newConfig = XDocument.Parse(UpdateFile.Update( @"TestUpdateFiles\TestSubstitution7.xml", @"TestUpdateFiles\TestConfig3.xml" )); Assert.AreEqual("oldValue", newConfig.XPathSelectElement("/root/value").Value); }
public void RemoveAttributesIfSpecified() { var newConfig = XDocument.Parse(UpdateFile.Update( @"TestUpdateFiles\TestSubstitution8.xml", @"TestUpdateFiles\TestConfig3.xml" )); Assert.IsNull(newConfig.XPathSelectElement("/root/value").Attribute("duckAttr")); }
public void CondensedChangeAttributeStructure() { var newConfig = XDocument.Parse(UpdateFile.Update( @"TestUpdateFiles\TestSubstitution28.xml", @"TestUpdateFiles\TestConfig3.xml" )); Assert.AreEqual("after", newConfig.XPathSelectElement("/root/value").Attribute("myAttr").Value); }
public void DoNotRemoveAttributesUnlessSpecified() { var newConfig = XDocument.Parse(UpdateFile.Update( @"TestUpdateFiles\TestSubstitution7.xml", @"TestUpdateFiles\TestConfig3.xml" )); Assert.AreEqual("quack", newConfig.XPathSelectElement("/root/value").Attribute("duckAttr").Value); }
public void InvalidSubstitutionXmlShouldThrow() { Assert.Throws <XmlSchemaValidationException>(() => XDocument.Parse(UpdateFile.Update( @"TestUpdateFiles\TestSubstitution20.xml", @"TestUpdateFiles\TestConfig2.xml", new Dictionary <string, object> { { "tagged", "after" }, { "Environment", "LOC" } } ))); }
public void EmptyChildContentWorks() { var newConfig = XDocument.Parse(UpdateFile.Update( @"TestUpdateFiles\TestSubstitution16.xml", @"TestUpdateFiles\TestConfig1.xml", new Dictionary <string, object> { { "newValue", "after" } } )); Assert.IsTrue(newConfig.XPathSelectElements("/root/value/NewTag").Count() == 0); }
public void SubstituteTaggedAttributeValue() { var newConfig = XDocument.Parse(UpdateFile.Update( @"TestUpdateFiles\TestSubstitution9.xml", @"TestUpdateFiles\TestConfig3.xml", new Dictionary <string, object> { { "newValue", "after" } } )); Assert.AreEqual("after", newConfig.XPathSelectElement("/root/value").Attribute("myAttr").Value); }
public void TagsOutsideSpecifiedXPathsUnchanged() { var newConfig = XDocument.Parse(UpdateFile.Update( @"TestUpdateFiles\TestSubstitution9.xml", @"TestUpdateFiles\TestConfig3.xml", new Dictionary <string, object> { { "newValue", "after" } } )); Assert.AreEqual("{{ tagged }}", newConfig.XPathSelectElement("/root/myValue").Value); }
public void SubstituteOldValueWithNewTaggedValue() { var newConfig = XDocument.Parse(UpdateFile.Update( @"TestUpdateFiles\TestSubstitution4.xml", @"TestUpdateFiles\TestConfig1.xml", new Dictionary <string, object> { { "taggedReplacementContent", "newvalue" } }.ToLazyTagDictionary() )); Assert.AreEqual("newvalue", newConfig.XPathSelectElement("/root/value").Value); }
public void PlainTextTemplatingWorks() { var newConfig = UpdateFile.Update( @"TestUpdateFiles\TestSubstitution21.xml", @"TestUpdateFiles\PlainText01.txt", new Dictionary <string, object> { { "tag", "after" }, { "Environment", "LOC" } }.ToLazyTagDictionary()); Assert.IsTrue(newConfig.Contains("after")); }
public void ReplaceFileWithTemplateWorks() { var newConfig = XDocument.Parse(UpdateFile.Update( @"TestUpdateFiles\TestSubstitution10.xml", @"TestUpdateFiles\TestConfig2.xml", new Dictionary <string, object> { { "tagged", "after" } }.ToLazyTagDictionary() )); Assert.AreEqual("after", newConfig.XPathSelectElement("/root/myValue").Value); }
public void AddChildContentWorks() { var newConfig = XDocument.Parse(UpdateFile.Update( @"TestUpdateFiles\TestSubstitution15.xml", @"TestUpdateFiles\TestConfig1.xml", new Dictionary <string, object> { { "newValue", "after" } }.ToLazyTagDictionary() )); Assert.AreEqual(1, newConfig.XPathSelectElements("/root/value/NewTag").Count()); }
public void AppendAfterWorks() { var newConfig = XDocument.Parse(UpdateFile.Update( @"TestUpdateFiles\TestSubstitution14.xml", @"TestUpdateFiles\TestConfig1.xml", new Dictionary <string, object> { { "newValue", "after" } } )); Assert.IsTrue(newConfig.Root.Descendants().Select(el => el.Name).Contains("NewTag")); }
public void ConcatFilterWorks() { var newConfig = UpdateFile.Update( @"TestUpdateFiles\TestSubstitution23.xml", @"TestUpdateFiles\PlainText03.txt", new Dictionary <string, object> { { "tag", "<after>" }, { "Environment", "LOC" } }); Assert.AreEqual("Some plain text. With a concat <after></after>.", newConfig); }
public void Transform() { var config = TagDictionary.FromSources("ident", new Dictionary <TagSource, string> { { TagSource.XmlFileName, @"ApprovalTestFiles\Config.xml" } }); var lazyConfig = new Lazy <TagDictionary>(() => config); var result = XDocument.Parse(UpdateFile.Update(@"ApprovalTestFiles\Substitution.xml", @"ApprovalTestFiles\BaseFile.xml", lazyConfig)); Approvals.VerifyXml(result.ToString()); }
public void SubstituteOldValueWithNewTaggedXmlValue() { var newConfig = XDocument.Parse(UpdateFile.Update( @"TestUpdateFiles\TestSubstitution5.xml", @"TestUpdateFiles\TestConfig1.xml", new Dictionary <string, object> { { "taggedReplacementContent", "newvalue" } } )); Assert.AreEqual("newvalue", newConfig.XPathSelectElement("/root/value").Descendants().First().Name.LocalName); }
public void PlainTextWithEscaping() { var newConfig = UpdateFile.Update( @"TestUpdateFiles\TestSubstitution22.xml", @"TestUpdateFiles\PlainText02.txt", new Dictionary <string, object> { { "tag", "<after>" }, { "Environment", "LOC" } }); Assert.AreEqual("Some plain text. With a {{ tag }}.", newConfig); }
public void NDjangoFiltersAvailable() { var newConfig = XDocument.Parse(UpdateFile.Update( @"TestUpdateFiles\TestSubstitution12.xml", @"TestUpdateFiles\TestConfig1.xml", new Dictionary <string, object> { { "newvalue", "AfTer" } } )); Assert.AreEqual("after", newConfig.XPathSelectElement("/root/value").Value); }
public void PlainTextTemplatingWorksEvenWithXmlEscapableCharacters() { var newConfig = UpdateFile.Update( @"TestUpdateFiles\TestSubstitution21.xml", @"TestUpdateFiles\PlainText01.txt", new Dictionary <string, object> { { "tag", "<after>" }, { "Environment", "LOC" } }); Assert.IsTrue(newConfig.Contains("<after>")); }
public void NewFileWithTemplateWorks() { var newConfig = XDocument.Parse(UpdateFile.Update( @"TestUpdateFiles\TestSubstitution11.xml", @"TestUpdateFiles\DoesntExist.xml", new Dictionary <string, object> { { "tagged", "after" } } )); Assert.AreEqual("after", newConfig.XPathSelectElement("/root/myValue").Value); }
public void SubstituteOldValueWithNewLoopedTaggedXmlValuesAsXml() { var newConfig = XDocument.Parse(UpdateFile.Update( @"TestUpdateFiles\TestSubstitution6.xml", @"TestUpdateFiles\TestConfig1.xml", new Dictionary <string, object> { { "configList", new [] { "newvalue1", "newvalue2", "newvalue3" } } } )); Assert.AreEqual("", newConfig.XPathSelectElement("/root/value/newvalue1").Value); }
public void SubstituteOldValueWithNewLoopedTaggedXmlValues() { var newConfig = XDocument.Parse(UpdateFile.Update( @"TestUpdateFiles\TestSubstitution6.xml", @"TestUpdateFiles\TestConfig1.xml", new Dictionary <string, object> { { "configList", new [] { "newvalue1", "newvalue2", "newvalue3" } } }.ToLazyTagDictionary() )); Assert.AreEqual(XElement.Parse("<value><newvalue1/><newvalue2 /><newvalue3/></value>").ToString(), newConfig.XPathSelectElement("/root/value").ToString()); }
public void TemplateAndChangesWork() { var newConfig = XDocument.Parse(UpdateFile.Update( @"TestUpdateFiles\TestSubstitution18.xml", @"TestUpdateFiles\TestConfig2.xml", new Dictionary <string, object> { { "tagged", "after" } } )); Assert.AreEqual("after", newConfig.XPathSelectElement("/root/myValue").Value); Assert.AreEqual("afterAttr", newConfig.XPathSelectElement("/root/myValue").Attribute("myAttr").Value); }
public void MultipleChildContentWorks() { var newConfig = XDocument.Parse(UpdateFile.Update( @"TestUpdateFiles\TestSubstitution17.xml", @"TestUpdateFiles\TestConfig1.xml", new Dictionary <string, object> { { "newValue", "after" } } )); Assert.AreEqual("1", newConfig.XPathSelectElements("/root/value/one").First().Value); Assert.AreEqual("2", newConfig.XPathSelectElements("/root/value/two").First().Value); }