public static IEnumerable <object[]> GetPageAndFeatureTemplatesForGeneration(string frameworkFilter)
        {
            InitializeTemplates(new LocalTemplatesSource(null, "TestGen"));

            return(BaseGenAndBuildFixture.GetPageAndFeatureTemplates(frameworkFilter));
        }
        protected async Task<string> AssertGenerateRightClickAsync(string projectName, UserSelectionContext context, bool emptyProject, List<string> excludedGroupIdentity = null)
        {
            BaseGenAndBuildFixture.SetCurrentLanguage(context.Language);
            BaseGenAndBuildFixture.SetCurrentPlatform(context.Platform);
            var path = Path.Combine(_fixture.TestNewItemPath, projectName, projectName);

            GenContext.Current = new FakeContextProvider
            {
                ProjectName = projectName,
                DestinationPath = path,
                GenerationOutputPath = path,
            };

            var userSelection = _fixture.SetupProject(context);
            var appModel = context.GetAppModel();

            if (!emptyProject)
            {
                var templates = _fixture.Templates().Where(
                    t => t.GetTemplateType().IsItemTemplate()
                    && (t.GetProjectTypeList().Contains(context.ProjectType) || t.GetProjectTypeList().Contains(All))
                    && (t.GetFrontEndFrameworkList().Contains(context.FrontEndFramework) || t.GetFrontEndFrameworkList().Contains(All))
                    && t.GetPlatform() == context.Platform
                    && (string.IsNullOrEmpty(appModel) || t.GetPropertyBagValuesList("appmodel").Contains(appModel) || t.GetPropertyBagValuesList("appmodel").Contains(All))
                    && (excludedGroupIdentity == null || (!excludedGroupIdentity.Contains(t.GroupIdentity)))
                    && !t.GetIsHidden());

                var templatesInfo = GenContext.ToolBox.Repo.GetTemplatesInfo(templates, context);

                _fixture.AddItems(userSelection, templatesInfo, BaseGenAndBuildFixture.GetDefaultName);
            }

            await NewProjectGenController.Instance.UnsafeGenerateProjectAsync(userSelection);

            var project = Path.Combine(_fixture.TestNewItemPath, projectName);

            // Assert on project
            Assert.True(Directory.Exists(project));

            int emptyProjecFileCount = Directory.GetFiles(project, "*.*", SearchOption.AllDirectories).Count();
            Assert.True(emptyProjecFileCount > 2);

            var rightClickTemplates = _fixture.Templates().Where(
                t => t.GetTemplateType().IsItemTemplate()
                && (t.GetProjectTypeList().Contains(context.ProjectType) || t.GetProjectTypeList().Contains(All))
                && (t.GetFrontEndFrameworkList().Contains(context.FrontEndFramework) || t.GetFrontEndFrameworkList().Contains(All))
                && t.GetPlatform() == context.Platform
                && (string.IsNullOrEmpty(appModel) || t.GetPropertyBagValuesList("appmodel").Contains(appModel) || t.GetPropertyBagValuesList("appmodel").Contains(All))
                && !t.GetIsHidden()
                && (excludedGroupIdentity == null || (!excludedGroupIdentity.Contains(t.GroupIdentity)))
                && t.GetRightClickEnabled());

            await AddRightClickTemplatesAsync(path, rightClickTemplates, projectName, context.ProjectType, context.FrontEndFramework, context.Platform, context.Language);

            var finalProjectPath = Path.Combine(_fixture.TestNewItemPath, projectName);
            int finalProjectFileCount = Directory.GetFiles(finalProjectPath, "*.*", SearchOption.AllDirectories).Count();

            if (emptyProject)
            {
                Assert.True(finalProjectFileCount > emptyProjecFileCount);
            }
            else
            {
                Assert.True(finalProjectFileCount == emptyProjecFileCount);
            }

            return finalProjectPath;
        }
Пример #3
0
        public static IEnumerable <object[]> GetPageAndFeatureTemplatesForBuild(string frameworkFilter)
        {
            InitializeTemplates(new LocalTemplatesSource(ShortFrameworkName(frameworkFilter)));

            return(BaseGenAndBuildFixture.GetPageAndFeatureTemplates(frameworkFilter));
        }
