Example #1
0
        public void generate_a_simple_template()
        {
            // SAMPLE: generating-with-templates
            var library = new TemplateLibrary("path to your templates");
            var builder = new TemplatePlanBuilder(library);
            var request = buildTemplateRequest();

            // Build a TemplatePlan
            var plan = builder.BuildPlan(request);
            plan.Execute();
            // ENDSAMPLE
        }
Example #2
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 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");
        }
        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());
        }
        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);
        }