public void CreateEntryForView()
        {
            var descriptor = new SparkViewDescriptor().SetLanguage(LanguageType.Python);
            var entry      = _engine.CreateEntry(descriptor);
            var view       = entry.CreateInstance();

            Assert.IsInstanceOf(typeof(StubSparkView), view);
        }
Esempio n. 2
0
        public void TestExtensions()
        {
            var descriptor = new SparkViewDescriptor();

            descriptor.Templates.Add("Home\\extensionelements.spark");
            var entry = engine.CreateEntry(descriptor);

            Assert.That(entry.SourceCode.Contains("//this was a test"));
        }
Esempio n. 3
0
        public void GenerateSimpleTemplate()
        {
            var descriptor = new SparkViewDescriptor()
                .SetLanguage(LanguageType.Javascript)
                .AddTemplate("Clientside\\simple.spark");

            var engine = new SparkViewEngine { ViewFolder = new FileSystemViewFolder("Spark.Tests.Views") };
            var entry = engine.CreateEntry(descriptor);

            Assert.IsNotNull(entry.SourceCode);
            Assert.IsNotEmpty(entry.SourceCode);
        }
Esempio n. 4
0
        public void ProcessRequest(HttpContext context)
        {
            var engine = new SparkViewEngine
            {
                ViewFolder = new VirtualPathProviderViewFolder("~/Views")
            };
            var entry = engine.CreateEntry(new SparkViewDescriptor()
                                           .SetLanguage(LanguageType.Javascript)
                                           .AddTemplate(context.Request.PathInfo.TrimStart('/', Path.DirectorySeparatorChar) + ".spark"));

            //Spark.Simple._LiteralHtml({foo:'asoi'})
            context.Response.ContentType = "text/javascript";
            context.Response.Write(entry.SourceCode);
        }
Esempio n. 5
0
        public void ProcessRequest(HttpContext context)
        {
            var engine = new SparkViewEngine
                             {
                                 ViewFolder = new VirtualPathProviderViewFolder("~/Views")
                             };
            var entry = engine.CreateEntry(new SparkViewDescriptor()
                                               .SetLanguage(LanguageType.Javascript)
                                               .AddTemplate(context.Request.PathInfo.TrimStart('/', Path.DirectorySeparatorChar) + ".spark"));

            //Spark.Simple._LiteralHtml({foo:'asoi'})
            context.Response.ContentType = "text/javascript";
            context.Response.Write(entry.SourceCode);
        }
Esempio n. 6
0
        public void GenerateSimpleTemplate()
        {
            var descriptor = new SparkViewDescriptor()
                             .SetLanguage(LanguageType.Javascript)
                             .AddTemplate("Clientside\\simple.spark");

            var engine = new SparkViewEngine {
                ViewFolder = new FileSystemViewFolder("Spark.Tests.Views")
            };
            var entry = engine.CreateEntry(descriptor);

            Assert.IsNotNull(entry.SourceCode);
            Assert.IsNotEmpty(entry.SourceCode);
        }
Esempio n. 7
0
        public void AnonymousTypeBecomesHashLikeObject()
        {
            var descriptor = new SparkViewDescriptor()
                .SetLanguage(LanguageType.Javascript)
                .AddTemplate("Clientside\\AnonymousTypeBecomesHashLikeObject.spark");

            var engine = new SparkViewEngine { ViewFolder = new FileSystemViewFolder("Spark.Tests.Views") };
            var entry = engine.CreateEntry(descriptor);

            Assert.IsNotNull(entry.SourceCode);
            Assert.IsNotEmpty(entry.SourceCode);

            Assert.That(entry.SourceCode, Text.Contains("x = {foo:\"bar\",quux:5}"));
            Assert.That(entry.SourceCode, Text.Contains("HelloWorld({id:23,data:x})"));
        }
Esempio n. 8
0
        public void AnonymousTypeBecomesHashLikeObject()
        {
            var descriptor = new SparkViewDescriptor()
                             .SetLanguage(LanguageType.Javascript)
                             .AddTemplate("Clientside\\AnonymousTypeBecomesHashLikeObject.spark");

            var engine = new SparkViewEngine {
                ViewFolder = new FileSystemViewFolder("Spark.Tests.Views")
            };
            var entry = engine.CreateEntry(descriptor);

            Assert.IsNotNull(entry.SourceCode);
            Assert.IsNotEmpty(entry.SourceCode);

            Assert.That(entry.SourceCode, Text.Contains("x = {foo:\"bar\",quux:5}"));
            Assert.That(entry.SourceCode, Text.Contains("HelloWorld({id:23,data:x})"));
        }