Пример #4
0
        public static IEnumerable <object[]> GetPageAndFeatureTemplatesForBuild(string frameworkFilter, string language = ProgrammingLanguages.CSharp)
        {
            InitializeTemplates(new LocalTemplatesSource(null, ShortFrameworkName(frameworkFilter)));

            return(BaseGenAndBuildFixture.GetPageAndFeatureTemplates(frameworkFilter, language));
        }
 public BaseGenAndBuildTests(BaseGenAndBuildFixture fixture, IContextProvider contextProvider = null, string framework = "")
 {
     _fixture = fixture;
     _fixture.InitializeFixture(contextProvider ?? new FakeContextProvider(), framework);
 }
        protected async Task <(string ProjectPath, string ProjectName)> SetUpComparisonProjectAsync(string language, string projectType, string framework, IEnumerable <string> genIdentities, bool lastPageIsHome = false, bool includeMultipleInstances = true)
        {
            BaseGenAndBuildFixture.SetCurrentLanguage(language);
            BaseGenAndBuildFixture.SetCurrentPlatform(Platforms.Uwp);

            var singlePageName = string.Empty;

            var genIdentitiesList = genIdentities.ToList();

            if (genIdentitiesList.Count == 1)
            {
                singlePageName = genIdentitiesList.Last().Split('.').Last();
            }

            var projectName     = $"{projectType}{framework}{singlePageName}{ShortLanguageName(language)}";
            var destinationPath = Path.Combine(_fixture.TestProjectsPath, projectName, projectName);

            GenContext.Current = new FakeContextProvider
            {
                ProjectName          = projectName,
                DestinationPath      = destinationPath,
                GenerationOutputPath = destinationPath,
            };

            var context = new UserSelectionContext(language, Platforms.Uwp)
            {
                ProjectType       = projectType,
                FrontEndFramework = framework,
            };

            var userSelection = _fixture.SetupProject(context);

            foreach (var identity in genIdentitiesList)
            {
                var itemTemplate = _fixture.Templates().FirstOrDefault(t
                                                                       => (t.Identity.StartsWith($"{identity}.") || t.Identity.Equals(identity)) &&
                                                                       (t.GetProjectTypeList().Contains(projectType) || t.GetProjectTypeList().Contains(All)) &&
                                                                       (t.GetFrontEndFrameworkList().Contains(framework) || t.GetFrontEndFrameworkList().Contains(All)));

                var templateInfo = GenContext.ToolBox.Repo.GetTemplateInfo(itemTemplate, context);
                _fixture.AddItem(userSelection, templateInfo, BaseGenAndBuildFixture.GetDefaultName);

                // Add multiple pages if supported to check these are handled the same
                if (includeMultipleInstances && templateInfo.MultipleInstance)
                {
                    _fixture.AddItem(userSelection, templateInfo, BaseGenAndBuildFixture.GetDefaultName);
                }
            }

            if (lastPageIsHome)
            {
                // Useful if creating a blank project type and want to change the start page
                userSelection.HomeName = userSelection.Pages.Last().Name;

                if (projectType == ProjectTypes.TabbedNav)
                {
                    userSelection.Pages.Reverse();
                }
            }

            await NewProjectGenController.Instance.UnsafeGenerateProjectAsync(userSelection);

            var resultPath = Path.Combine(_fixture.TestProjectsPath, GenContext.Current.ProjectName);

            return(resultPath, GenContext.Current.ProjectName);
        }
        protected async Task <string> AssertGenerateRightClickAsync(string projectName, string projectType, string framework, string platform, string language, bool emptyProject, string excludedGroupIdentity = "")
        {
            BaseGenAndBuildFixture.SetCurrentLanguage(language);
            BaseGenAndBuildFixture.SetCurrentPlatform(platform);
            var path = Path.Combine(_fixture.TestNewItemPath, projectName, projectName);

            GenContext.Current = new FakeContextProvider
            {
                ProjectName          = projectName,
                DestinationPath      = path,
                GenerationOutputPath = path,
            };

            var userSelection = _fixture.SetupProject(projectType, framework, platform, language);

            if (!emptyProject)
            {
                var templates = _fixture.Templates().Where(
                    t => t.GetTemplateType().IsItemTemplate() &&
                    (t.GetProjectTypeList().Contains(projectType) || t.GetProjectTypeList().Contains(All)) &&
                    t.GetFrontEndFrameworkList().Contains(framework) &&
                    t.GetPlatform() == platform &&
                    t.GroupIdentity != excludedGroupIdentity &&
                    !t.GetIsHidden());

                var templatesInfo = GenContext.ToolBox.Repo.GetTemplatesInfo(templates, platform, projectType, framework, _emptyBackendFramework);

                _fixture.AddItems(userSelection, templatesInfo, BaseGenAndBuildFixture.GetDefaultName);
            }

            await NewProjectGenController.Instance.UnsafeGenerateProjectAsync(userSelection);

            var project = Path.Combine(_fixture.TestNewItemPath, projectName);

            // Assert on project
            Assert.True(Directory.Exists(project));

            int emptyProjecFileCount = Directory.GetFiles(project, "*.*", SearchOption.AllDirectories).Count();

            Assert.True(emptyProjecFileCount > 2);

            var rightClickTemplates = _fixture.Templates().Where(
                t => t.GetTemplateType().IsItemTemplate() &&
                (t.GetProjectTypeList().Contains(projectType) || t.GetProjectTypeList().Contains(All)) &&
                t.GetFrontEndFrameworkList().Contains(framework) &&
                t.GetPlatform() == platform &&
                !t.GetIsHidden() &&
                t.GetRightClickEnabled());

            await AddRightClickTemplatesAsync(path, rightClickTemplates, projectName, projectType, framework, platform, language);

            var finalProjectPath      = Path.Combine(_fixture.TestNewItemPath, projectName);
            int finalProjectFileCount = Directory.GetFiles(finalProjectPath, "*.*", SearchOption.AllDirectories).Count();

            if (emptyProject)
            {
                Assert.True(finalProjectFileCount > emptyProjecFileCount);
            }
            else
            {
                Assert.True(finalProjectFileCount == emptyProjecFileCount);
            }

            return(finalProjectPath);
        }