public void sets_the_dot_net_version_if_it_exists() { var template = new ProjectTemplate { DotNetVersion = DotNetVersion.V45, Template = "SomeTemplate" }; template.BuildProjectRequest(new TemplateChoices { ProjectName = "SomeLib", }) .Version.ShouldEqual(DotNetVersion.V45); new ProjectTemplate { DotNetVersion = DotNetVersion.V40, Template = "SomeTemplate" }.BuildProjectRequest(new TemplateChoices { ProjectName = "Foo" }) .Version.ShouldEqual(DotNetVersion.V40); }
public static ProjectTemplate BuildProjectTemplate(this XmlElement element) { var projectTemplate = new ProjectTemplate { Name = element.GetAttribute("name"), Description = element.GetAttribute("description"), Template = element.GetAttribute("template"), DotNetVersion = element.GetAttribute("dotnet") }; if (element.HasAttribute("alterations")) { projectTemplate.Alterations.AddRange(element.GetAttribute("alterations").ToDelimitedArray()); } projectTemplate.Url = element.GetAttribute("url"); projectTemplate.Options = element.ReadOptions(); projectTemplate.Selections.AddRange(element.BuildSelections()); return projectTemplate; }
public void build_request_with_default_value_for_a_selection() { var graph = new TemplateGraph(); var projectTemplate = new ProjectTemplate { Name = "Foo", Template = "FooProj", Alterations = new List<string> {"Foo1", "Foo2"}, DotNetVersion = DotNetVersion.V45 }; graph.AddCategory("new").Templates.Add(projectTemplate); projectTemplate.Selections.Add(new OptionSelection { Name = "FooSelection", Options = new List<Option> { new Option { Name = "FooOpt1", Alterations = new List<string> {"C", "D"} }, new Option { Name = "FooOpt2", Alterations = new List<string> {"E", "F"} } } }); var choices = new TemplateChoices {Category = "new", ProjectType = "Foo", ProjectName = "MyFoo"}; ProjectRequest request = graph.BuildProjectRequest(choices); request.Version.ShouldEqual(DotNetVersion.V45); request.Alterations.ShouldHaveTheSameElementsAs("Foo1", "Foo2", "C", "D"); }
public void build_request_with_named_value_for_a_selection() { var graph = new TemplateGraph(); var templateSet = new ProjectTemplate { Name = "Foo", Template = "FooProj", Alterations = new List<string> { "Foo1", "Foo2" } }; graph.AddCategory("new").Templates.Add(templateSet); templateSet.Selections.Add(new OptionSelection { Name = "FooSelection", Options = new List<Option> { new Option { Name = "FooOpt1", Alterations = new List<string> {"C", "D"} }, new Option { Name = "FooOpt2", Alterations = new List<string> {"E", "F"} } } }); var choices = new TemplateChoices { Category = "new", ProjectType = "Foo", ProjectName = "MyFoo" }; choices.Selections["FooSelection"] = "fooopt2"; ProjectRequest request = graph.BuildProjectRequest(choices); request.Alterations.ShouldHaveTheSameElementsAs("Foo1", "Foo2", "E", "F"); }
public void build_request_with_options() { var graph = new TemplateGraph(); var templateSet = new ProjectTemplate { Name = "Foo", Template = "FooProj", Alterations = new List<string> {"Foo1", "Foo2"} }; graph.AddCategory("new").Templates.Add(templateSet); templateSet.Options.Add(new Option { Name = "FooOpt1", Alterations = new List<string> {"C", "D"} }); templateSet.Options.Add(new Option { Name = "FooOpt2", Alterations = new List<string> {"E", "F"} }); templateSet.Options.Add(new Option { Name = "FooOpt3", Alterations = new List<string> {"G", "H"} }); var choices = new TemplateChoices { Category = "new", ProjectType = "Foo", ProjectName = "MyFoo", Options = new[] {"FooOpt1", "FooOpt3"} }; ProjectRequest request = graph.BuildProjectRequest(choices); request.Alterations.ShouldHaveTheSameElementsAs("Foo1", "Foo2", "C", "D", "G", "H"); }