private void applyTestingTemplates(TemplateRequest request, TemplatePlan plan)
 {
     request.TestingProjects.Each(proj => {
         buildProjectPlan(plan, proj);
         plan.Add(new CopyProjectReferences(proj.OriginalProject));
     });
 }
Exemple #2
0
        // SAMPLE: building-template-request
        private static TemplateRequest buildTemplateRequest()
        {
            var request = new TemplateRequest
            {
                RootDirectory = "root directory",
                SolutionName = "MySolution.sln"
            };

            // Add a project named "MyProject" using a project template named "basic-new-project"
            request.AddProjectRequest("MyProject", "basic-new-project", project => {
                // Add some extra templates from the /alterations folder
                project.Alterations.Add("raven");
                project.Alterations.Add("spark");

                // Add some substitution values for the templating if desired
                // See the topic page for subsitutions and inputs
                project.Substitutions.Set("%SHORT_NAME%", "MyProj");
            });

            // Add a testing project related to our first project using the "unit-testing" project template
            // See the topic about testing projects
            request.AddTestingRequest(new ProjectRequest("MyProject.Testing", "unit-testing", "MyProject"));

            return request;
        }
        public void validate_missing_solution_template()
        {
            var request = new TemplateRequest();
            request.AddTemplate("NonExistent");

            var missing = request.Validate(theTemplates).Single();
            missing.Name.ShouldEqual("NonExistent");
            missing.TemplateType.ShouldEqual(TemplateType.Solution);
            missing.ValidChoices.ShouldHaveTheSameElementsAs("Complex", "Simple");
        }
        public void validate_missing_project_template()
        {
            var request = new TemplateRequest();
            request.AddTemplate("Simple");
            request.AddProjectRequest(new ProjectRequest("foo", "NonExistent"));

            var missing = request.Validate(theTemplates).Single();
            missing.Name.ShouldEqual("NonExistent");
            missing.TemplateType.ShouldEqual(TemplateType.Project);
            missing.ValidChoices.ShouldHaveTheSameElementsAs("MvcApp", "MvcBottle");
        }
Exemple #5
0
        public static TemplatePlan BuildPlan(TemplateRequest request)
        {
            var planner = new TemplatePlanBuilder(_templates.Value);

            var plan = planner.BuildPlan(request);
            if (plan.Steps.OfType<GemReference>().Any())
            {
                plan.Add(new BundlerStep());
            }

            return plan;
        }
        public void validate_missing_alteration_template()
        {
            var request = new TemplateRequest();
            request.AddTemplate("Simple");
            request.AddProjectRequest(new ProjectRequest("foo", "MvcApp" ));
            request.Projects.Last().Alterations.Add("NonExistent");

            var missing = request.Validate(theTemplates).Single();
            missing.Name.ShouldEqual("NonExistent");
            missing.TemplateType.ShouldEqual(TemplateType.Alteration);
            missing.ValidChoices.ShouldHaveTheSameElementsAs("Assets", "HtmlConventions");
        }
        public void build_with_missing_solution()
        {
            var request = new TemplateRequest
            {
                SolutionName = "MySolution",
                RootDirectory = "root"
            };

            var plan = new TemplatePlanBuilder(new TemplateLibrary("."))
                .BuildPlan(request);

            var create =plan.Steps.First().ShouldBeOfType<CreateSolution>();
            create.SolutionName.ShouldEqual("MySolution");
        }
