This works for me:
using System.Collections;
using System.IO;
using NUnit.Framework;
using NVelocity;
using NVelocity.App;
[Test]
public void StringParsing()
{
var h = new Hashtable {
{ "foo", "Template" },
{ "bar", "is working" },
{ "foobar", new[] { "1", "2", "3" } } };
Velocity.Init();
var c = new VelocityContext( h );
var s = new StringWriter();
Velocity.Evaluate( c, s, "",
"$foo $bar: #foreach ($i in $foobar)$i#end" );
Assert.AreEqual( "Template is working: 123", s.ToString() );
}
source
share