static void Main(string[] args) { Stopwatch stopwatch = new Stopwatch(); int count = 1000; Console.WriteLine(string.Format("Transforming {0} templates", count)); stopwatch.Start(); for (int i = 0; i < count; i++) { TextTemplateTransformer transformer = new TextTemplateTransformer(); transformer.TransformFile(@"Template1.stt"); Console.Write("."); } stopwatch.Stop(); Console.WriteLine(); Console.WriteLine(string.Format("Completed in {0}", stopwatch.Elapsed)); Console.WriteLine(string.Format("Averaging {0} each", TimeSpan.FromMilliseconds(((double)stopwatch.Elapsed.TotalMilliseconds / (double)count)))); Console.WriteLine(); Console.WriteLine("Press any key to exit"); Console.ReadKey(); }
public void Transforming_Template1_ResultsInExpectedOutput() { // Arrange. var transformer = new TextTemplateTransformer(); var expected = new Template1().TransformText(); // Act. string output = transformer.TransformFile(@"Templates\Template1.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); }
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); }