public void DefaultNamespaceCombinesRelativeInputFilePathWithRootNamespace() { using (var transformation = new FakeTransformation()) using (var context = new TransformationContext(transformation, transformation.GenerationEnvironment)) using (var template = new TestClrTemplate()) { template.Context = context; transformation.Host.TemplateFile = Path.Combine(Environment.CurrentDirectory, "SubFolder\\Template.tt"); transformation.Host.GetMetadataValue = (hierarhcy, inputFile, metadataName) => string.Empty; transformation.Host.GetPropertyValue = (hierarchy, propertyName) => { switch (propertyName) { case "RootNamespace": return "TestNamespace"; case "MSBuildProjectFullPath": return Path.Combine(Environment.CurrentDirectory, "Project.proj"); default: return string.Empty; } }; Assert.AreEqual("TestNamespace.SubFolder", template.DefaultNamespace); } }
public void DefaultNamespaceCombinesRelativeInputFilePathWithRootNamespace() { using (var transformation = new FakeTransformation()) using (var context = new TransformationContext(transformation, transformation.GenerationEnvironment)) using (var template = new TestClrTemplate()) { template.Context = context; transformation.Host.TemplateFile = Path.Combine(Environment.CurrentDirectory, "SubFolder\\Template.tt"); transformation.Host.GetMetadataValue = (hierarhcy, inputFile, metadataName) => string.Empty; transformation.Host.GetPropertyValue = (hierarchy, propertyName) => { switch (propertyName) { case "RootNamespace": return("TestNamespace"); case "MSBuildProjectFullPath": return(Path.Combine(Environment.CurrentDirectory, "Project.proj")); default: return(string.Empty); } }; Assert.AreEqual("TestNamespace.SubFolder", template.DefaultNamespace); } }
public void RootNamespaceReturnsPropertyValueSuppliedByProvider() { using (var transformation = new FakeTransformation()) using (var context = new TransformationContext(transformation, transformation.GenerationEnvironment)) using (var template = new TestClrTemplate()) { template.Context = context; const string ExpectedValue = "TestNamespace"; string actualPropertyName = null; transformation.Host.GetPropertyValue = (hierarchy, propertyName) => { actualPropertyName = propertyName; return(ExpectedValue); }; Assert.AreEqual(ExpectedValue, template.RootNamespace); Assert.AreEqual("RootNamespace", actualPropertyName); } }
public void RootNamespaceReturnsPropertyValueSuppliedByProvider() { using (var transformation = new FakeTransformation()) using (var context = new TransformationContext(transformation, transformation.GenerationEnvironment)) using (var template = new TestClrTemplate()) { template.Context = context; const string ExpectedValue = "TestNamespace"; string actualPropertyName = null; transformation.Host.GetPropertyValue = (hierarchy, propertyName) => { actualPropertyName = propertyName; return ExpectedValue; }; Assert.AreEqual(ExpectedValue, template.RootNamespace); Assert.AreEqual("RootNamespace", actualPropertyName); } }