Ejemplo n.º 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);
        }
Ejemplo n.º 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");
        }
Ejemplo n.º 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");
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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:"));
        }