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 = GenerationFixture.Templates.FirstOrDefault(projectTemplateSelector); ProjectName = projectName; ProjectPath = Path.Combine(_fixture.TestProjectsPath, projectName, projectName); OutputPath = ProjectPath; var userSelection = await GenerationFixture.SetupProjectAsync(projectType, framework, language); if (getName != null) { GenerationFixture.AddItems(userSelection, GenerationFixture.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); // Clean if (cleanGeneration) { Fs.SafeDeleteDirectory(resultPath); } return(resultPath); }
public async void GenerateAllPagesAndFeaturesRandomNames(string projectType, string framework) { var targetProjectTemplate = GenerationFixture.Templates.FirstOrDefault(t => t.GetTemplateType() == TemplateType.Project && t.GetProjectTypeList().Contains(projectType) && t.GetFrameworkList().Contains(framework) && !t.GetIsHidden()); var projectName = $"{projectType}{framework}AllRandom"; ProjectName = projectName; ProjectPath = Path.Combine(_fixture.TestProjectsPath, projectName, projectName); OutputPath = ProjectPath; var userSelection = GenerationFixture.SetupProject(projectType, framework); GenerationFixture.AddItems(userSelection, GenerationFixture.GetTemplates(framework), GenerationFixture.GetRandomName); await NewProjectGenController.Instance.UnsafeGenerateProjectAsync(userSelection); //Build solution var outputPath = Path.Combine(_fixture.TestProjectsPath, projectName); var result = GenerationFixture.BuildSolution(projectName, outputPath); //Assert Assert.True(result.exitCode.Equals(0), $"Solution {targetProjectTemplate.Name} was not built successfully. {Environment.NewLine}Errors found: {GenerationFixture.GetErrorLines(result.outputFile)}.{Environment.NewLine}Please see {Path.GetFullPath(result.outputFile)} for more details."); //Clean Directory.Delete(outputPath, true); }