public void TestMergeUsingFile() { VelocityEngine velocityEngine = appContext.GetObject("fileBasedVelocityEngine") as VelocityEngine; Assert.IsNotNull(velocityEngine, "velocityEngine is null"); AssertMergedValue(velocityEngine, "Template/Velocity/SimpleTemplate.vm"); try { VelocityEngineUtils.MergeTemplateIntoString(velocityEngine, "NoneExistingFile", Encoding.UTF8.WebName, model); throw new TestException( "Merge using non existing file should throw exception"); } catch (Exception ex) { Assert.IsTrue(ex is VelocityException, "Illegal merge should throw VelocityException"); } }
/// <summary> /// Basic method for asserting the expected TEST_VALUE in the merged template /// </summary> protected void AssertMergedValue(VelocityEngine velocityEngine, string template) { string mergedTemplate = VelocityEngineUtils.MergeTemplateIntoString(velocityEngine, template, Encoding.UTF8.WebName, model); Assert.AreEqual(string.Format("value={0}", TEST_VALUE), mergedTemplate); }