public void BuildTagDictionary_InvalidPath() { //Act var exception = Assert.Throws <FileNotFoundException>(() => TagDictionaryBuilder.Build(@"D:\FixedStructure\D:\FixedStructure\#{FixedStructureFile}")); //Assert Assert.NotNull(exception); Assert.AreEqual("No structure file found at D:\\FixedStructure\\D:\\FixedStructure\\#{FixedStructureFile}", exception.Message); }
public void BuildTagDictionary_ValidPathAndContent() { //Act var dictionary = TagDictionaryBuilder.Build(Path.Combine(testFilePath, "structure.xml")); //Assert Assert.IsNotEmpty(dictionary, "TagDictionary was empty"); Assert.AreEqual(EnvClientCode, dictionary["ClientCode"], "TagDictionary[\"ClientCode\"] was not correct"); Assert.AreEqual(EnvEnvironment, dictionary["Environment"], "TagDictionary[\"Environment\"] was not correct"); Assert.AreEqual($"{EnvClientCode}.{EnvEnvironment}.example.com", dictionary["ClientDomain"], "TagDictionary[\"ClientDomain\"] was not correct"); }
public void BuildTagDictionary_EmptyString() { //Act var dictionary = TagDictionaryBuilder.Build(string.Empty); //Assert Assert.IsNotEmpty(dictionary, "TagDictionary was empty"); Assert.AreEqual(EnvClientCode, dictionary["ClientCode"], "TagDictionary[\"ClientCode\"] was not correct"); Assert.AreEqual(EnvEnvironment, dictionary["Environment"], "TagDictionary[\"Environment\"] was not correct"); Assert.False(dictionary.ContainsKey("ClientDomain"), "TagDictionary ClientDomain was found"); }
public void BuildTagDictionary_ValidPathAndInvalidContent() { //Arrange var path = Path.Combine(testFilePath, "invalidStructure.xml"); //Act var exception = Assert.Throws <XmlException>(() => TagDictionaryBuilder.Build(path)); //Assert Assert.NotNull(exception); Assert.AreEqual("Unable to parse XML data", exception.Message); }
public void BuildTagDictionary_NonExistentPath() { //Arrange var path = $@"D:\FixedStructure\NonExistantFile-{Guid.NewGuid()}.xml"; //Act var exception = Assert.Throws <FileNotFoundException>(() => TagDictionaryBuilder.Build(path)); //Assert Assert.NotNull(exception); Assert.AreEqual($"No structure file found at {path}", exception.Message); }
public void BuildTagDictionary_ValidPathAndIncorrectStructure() { //Arrange var path = Path.Combine(testFilePath, "incorrectStructure.xml"); //Act var exception = Assert.Throws <XmlSchemaValidationException>(() => TagDictionaryBuilder.Build(path)); //Assert Assert.NotNull(exception); //NOTE: The entire message isn't used as the exception has different order of elements & that is framework controlled Assert.That(exception.Message.StartsWith("The element 'Structure' has incomplete content. List of possible elements expected:")); }
internal static void ExportTagDictionary() { var tagDictionary = TagDictionaryBuilder.BuildLazy(Arguments.FixedPath); var tagDictionaryJson = JsonConvert.SerializeObject(tagDictionary, Formatting.Indented); if (!string.IsNullOrWhiteSpace(Arguments.DictionarySavePath)) { File.WriteAllText(Arguments.DictionarySavePath, tagDictionaryJson); } if (!string.IsNullOrWhiteSpace(Arguments.DictionaryPostUrl)) { using (var cli = new WebClient { Headers = { [HttpRequestHeader.ContentType] = "application/json" } }) { cli.UploadString(Arguments.DictionaryPostUrl, tagDictionaryJson); } } }
internal static string Render(this string s) { var tagDictionary = TagDictionaryBuilder.BuildLazy(Arguments.FixedPath); return(s.RenderTemplate(tagDictionary)); }
internal static void DefaultUpdate() { var tagDictionary = TagDictionaryBuilder.BuildLazy(Arguments.FixedPath); ProcessSubstitution.Update(Arguments.SubstitutionPath, tagDictionary, Arguments.OutputFailureContext); }
internal static void UpdateFiles() { var tagDictionary = TagDictionaryBuilder.BuildLazy(Arguments.FixedPath); ProcessFiles.UpdateFiles(Arguments.DeployFrom, Arguments.TemplateFilters, tagDictionary); }