Example #1
0
        public void TestSaveToFile()
        {
            RazorEngine razorEngine = new RazorEngine();
            IRazorEngineCompiledTemplate initialTemplate = razorEngine.Compile("Hello @Model.Name");

            initialTemplate.SaveToFile("testTemplate.dll");

            IRazorEngineCompiledTemplate loadedTemplate = RazorEngineCompiledTemplate.LoadFromFile("testTemplate.dll");

            string initialTemplateResult = initialTemplate.Run(new { Name = "Alex" });
            string loadedTemplateResult  = loadedTemplate.Run(new { Name = "Alex" });

            Assert.AreEqual(initialTemplateResult, loadedTemplateResult);
        }