public void CreateEntryForView() { var descriptor = new SparkViewDescriptor().SetLanguage(LanguageType.Python); var entry = _engine.CreateEntry(descriptor); var view = entry.CreateInstance(); Assert.IsInstanceOf(typeof(StubSparkView), view); }
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")); }
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); }
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); }
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); }
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); }
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})")); }
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})")); }