예제 #1
0
        public void should_be_able_to_read_inline_values_from_transformation_configuration()
        {
            //ARRANGE
            const string testFilePath        = "test.xml";
            var          configurationReader = new TransformConfigurationReader
            {
                FileReader = TextFileReaderTestsHelpers.GetTextFileReaderMock(testFilePath, @"
                            <root>
                                <transformationGroup pattern=""aaa.pattern.xml"">
                                    <transformation output=""output.xml"">
                                        <values>
                                            <Val1>AAA</Val1>
                                        </values>                                    
                                    </transformation>
                                </transformationGroup>
                            </root>")
            };
            var transformConfigurations = configurationReader.ReadFromFile(testFilePath);
            var transformationToTest    = transformConfigurations.First();

            //ACT
            var values = transformationToTest.ValuesProvider.GetValues();


            //ASSERT
            Assert.IsNotNull(values);
            Assert.IsTrue(values.ContainsKey("Val1"));
            Assert.AreEqual(values["Val1"], "AAA");
        }
예제 #2
0
        public void should_be_able_to_read_transformations_from_file_with_placeholder_pattern()
        {
            //ARRANGE
            const string testFilePath        = "test.xml";
            var          configurationReader = new TransformConfigurationReader
            {
                FileReader = TextFileReaderTestsHelpers.GetTextFileReaderMock(testFilePath, @"
                            <root>
                                <transformationGroup pattern=""aaa.pattern.xml"" placeholderPattern=""#[KEY]"">
                                    <transformation values=""aaa.values.xml"" output=""output.xml"" />
                                </transformationGroup>
                            </root>")
            };

            //ACT
            var result = configurationReader.ReadFromFile(testFilePath);

            //ASSERT
            Assert.IsNotNull(result);
            CollectionAssert.IsNotEmpty(result);
            Assert.AreEqual("aaa.pattern.xml", result[0].PatternFilePath);
            Assert.IsNotNull(result[0].ValuesProvider);
            Assert.AreEqual("#[KEY]", result[0].PlaceholderPattern);
            Assert.AreEqual("output.xml", result[0].OutputFilePath);
        }
예제 #3
0
        public void should_be_able_to_suppress_all_post_transformation_on_lower_level_of_configuration()
        {
            //ARRANGE
            const string testFilePath        = "test.xml";
            var          configurationReader = new TransformConfigurationReader
            {
                FileReader = TextFileReaderTestsHelpers.GetTextFileReaderMock(testFilePath, @"
                            <root>
                                <postTransformations>
                                    <add name=""StripXMLComments"" />
                                    <add name=""ReFormatXML"" />
                                </postTransformations>
                                <transformationGroup pattern=""aaa.pattern.xml"">
                                    <transformation values=""aaa.values.xml"" output=""output.xml"">
                                        <postTransformations>
                                            <clear />
                                        </postTransformations>
                                    </transformation>
                                </transformationGroup>
                            </root>")
            };

            //ACT
            var transformConfigurations = configurationReader.ReadFromFile(testFilePath);


            //ASSERT
            var transformationToTest = transformConfigurations.First();

            Assert.IsNotNull(transformationToTest.PostTransformations);
            Assert.AreEqual(0, transformationToTest.PostTransformations.Count);
        }
예제 #4
0
        public void should_be_able_to_read_post_transformation_from_transformation_node_configuration()
        {
            //ARRANGE
            const string testFilePath        = "test.xml";
            var          configurationReader = new TransformConfigurationReader
            {
                FileReader = TextFileReaderTestsHelpers.GetTextFileReaderMock(testFilePath, @"
                            <root>
                                <transformationGroup pattern=""aaa.pattern.xml"">
                                    <transformation values=""aaa.values.xml"" output=""output.xml"">
                                        <postTransformations>
                                            <add name=""ReFormatXML"" />
                                        </postTransformations>
                                    </transformation>
                                </transformationGroup>
                            </root>")
            };

            //ACT
            var transformConfigurations = configurationReader.ReadFromFile(testFilePath);


            //ASSERT
            var transformationToTest = transformConfigurations.First();

            Assert.IsNotNull(transformationToTest.PostTransformations);
            Assert.AreEqual(1, transformationToTest.PostTransformations.Count);
            Assert.AreEqual("ReFormatXML", transformationToTest.PostTransformations.First().Name);
        }
예제 #5
0
        public static XmlTextFileReader CreateXmlTextFileReader(string path, string config)
        {
            var textFileReader    = TextFileReaderTestsHelpers.GetTextFileReaderMock(path, config);
            var xmlTextFileReader = new XmlTextFileReader(textFileReader);

            return(xmlTextFileReader);
        }
예제 #6
0
        public void should_be_able_to_read_many_transformation_for_single_pattern()
        {
            //ARRANGE
            const string testFilePath        = "test.xml";
            var          configurationReader = new TransformConfigurationReader
            {
                FileReader = TextFileReaderTestsHelpers.GetTextFileReaderMock(testFilePath, @"
                            <root>
                                <transformationGroup pattern=""aaa.pattern.xml"">
                                    <transformation values=""aaa.values.xml"" output=""output.xml"" />
                                    <transformation values=""aaa1.values.xml"" output=""output1.xml"" />
                                </transformationGroup>
                            </root>")
            };

            //ACT
            var result = configurationReader.ReadFromFile(testFilePath);

            //ASSERT
            Assert.IsNotNull(result);
            CollectionAssert.IsNotEmpty(result);
            Assert.AreEqual(2, result.Count);
        }