public void Compose_GenerationWithRequirement()
        {
            GenContext.Current = new TestContextProvider()
            {
                DestinationPath = string.Empty,
                ProjectName     = "TestProject",
            };

            var userSelection = new UserSelection("pt1", "fx1", string.Empty, "test", ProgrammingLanguages.CSharp)
            {
                HomeName = "TestHome",
            };

            userSelection.Add(new UserSelectionItem()
            {
                Name = "Main", TemplateId = "Microsoft.Templates.Test.PageTemplate.CSharp"
            }, TemplateType.Page);
            userSelection.Add(new UserSelectionItem()
            {
                Name = "r1", TemplateId = "r1"
            }, TemplateType.Feature);
            userSelection.Add(new UserSelectionItem()
            {
                Name = "Feature1", TemplateId = "Microsoft.Templates.Test.RequirementsTemplate.CSharp"
            }, TemplateType.Feature);

            var genQueue = GenComposer.Compose(userSelection);

            AssertBasicParameters(genQueue);
        }
Exemple #2
0
 private void AddTemplate(TemplateInfoViewModel selectedTemplate)
 {
     if (selectedTemplate.MultipleInstance || !UserSelection.IsTemplateAdded(selectedTemplate))
     {
         UserSelection.Add(TemplateOrigin.UserSelection, selectedTemplate);
     }
 }
        public void Compose_BasicGeneration()
        {
            GenContext.Current = new TestContextProvider()
            {
                DestinationPath = string.Empty,
                ProjectName     = "TestProject",
            };

            var context = new UserSelectionContext(ProgrammingLanguages.CSharp, "test")
            {
                ProjectType       = "pt1",
                FrontEndFramework = "fx1",
            };

            var userSelection = new UserSelection(context)
            {
                HomeName = "TestHome",
            };

            userSelection.Add(new UserSelectionItem()
            {
                Name = "Main", TemplateId = "Microsoft.Templates.Test.PageTemplate.CSharp"
            }, TemplateType.Page);

            var genQueue = GenComposer.Compose(userSelection);

            AssertBasicParameters(genQueue, context);
        }
        public void Compose_GenerationWithPropertyBag()
        {
            GenContext.Current = new TestContextProvider()
            {
                DestinationPath = string.Empty,
                ProjectName     = "TestProject",
            };

            var context = new UserSelectionContext(ProgrammingLanguages.CSharp, "test")
            {
                ProjectType       = "pt1",
                FrontEndFramework = "fx4",
            };

            context.PropertyBag.Add("pb1", "value1");

            var userSelection = new UserSelection(context)
            {
                HomeName = "TestHome",
            };

            userSelection.Add(new UserSelectionItem()
            {
                Name = "MainPage", TemplateId = "Microsoft.Templates.Test.PageTemplatePropertyBag.CSharp"
            }, TemplateType.Page);

            var genQueue = GenComposer.Compose(userSelection);

            AssertBasicParameters(genQueue, context);

            var property = new KeyValuePair <string, string>("wts.generation.pb1", "value1");

            Assert.True(genQueue.Where(g => g.Name == "ProjectTemplatePropertyBag").All(g => g.Parameters.Contains(property)));
        }
        public void Compose_GenerationWithCasingParams()
        {
            GenContext.Current = new TestContextProvider()
            {
                DestinationPath = string.Empty,
                ProjectName     = "TestProject",
            };

            var userSelection = new UserSelection("pt1", "fx1", string.Empty, "test", ProgrammingLanguages.CSharp)
            {
                HomeName = "TestHome",
            };

            userSelection.Add(new UserSelectionItem()
            {
                Name = "MainPage", TemplateId = "Microsoft.Templates.Test.PageTemplate.CSharp"
            }, TemplateType.Page);

            var genQueue = GenComposer.Compose(userSelection);

            AssertBasicParameters(genQueue);

            var kebabCase  = new KeyValuePair <string, string>("wts.sourceName.casing.kebab", "main-page");
            var camelCase  = new KeyValuePair <string, string>("wts.sourceName.casing.camel", "mainPage");
            var pascalCase = new KeyValuePair <string, string>("wts.sourceName.casing.pascal", "MainPage");

            Assert.True(genQueue.Where(g => g.Name == "MainPage").All(g => g.Parameters.Contains(kebabCase)));
            Assert.True(genQueue.Where(g => g.Name == "MainPage").All(g => g.Parameters.Contains(camelCase)));
            Assert.True(genQueue.Where(g => g.Name == "MainPage").All(g => g.Parameters.Contains(pascalCase)));
        }
        public void Compose_GenerationWithExportParams()
        {
            GenContext.Current = new TestContextProvider()
            {
                DestinationPath = string.Empty,
                ProjectName     = "TestProject",
            };

            var userSelection = new UserSelection("pt1", "fx1", string.Empty, "test", ProgrammingLanguages.CSharp)
            {
                HomeName = "TestHome",
            };

            userSelection.Add(new UserSelectionItem()
            {
                Name = "Main", TemplateId = "Microsoft.Templates.Test.PageTemplate.CSharp"
            }, TemplateType.Page);

            var genQueue = GenComposer.Compose(userSelection);

            AssertBasicParameters(genQueue);

            var export = new KeyValuePair <string, string>("testKey", "testValue");

            Assert.True(genQueue.Where(g => g.Template.Name == "Microsoft.Templates.Test.PageTemplate.CSharp").All(g => g.Parameters.Contains(export)));
        }
        public void Compose_GenerationWithDependency()
        {
            GenContext.Current = new TestContextProvider()
            {
                DestinationPath = string.Empty,
                ProjectName     = "TestProject",
            };

            var context = new UserSelectionContext(ProgrammingLanguages.CSharp, "test")
            {
                ProjectType       = "pt1",
                FrontEndFramework = "fx1",
            };

            var userSelection = new UserSelection(context)
            {
                HomeName = "TestHome",
            };

            userSelection.Add(new UserSelectionItem()
            {
                Name = "Main", TemplateId = "Microsoft.Templates.Test.PageTemplate.CSharp"
            }, TemplateType.Page);
            userSelection.Add(new UserSelectionItem()
            {
                Name = "Feature1", TemplateId = "Microsoft.Templates.Test.DependenciesTemplate.CSharp"
            }, TemplateType.Feature);
            userSelection.Add(new UserSelectionItem()
            {
                Name = "d1", TemplateId = "dp1"
            }, TemplateType.Feature);
            userSelection.Add(new UserSelectionItem()
            {
                Name = "d2", TemplateId = "dp2"
            }, TemplateType.Feature);

            var genQueue = GenComposer.Compose(userSelection);

            AssertBasicParameters(genQueue, context);

            var dp1 = new KeyValuePair <string, string>("dp1", "d1");
            var dp2 = new KeyValuePair <string, string>("dp2", "d2");

            Assert.True(genQueue.Where(g => g.Name == "Feature1").All(g => g.Parameters.Contains(dp1)));
            Assert.True(genQueue.Where(g => g.Name == "Feature1").All(g => g.Parameters.Contains(dp2)));
        }
        private UserSelection GetUserSelection()
        {
            var userSelection = new UserSelection(ConfigProjectType, ConfigFramework, _emptyBackendFramework, ConfigPlatform, Language);
            var selectedItem  = new UserSelectionItem {
                Name = TemplateSelection.Name, TemplateId = TemplateSelection.Template.TemplateId
            };

            userSelection.Add(selectedItem, TemplateSelection.Template.TemplateType);
            return(userSelection);
        }
        private void OnFinish(object sender, EventArgs e)
        {
            var userSelection = new UserSelection(ConfigProjectType, ConfigFramework, _emptyBackendFramework, ConfigPlatform, Language);

            userSelection.Add(
                new UserSelectionItem()
            {
                Name       = TemplateSelection.Name,
                TemplateId = TemplateSelection.Template.TemplateId,
            }, TemplateType);
            WizardShell.Current.Result = userSelection;
            WizardShell.Current.Result.ItemGenerationType = ChangesSummary.DoNotMerge ? ItemGenerationType.Generate : ItemGenerationType.GenerateAndMerge;
        }
        private UserSelection CreateUserSelection()
        {
            var userSelection = new UserSelection(ConfigProjectType, ConfigFramework, _emptyBackendFramework, ConfigPlatform, Language)
            {
                HomeName = string.Empty
            };
            var selectedTemplate = new UserSelectionItem {
                Name = TemplateSelection.Name, TemplateId = TemplateSelection.Template.TemplateId
            };

            userSelection.Add(selectedTemplate, TemplateSelection.Template.TemplateType);

            foreach (var dependencyTemplate in TemplateSelection.Template.Dependencies)
            {
                var selectedTemplateDependency = new UserSelectionItem {
                    Name = dependencyTemplate.DefaultName, TemplateId = dependencyTemplate.TemplateId
                };
                userSelection.Add(selectedTemplateDependency, dependencyTemplate.TemplateType);
            }

            return(userSelection);
        }
