public void GenerateFile_MvcViewTextTemplateSet_MvcViewTextTemplateUsedWhenGeneratingFile() { CreateGenerator(); ProjectPassedToGeneratorIsCSharpProject(); string expectedFileName = @"d:\templates\controller.tt"; MvcViewTextTemplate template = CreateViewTemplate(expectedFileName); generator.Template = template; GenerateFile(); string fileName = fakeHost.InputFilePassedToProcessTemplate; Assert.AreEqual(expectedFileName, fileName); }
public void GetMvcViewTextTemplates_CSharpRazorTemplatesRequestedAndTwoViewTemplatesInFolder_ReturnsTwoViewTextTemplates() { CreateRepositoryWithAspNetMvcAddInDirectory(@"C:\SD\AddIns\AspNet.Mvc"); string templateFolder = @"C:\SD\AddIns\AspNet.Mvc\ItemTemplates\CSharp\CodeTemplates\AddView\CSHTML"; string[] templateFileNames = new string[] { @"C:\SD\AddIns\AspNet.Mvc\ItemTemplates\CSharp\CodeTemplates\AddView\CSHTML\B.tt", @"C:\SD\AddIns\AspNet.Mvc\ItemTemplates\CSharp\CodeTemplates\AddView\CSHTML\A.tt" }; AddTextTemplatesToFolder(templateFolder, templateFileNames); var templateCriteria = new MvcTextTemplateCriteria() { TemplateLanguage = MvcTextTemplateLanguage.CSharp, TemplateType = MvcTextTemplateType.Razor }; List <MvcViewTextTemplate> templates = repository.GetMvcViewTextTemplates(templateCriteria).ToList(); var expectedTemplate1 = new MvcViewTextTemplate() { Name = "B", FileName = templateFileNames[0] }; var expectedTemplate2 = new MvcViewTextTemplate() { Name = "A", FileName = templateFileNames[1] }; var expectedTemplates = new MvcViewTextTemplate[] { expectedTemplate1, expectedTemplate2 }; MvcViewTextTemplateCollectionAssert.AreEqual(expectedTemplates, templates); }
static string ConvertToString(MvcViewTextTemplate template) { return(String.Format( "Name: {0}, FileName: {1}", template.Name, template.FileName)); }