Exemple #8
0
        public void should_add_a_bundler_step_if_there_are_any_gem_references()
        {
            var request = new TemplateRequest
            {
                SolutionName = "Foo",
                RootDirectory = "Foo"
            };

            request.AddTemplate("baseline");

            Templating.BuildPlan(request)
                      .Steps.OfType<BundlerStep>()
                      .Count().ShouldEqual(1);
        }
        // TODO -- do a bulk validation of TemplateRequest against the library
        public TemplatePlan BuildPlan(TemplateRequest request)
        {
            var plan = new TemplatePlan(request.RootDirectory);
            if (request.SolutionName.IsNotEmpty())
            {
                determineSolutionFileHandling(request, plan);
            }

            applySolutionTemplates(request, plan);
            request.Substitutions.CopyTo(plan.Substitutions);

            applyProjectTemplates(request, plan);
            applyTestingTemplates(request, plan);

            return plan;
        }
        public void respects_version_number_for_VS()
        {
            var request = new TemplateRequest
            {
                SolutionName = "MySolution",
                RootDirectory = "root",
                Version = Solution.VS2010
            };

            var plan = new TemplatePlanBuilder(new TemplateLibrary("."))
                .BuildPlan(request);

            var create = plan.Steps.First().ShouldBeOfType<CreateSolution>();
            create.SolutionName.ShouldEqual("MySolution");
            create.Version.ShouldEqual(request.Version);
        }
        public void copies_substitution_values_from_request_to_solution()
        {
            var request = new TemplateRequest
            {
                SolutionName = "MySolution",
                RootDirectory = "root"
            };

            request.Substitutions.Set("Key", "12345");
            request.Substitutions.Set("Password", "45678");

            var plan = new TemplatePlanBuilder(new TemplateLibrary("."))
                .BuildPlan(request);

            plan.Substitutions.ValueFor("Key").ShouldEqual("12345");
            plan.Substitutions.ValueFor("Password").ShouldEqual("45678");
        }
        public void build_with_existing_solution_should_just_read_the_current_one()
        {
            var original = Solution.CreateNew("root".AppendPath("src"), "MySolution");
            original.Save();

            var request = new TemplateRequest
            {
                SolutionName = "MySolution",
                RootDirectory = "root"
            };

            var plan = new TemplatePlanBuilder(new TemplateLibrary("."))
                .BuildPlan(request);

            var readSolution = plan.Steps.First().ShouldBeOfType<ReadSolution>();
            readSolution.SolutionFile.ToFullPath()
                        .ShouldEqual(original.Filename.ToFullPath());
        }
        private static void determineSolutionFileHandling(TemplateRequest request, TemplatePlan plan)
        {
            var sourceDirectory = plan.SourceDirectory;
            var expectedFile = sourceDirectory.AppendPath(request.SolutionName);
            if (Path.GetExtension(expectedFile) != ".sln")
            {
                expectedFile += ".sln";
            }

            if (File.Exists(expectedFile))
            {
                plan.Add(new ReadSolution(expectedFile));
            }
            else
            {
                plan.Add(new CreateSolution(request.SolutionName)
                {
                    Version = request.Version
                });
            }
        }
        public void SetUp()
        {
            library =
                new TemplateLibrary(
                    ".".ToFullPath().ParentDirectory().ParentDirectory().ParentDirectory().AppendPath("templates"));

            theRequest = new TemplateRequest
            {
                RootDirectory = "integrated",
                SolutionName = "MySolution"
            };

            new FileSystem().DeleteDirectory("integrated");
        }
 private void applyProjectTemplates(TemplateRequest request, TemplatePlan plan)
 {
     request.Projects.Each(proj => buildProjectPlan(plan, proj));
 }
        public void validate_when_everything_matches()
        {
            var request = new TemplateRequest();
            request.AddTemplate("Simple");

            request.Validate(theTemplates).Any().ShouldBeFalse();

            request.AddProjectRequest(new ProjectRequest("foo", "MvcApp"));

            request.Validate(theTemplates).Any().ShouldBeFalse();

            request.Projects.Single().Alterations.Add("Assets");

            request.AddTestingRequest(new ProjectRequest("foo", "MvcApp", "original"));

            request.Validate(theTemplates).Any().ShouldBeFalse();
        }
 private void applySolutionTemplates(TemplateRequest request, TemplatePlan plan)
 {
     var planner = new SolutionPlanner();
     _library.Find(TemplateType.Solution, request.Templates)
         .Each(template => planner.CreatePlan(template, plan));
 }