/// <summary>
        /// Check if everything is cleaned up.
        /// </summary>
        public string RazorEngineService_CleanUpWorks(CrossAppDomainCleanUp.IPrinter printer)
        {
            CrossAppDomainCleanUp.CurrentPrinter = printer;
            var cache = new DefaultCachingProvider();
            RazorEngineServiceTestFixture.RunTestHelper(service =>
            {
                string template = @"@Model.Name";

                var result = service.RunCompile(template, "test", null, new { Name = "test" });
                Assert.AreEqual("test", result);
            }, config =>
            {
                config.CachingProvider = cache;
            });
            ICompiledTemplate compiledTemplate;
            Assert.IsTrue(cache.TryRetrieveTemplate(new NameOnlyTemplateKey("test", ResolveType.Global, null), null, out compiledTemplate));
            var folder = compiledTemplate.CompilationData.TmpFolder;
            Assert.IsTrue(Directory.Exists(folder));
            return folder;
        }
        public void RazorEngineService_TestDebuggingWithHelperWithTemplateFile()
        {
            var cache = new DefaultCachingProvider();
            var file = System.IO.Path.GetTempFileName();

            var template =
            @"@helper Display(int price) {
            if (price == 0) {
            <text>free</text>
            } else {
            <text>@price</text>
            }
            }
            @Display(Model.MyPrice)";
            File.WriteAllText(file, template);
            RunTestHelper(service =>
            {
                var model = new { MyPrice = 0 };
                string result = service.RunCompile(new LoadedTemplateSource(template, file), "key", null, model);
                Assert.AreEqual("free", result.Trim());
            }, config => config.CachingProvider = cache);
            ICompiledTemplate compiledTemplate;
            Assert.IsTrue(cache.TryRetrieveTemplate(new NameOnlyTemplateKey("key", ResolveType.Global, null), null, out compiledTemplate));
            // Contains line pragmas with the template file.
            Assert.IsTrue(compiledTemplate.CompilationData.SourceCode.Contains(file), "");
            File.Delete(file);
        }
 public void RazorEngineService_TestDebuggingWithHelper()
 {
     var cache = new DefaultCachingProvider();
     var template =
     @"@helper Display(int price) {
     if (price == 0) {
     <text>free</text>
     } else {
     <text>@price</text>
     }
     }
     @Display(Model.MyPrice)";
     RunTestHelper(service =>
     {
         var model = new { MyPrice = 0 };
         string result = service.RunCompile(template, "key", null, model);
         Assert.AreEqual("free", result.Trim());
     }, config => config.CachingProvider = cache);
     ICompiledTemplate compiledTemplate;
     Assert.IsTrue(cache.TryRetrieveTemplate(new NameOnlyTemplateKey("key", ResolveType.Global, null), null, out compiledTemplate));
     // #line hidden should be removed, so make debugging work, see https://github.com/Antaris/RazorEngine/issues/253.
     Assert.IsFalse(compiledTemplate.CompilationData.SourceCode.Contains("#line hidden"));
 }
 public void Roslyn_TestDisableTempFileLocking()
 {
     var cache = new DefaultCachingProvider(t => { });
     var template = "@Model.Property";
     RunTestHelper(service =>
     {
         var model = new { Property = 0 };
         string result = service.RunCompile(template, "key", null, model);
         Assert.AreEqual("0", result.Trim());
     }, config =>
     {
         config.Debug = false;
         config.CachingProvider = cache;
         config.DisableTempFileLocking = true;
     });
     ICompiledTemplate compiledTemplate;
     Assert.IsTrue(cache.TryRetrieveTemplate(new NameOnlyTemplateKey("key", ResolveType.Global, null), null, out compiledTemplate));
     var data = compiledTemplate.CompilationData;
     var folder = data.TmpFolder;
     Assert.IsTrue(Directory.Exists(folder));
     data.DeleteAll();
     Assert.IsFalse(Directory.Exists(folder));
 }