public void Transforming_Template4WithProgrammaticTransform_ResultsInExpectedOutput()
        {
            // Arrange.
            var transformer = new TextTemplateTransformer();
            var expected = "<html>\r\n<head>\r\n    <title>\r\n    </title>\r\n</head>\r\n<body>\r\n    Property 1 : passed-through-test-value\r\n</body>\r\n</html>\r\n";

            // Act.
            string output = transformer.TransformFile(@"Templates\NonT4Features\Template2.stt");

            // Assert.
            Assert.AreEqual(expected, output);
        }
        public void Transforming_Template3WithInclude_ResultsInExpectedOutput()
        {
            // Arrange.
            var transformer = new TextTemplateTransformer();
            var expected = new Template3().TransformText();

            // Act.
            string output = transformer.TransformFile(@"Templates\Template3.tt");

            // Assert.
            Assert.AreEqual(expected, output);
        }
        public void Transforming_Template4WithProperty_ResultsInExpectedOutput()
        {
            // Arrange.
            var transformer = new TextTemplateTransformer();
            var propertyValue = "test-value";
            var expected = "<html>\r\n<head>\r\n    <title>\r\n    </title>\r\n</head>\r\n<body>\r\n    Property 1 : " + propertyValue + "\r\n</body>\r\n</html>\r\n";

            // Act.
            string output = transformer.TransformFile(@"Templates\NonT4Features\Template1.stt", propertyValue);

            // Assert.
            Assert.AreEqual(expected, output);
        }
Beispiel #4
0
        /// <summary>
        ///     Transforms the specified text file and returns the result.
        /// </summary>
        /// <param name="relativePath">The relative path.</param>
        /// <param name="propertyValues">The property values.</param>
        /// <returns>The result of the transformation.</returns>
        public string TransformRelativeFile(string relativePath, params object[] propertyValues)
        {
            if (relativePath == null)
            {
                throw new ArgumentNullException("relativePath");
            }
            else if (string.IsNullOrWhiteSpace(relativePath))
            {
                throw new ArgumentException(InternalExceptionStrings.ArgumentException_EmptyOrWhitespaceString, "relativePath");
            }

            TextTemplateTransformer transformer = new TextTemplateTransformer();

            return(transformer.TransformFile(Path.Combine(scriptDirectory, relativePath), propertyValues));
        }
        public void Transforming_Template2WithImport_ResultsInExpectedOutput()
        {
            // Arrange.
            var context = new TestContext1
            {
                Property1 = DateTime.Now.ToString()
            };

            var transformer = new TextTemplateTransformer(context);
            var expected = new Template2() { Context = context }.TransformText();

            // Act.
            string output = transformer.TransformFile(@"Templates\Template2.tt");

            // Assert.
            Assert.AreEqual(expected, output);
        }
        /// <summary>
        ///     Transforms the specified text file and returns the result.
        /// </summary>
        /// <param name="relativePath">The relative path.</param>
        /// <param name="propertyValues">The property values.</param>
        /// <returns>The result of the transformation.</returns>
        public string TransformRelativeFile(string relativePath, params object[] propertyValues)
        {
            if (relativePath == null)
            {
                throw new ArgumentNullException("relativePath");
            }
            else if (string.IsNullOrWhiteSpace(relativePath))
            {
                throw new ArgumentException(InternalExceptionStrings.ArgumentException_EmptyOrWhitespaceString, "relativePath");
            }

            TextTemplateTransformer transformer = new TextTemplateTransformer();

            return transformer.TransformFile(Path.Combine(scriptDirectory, relativePath), propertyValues);
        }