public void ShouldUseCustomModuleName()
        {
            var options = new TemplateCompilerOptions
            {
                ModuleName = "myapp",
                WorkingDir = "/fixtures"
            };

            var compiler = new TemplateCompiler(options);
            var result = compiler.Compile(new VirtualFile[] {_template1});
            Assert.Equal(File.ReadAllText("../../../expected/compiled2.js"), result);
        }
        public void ShouldUseCustomModuleName()
        {
            var options = new TemplateCompilerOptions
            {
                ModuleName = "myapp",
                WorkingDir = "/fixtures"
            };

            var compiler = new TemplateCompiler(options);
            var result   = compiler.Compile(new VirtualFile[] { _template1 });

            Assert.Equal(File.ReadAllText("../../../expected/compiled2.js"), result);
        }
        private void SetupBundles(BundleCollection collection)
        {
            var options = new TemplateCompilerOptions
            {
                ModuleName = "myapp",
                Prefix = "/templates",
                WorkingDir = "../../../fixtures"
            };

            var bundle =
                new TemplateBundle("~/templates", options).Include("~/template1.html");
            bundle.Transforms.Clear();
            collection.Add(bundle);
        }
        public void ShouldRenderStandaloneModule()
        {
            var options = new TemplateCompilerOptions
            {
                ModuleName = "",
                WorkingDir = "/fixtures",
                Standalone = true
            };

            var compiler = new TemplateCompiler(options);
            var result   = compiler.Compile(new VirtualFile[] { _template1 });

            Assert.Equal(File.ReadAllText("../../../expected/compiled5.js"), result);
        }
        private void SetupBundles(BundleCollection collection)
        {
            var options = new TemplateCompilerOptions
            {
                ModuleName = "myapp",
                Prefix     = "/templates",
                WorkingDir = "../../../fixtures"
            };

            var bundle =
                new TemplateBundle("~/templates", options).Include("~/template1.html");

            bundle.Transforms.Clear();
            collection.Add(bundle);
        }
        public void ShouldLowercaseTemplateName()
        {
            var options = new TemplateCompilerOptions
            {
                ModuleName            = "",
                WorkingDir            = "/fixtures",
                LowercaseTemplateName = true
            };

            var template = new TestVirtualFile("/fixtures/TEMPLATE1.html", "test");
            var compiler = new TemplateCompiler(options);
            var result   = compiler.Compile(new VirtualFile[] { template });

            Assert.Equal(File.ReadAllText("../../../expected/compiled1.js"), result);
        }
        public void ShouldCombineMultipleFiles()
        {
            var options = new TemplateCompilerOptions
            {
                Prefix = "/templates",
                ModuleName = "myapp",
                WorkingDir = "/fixtures"
            };

            var compiler = new TemplateCompiler(options);
            var result = compiler.Compile(new VirtualFile[]
            {
                _template1,
                _template2
            });
            Assert.Equal(File.ReadAllText("../../../expected/compiled4.js"), result);
        }
        public void ShouldCombineMultipleFiles()
        {
            var options = new TemplateCompilerOptions
            {
                Prefix     = "/templates",
                ModuleName = "myapp",
                WorkingDir = "/fixtures"
            };

            var compiler = new TemplateCompiler(options);
            var result   = compiler.Compile(new VirtualFile[]
            {
                _template1,
                _template2
            });

            Assert.Equal(File.ReadAllText("../../../expected/compiled4.js"), result);
        }
 public TemplateBundle(string virtualPath, string cdnPath, TemplateCompilerOptions options)
     : base(virtualPath, cdnPath)
 {
     _options = options;
 }
        public void ShouldLowercaseTemplateName()
        {
            var options = new TemplateCompilerOptions
            {
                ModuleName = "",
                WorkingDir = "/fixtures",
                LowercaseTemplateName = true
            };

            var template = new TestVirtualFile("/fixtures/TEMPLATE1.html", "test");
            var compiler = new TemplateCompiler(options);
            var result = compiler.Compile(new VirtualFile[] {template});
            Assert.Equal(File.ReadAllText("../../../expected/compiled1.js"), result);
        }
        public void ShouldRenderStandaloneModule()
        {
            var options = new TemplateCompilerOptions
            {
                ModuleName = "",
                WorkingDir = "/fixtures",
                Standalone = true
            };

            var compiler = new TemplateCompiler(options);
            var result = compiler.Compile(new VirtualFile[] {_template1});
            Assert.Equal(File.ReadAllText("../../../expected/compiled5.js"), result);
        }