public void CanParseScriptWriteBlock() { var template = new RubyTemplate("<%= \"Hello World\" %>"); var result = template.ToScript(); Assert.Equal("response.Write(\"Hello World\")", result); }
public void CanParseMultiLineBlock() { var template = new RubyTemplate("<% puts \"Hello World\"\r\nputs 'IronRuby is fun!' %>"); var result = template.ToScript(); Assert.Equal("puts \"Hello World\"\r\nputs 'IronRuby is fun!'", result); }
public void CanAddRequires() { var template = new RubyTemplate(string.Empty); template.AddRequire("mscorlib.dll"); Assert.Equal(@"require 'mscorlib.dll'", template.ToScript()); }
public void ParsingAScriptBlockThatStartsButDoesNotEndThrowsInvalidOperationException() { var template = new RubyTemplate("<%="); Assert.Throws <InvalidOperationException>("Started a '<%=' block without ending it.", () => template.ToScript()); }
public void CanParseHtmlContainingDoubleQuotes() { var template = new RubyTemplate("<html><span title=\"blah\" /></html>"); var result = template.ToScript(); var expected = @"response.Write(""<html><span title=\""blah\"" /></html>"")"; Assert.Equal(expected, result); }
public void TemplateWithBackslashDoesNotCauseException() { var template = new RubyTemplate(@"<html>\</html>"); var result = template.ToScript(); var expected = ExpectedWrite(@"""<html>\\</html>"""); Assert.Equal(expected, result); }
public void CanParseHtmlBeginningInScriptBlock() { var template = new RubyTemplate("<% puts 'test' %></html>"); var result = template.ToScript(); var expected = "puts 'test'" + Environment.NewLine + ExpectedWrite("\"</html>\""); Assert.Equal(expected, result); }
public void TestTemplate() { var tem = new RubyTemplate(); tem.ModuleName = "Zxd.Script"; tem.AliasName = "�ű�"; tem.ScriptName = "Zxd"; //tem.Content = "1 + 1"; //tem.ToScript(); }
public void LeavesHtmlAlone() { var template = new RubyTemplate("<html>\r\n<head><title></title></head>\r\n<body>\r\nHello World</body>\r\n</html>"); var result = template.ToScript(); Assert.Equal( ExpectedWrite( "\"<html>\\r\\n<head><title></title></head>\\r\\n<body>\\r\\nHello World</body>\\r\\n</html>\""), result); }
public void CanConverToScript() { var template = new RubyTemplate("<% puts 'test' %></html>"); var result = template.ToScript("puts_test"); var expected = "def puts_test" + Environment.NewLine + "puts 'test'" + Environment.NewLine + ExpectedWrite("\"</html>\"") + Environment.NewLine + "end"; Assert.Equal(expected, result); }
public void CanRemoveNewlineAtEnd() { var original = "<% [1..10].each do |i| %>" + Environment.NewLine + " <%= i -%>"+ Environment.NewLine + "<% end %>"; var template = new RubyTemplate(original); var result = template.ToScript(); var expected = "[1..10].each do |i|" + Environment.NewLine + ExpectedWrite(@"""\r\n """) + Environment.NewLine + ExpectedWrite("i") + Environment.NewLine + "end"; Assert.Equal(expected, result); }
public void TestSave() { var tem = new RubyTemplate(); tem.ModuleName = "Zxd.Script"; tem.AliasName = "�ű�"; tem.ScriptName = "Zxd"; tem.Content = "1 + 1"; tem.Requires.Add("sdfsadfasf"); tem.Requires.Add("sdfaaaaaa"); tem.Footnode.Add("----------------"); tem.Footnode.Add("--------------------"); tem.Roles.Add("role"); tem.Users.Add("user"); var item = "RubyTemplateRespository".GetInstance<IRubyTemplateRepository>(); item.Add(tem); }
public void CanParseScriptBlock() { var template = new RubyTemplate("<% puts 'hello world' %>"); Assert.Equal("puts 'hello world'", template.ToScript()); }
public void CanParseEmptyTemplate() { var template = new RubyTemplate(string.Empty); Assert.Equal(string.Empty, template.ToScript()); }