예제 #1
0
        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);
        }
예제 #2
0
        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");
        }
예제 #3
0
        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");
        }
예제 #4
0
        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);
        }
예제 #5
0
        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);
        }
예제 #6
0
        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:"));
        }
예제 #7
0
        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);
                }
            }
        }
예제 #8
0
        internal static string Render(this string s)
        {
            var tagDictionary = TagDictionaryBuilder.BuildLazy(Arguments.FixedPath);

            return(s.RenderTemplate(tagDictionary));
        }
예제 #9
0
        internal static void DefaultUpdate()
        {
            var tagDictionary = TagDictionaryBuilder.BuildLazy(Arguments.FixedPath);

            ProcessSubstitution.Update(Arguments.SubstitutionPath, tagDictionary, Arguments.OutputFailureContext);
        }
예제 #10
0
        internal static void UpdateFiles()
        {
            var tagDictionary = TagDictionaryBuilder.BuildLazy(Arguments.FixedPath);

            ProcessFiles.UpdateFiles(Arguments.DeployFrom, Arguments.TemplateFilters, tagDictionary);
        }