protected async Task <string> AssertGenerateProjectAsync(Func <ITemplateInfo, bool> projectTemplateSelector, string projectName, string projectType, string framework, string language, Func <ITemplateInfo, string> getName = null, bool cleanGeneration = true) { await SetUpFixtureForTestingAsync(language); var targetProjectTemplate = _fixture.Templates().FirstOrDefault(projectTemplateSelector); ProjectName = projectName; ProjectPath = Path.Combine(_fixture.TestProjectsPath, projectName, projectName); OutputPath = ProjectPath; var userSelection = _fixture.SetupProject(projectType, framework, language, getName); if (getName != null) { _fixture.AddItems(userSelection, _fixture.GetTemplates(framework), getName); } await NewProjectGenController.Instance.UnsafeGenerateProjectAsync(userSelection); var resultPath = Path.Combine(_fixture.TestProjectsPath, projectName); // Assert Assert.True(Directory.Exists(resultPath)); Assert.True(Directory.GetFiles(resultPath, "*.*", SearchOption.AllDirectories).Count() > 2); AssertCorrectProjectConfigInfo(projectType, framework); // Clean if (cleanGeneration) { Fs.SafeDeleteDirectory(resultPath); } return(resultPath); }
protected async Task <string> AssertGenerateProjectAsync(Func <ITemplateInfo, bool> projectTemplateSelector, string projectName, string projectType, string framework, string platform, string language, Func <ITemplateInfo, bool> itemTemplatesSelector = null, Func <ITemplateInfo, string> getName = null, bool cleanGeneration = true) { BaseGenAndBuildFixture.SetCurrentLanguage(language); BaseGenAndBuildFixture.SetCurrentPlatform(platform); var targetProjectTemplate = _fixture.Templates().FirstOrDefault(projectTemplateSelector); var destinationPath = Path.Combine(_fixture.TestProjectsPath, projectName, projectName); GenContext.Current = new FakeContextProvider { ProjectName = projectName, DestinationPath = destinationPath, GenerationOutputPath = destinationPath, }; var userSelection = _fixture.SetupProject(projectType, framework, platform, language); if (getName != null && itemTemplatesSelector != null) { var itemTemplates = _fixture.Templates().Where(itemTemplatesSelector); _fixture.AddItems(userSelection, itemTemplates, getName); } await NewProjectGenController.Instance.UnsafeGenerateProjectAsync(userSelection); var resultPath = Path.Combine(_fixture.TestProjectsPath, projectName); // Assert Assert.True(Directory.Exists(resultPath)); Assert.True(Directory.GetFiles(resultPath, "*.*", SearchOption.AllDirectories).Count() > 2); if (platform == Platforms.Uwp) { AssertCorrectProjectConfigInfo(projectType, framework, platform); } // Clean if (cleanGeneration) { Fs.SafeDeleteDirectory(resultPath); } return(resultPath); }
protected async Task <string> AssertGenerateProjectAsync(string projectName, UserSelectionContext context, Func <ITemplateInfo, bool> itemTemplatesSelector = null, Func <TemplateInfo, string> getName = null, bool includeMultipleInstances = false) { BaseGenAndBuildFixture.SetCurrentLanguage(context.Language); BaseGenAndBuildFixture.SetCurrentPlatform(context.Platform); var destinationPath = Path.Combine(_fixture.TestProjectsPath, projectName, projectName); GenContext.Current = new FakeContextProvider { ProjectName = projectName, DestinationPath = destinationPath, GenerationOutputPath = destinationPath, }; var userSelection = _fixture.SetupProject(context); if (getName != null && itemTemplatesSelector != null) { var itemTemplates = _fixture.Templates().Where(itemTemplatesSelector); var itemsTemplateInfo = GenContext.ToolBox.Repo.GetTemplatesInfo(itemTemplates, context); _fixture.AddItems(userSelection, itemsTemplateInfo, getName, includeMultipleInstances); } await NewProjectGenController.Instance.UnsafeGenerateProjectAsync(userSelection); var resultPath = Path.Combine(_fixture.TestProjectsPath, projectName); // Assert Assert.True(Directory.Exists(resultPath)); Assert.True(Directory.GetFiles(resultPath, "*.*", SearchOption.AllDirectories).Count() > 2); if (context.Platform == Platforms.Uwp) { AssertCorrectProjectConfigInfo(context); } return(resultPath); }