ln.templates/test/HtmlTests.cs

38 lines
1.3 KiB
C#

// /**
// * File: HtmlTests.cs
// * Author: haraldwolff
// *
// * This file and it's content is copyrighted by the Author and / or copyright holder.
// * Any use wihtout proper permission is illegal and may lead to legal actions.
// *
// *
// **/
using NUnit.Framework;
using System;
using ln.templates.html;
using System.IO;
namespace ln.templates.test
{
[TestFixture()]
public class HtmlTests
{
[Test()]
public void TestCase()
{
ln.templates.html.TemplateReader templateReader = new ln.templates.html.TemplateReader();
templateReader.Read("<!DOCTYPE HTML>\n<html>\n<head>\n <title>Hello</title>\n</head>\n<body>\n <p>Welcome to this example.</p>\n <p>{{ 'Ich bin ein ScriptText!' }}</p>\n <p>DateTime: {{ Date }}</p>\n <p>Ein bisschen JavaScript: {{ 5 + ' mal ' + 5 + ' = ' + (5*5) }}</p>\n</body>\n</html>");
Console.WriteLine("Source rendered:\n{0}", templateReader.Document.ToString());
StringWriter stringWriter = new StringWriter();
RenderContext renderContext = new RenderContext(stringWriter);
renderContext.SetScriptObject("Date", DateTime.Now);
templateReader.TemplateDocument.RenderTemplate(renderContext);
Console.WriteLine("Template rendered:\n{0}", stringWriter.ToString());
}
}
}