Exemple #11
0
        private void OnFinish(object sender, EventArgs e)
        {
            var userSelection = new UserSelection(Context);

            userSelection.Add(
                new UserSelectionItem()
            {
                Name       = TemplateSelection.Name,
                TemplateId = TemplateSelection.Template.TemplateId,
            }, TemplateType);
            WizardShell.Current.Result = userSelection;
            WizardShell.Current.Result.ItemGenerationType = ChangesSummary.DoNotMerge ? ItemGenerationType.Generate : ItemGenerationType.GenerateAndMerge;
        }
Exemple #12
0
        private UserSelection CreateUserSelection()
        {
            var userSelection = new UserSelection(Context)
            {
                HomeName = string.Empty
            };
            var selectedTemplate = new UserSelectionItem {
                Name = TemplateSelection.Name, TemplateId = TemplateSelection.Template.TemplateId
            };

            userSelection.Add(selectedTemplate, TemplateSelection.Template.TemplateType);

            foreach (var dependencyTemplate in TemplateSelection.Template.Dependencies)
            {
                var selectedTemplateDependency = new UserSelectionItem {
                    Name = dependencyTemplate.DefaultName, TemplateId = dependencyTemplate.TemplateId
                };
                userSelection.Add(selectedTemplateDependency, dependencyTemplate.TemplateType);
            }

            return(userSelection);
        }
        public void AddItem(UserSelection userSelection, string itemName, TemplateInfo template)
        {
            var selectedTemplate = new UserSelectionItem {
                Name = itemName, TemplateId = template.TemplateId
            };

            userSelection.Add(selectedTemplate, template.TemplateType);

            foreach (var item in template.Dependencies)
            {
                if (!AlreadyAdded(userSelection, item))
                {
                    AddItem(userSelection, item.DefaultName, item);
                }
            }
        }
Exemple #14
0
        public void AddItem(UserSelection userSelection, string itemName, TemplateInfo template)
        {
            var selectedTemplate = new UserSelectionItem {
                Name = itemName, TemplateId = template.TemplateId
            };

            foreach (var item in template.Dependencies)
            {
                if (!AlreadyAdded(userSelection, item))
                {
                    AddItem(userSelection, item.DefaultName, item);
                }
            }

            if (template.Requirements.Count() > 0 && !userSelection.Items.Any(u => template.Requirements.Select(r => r.TemplateId).Contains(u.TemplateId)))
            {
                AddItem(userSelection, template.Requirements.FirstOrDefault().DefaultName, template.Requirements.FirstOrDefault());
            }

            userSelection.Add(selectedTemplate, template.TemplateType);
        }