Пример #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:"));
        }