public void Setup() { Teardown(); Directory.CreateDirectory("testtemplates"); using (var writer = new StreamWriter(@"testtemplates\testtemplate.vm")) { writer.Write("foo is $foo"); writer.Flush(); writer.Close(); } configurationMock = new DynamicMock(typeof(IConfigureTheTransformer)); configurationMock.SetupResult("TemplateDirectory", "testtemplates"); viewTransformer = new LazilyInitialisingVelocityTransformer((IConfigureTheTransformer)configurationMock.MockInstance); }
public void ShouldUseVelocityToMergeContextContentsWithTemplate() { Hashtable contextContents = new Hashtable(); contextContents["foo"] = "bar"; var pathMapperMock = new Mock <IPhysicalApplicationPathProvider>(); pathMapperMock.Setup(provider => provider.GetFullPathFor(It.IsAny <string>())).Returns(Path.Combine(".", "templates")); var pluginsMock = new Mock <IPluginConfiguration>(); pluginsMock.SetupGet(_configuration => _configuration.TemplateLocation).Returns(() => null); var configurationMock = new Mock <IDashboardConfiguration>(); configurationMock.SetupGet(_configuration => _configuration.PluginConfiguration).Returns(pluginsMock.Object); viewTransformer = new LazilyInitialisingVelocityTransformer((IPhysicalApplicationPathProvider)pathMapperMock.Object, (IDashboardConfiguration)configurationMock.Object); Assert.AreEqual("foo is bar", viewTransformer.Transform("TestTransform.vm", contextContents)); }
public void ShouldUseVelocityToMergeContextContentsWithTemplate() { Hashtable contextContents = new Hashtable(); contextContents["foo"] = "bar"; DynamicMock pathMapperMock = new DynamicMock(typeof(IPhysicalApplicationPathProvider)); pathMapperMock.SetupResult("GetFullPathFor", Path.Combine(".", "templates"), typeof(string)); DynamicMock pluginsMock = new DynamicMock(typeof(IPluginConfiguration)); pluginsMock.SetupResult("TemplateLocation", null); DynamicMock configurationMock = new DynamicMock(typeof(IDashboardConfiguration)); configurationMock.SetupResult("PluginConfiguration", pluginsMock.MockInstance); viewTransformer = new LazilyInitialisingVelocityTransformer((IPhysicalApplicationPathProvider)pathMapperMock.MockInstance, (IDashboardConfiguration)configurationMock.MockInstance); Assert.AreEqual("foo is bar", viewTransformer.Transform("testTransform.vm", contextContents)); }