Ejemplo n.º 1
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);
        }
Ejemplo n.º 2
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");
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 5
0
        private List <TransformConfiguration> GetTransformations()
        {
            if (IsTransformConfigurationFileSpecified())
            {
                var configurationReder = new TransformConfigurationReader();
                return(configurationReder.ReadFromFile(TransformConfiguration));
            }

            return(new List <TransformConfiguration>
            {
                new TransformConfiguration
                {
                    PatternFilePath = PatternFile,
                    OutputFilePath = OutputPath,
                    ValuesProvider = GetValuesProvider()
                }
            });
        }
        private List <TransformConfiguration> GetTransformations()
        {
            if (IsTransformConfigurationFileSpecified())
            {
                var configurationReader = new TransformConfigurationReader();
                return(configurationReader.ReadFromFile(_inputParameters.TransformConfiguration, _inputParameters.ProjectRootPath));
            }

            return(new List <TransformConfiguration>
            {
                new TransformConfiguration
                {
                    PatternFilePath = _inputParameters.PatternFile,
                    OutputFilePath = _inputParameters.OutputPath,
                    OutputArchive = _inputParameters.OutputArchivePath,
                    ValuesProvider = GetValuesProvider()
                }
            });
        }
Ejemplo n.º 7
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);
        }