Ejemplo n.º 1
0
        public void creating_a_new_psake_build(DirectoryInfo root, ITemplate template, ICraneContext context, ITemplateInvoker templateInvoker)
        {
            "Given I have a project root folder"
            ._(() =>
            {
                context         = ServiceLocator.Resolve <ICraneContext>();
                var fileManager = ServiceLocator.Resolve <IFileManager>();
                templateInvoker = ServiceLocator.Resolve <ITemplateInvoker>();
                context.ProjectRootDirectory = new DirectoryInfo(fileManager.GetTemporaryDirectory());
            });

            "And I have a psake template builder"
            ._(() => template = ServiceLocator.Resolve <ITemplateResolver>().Resolve(TemplateType.Build));

            "When I call create on the template with service stack as the project name and solution name"
            ._(() => templateInvoker.InvokeTemplate(template, new ProjectContext {
                ProjectName = "ServiceStack", SolutionPath = "../ServiceStack.sln"
            }));

            "It place a build.ps1 in the root project directory"
            ._(() => File.Exists(Path.Combine(context.ProjectRootDirectory.FullName, "build.ps1")).Should().BeTrue("build.ps1 should be in root directory"));

            "It should replace the solution file name in the build script with the project name"
            ._(() => File.ReadAllText(Path.Combine(context.BuildDirectory.FullName, "default.ps1")).Should().Contain("../ServiceStack.sln"))
            .Teardown(() => Directory.Delete(context.ProjectRootDirectory.FullName, recursive: true));
        }
Ejemplo n.º 2
0
        private void CreateProject(string projectName)
        {
            var projectContext = _projectContextFactory.Create(projectName, projectName);
            var visualStudio   = _templateResolver.Resolve(TemplateType.Source);

            _templateInvoker.InvokeTemplate(visualStudio, projectContext);
        }
Ejemplo n.º 3
0
        protected override void DoHandle(Assemble command)
        {
            var projectName    = command.FolderName;
            var solutionPath   = _solutionPathResolver.GetPathRelativeFromBuildFolder(command.FolderName);
            var projectContext = _projectContextFactory.Create(projectName, solutionPath);
            var buildTemplate  = _templateResolver.Resolve(TemplateType.Build);

            if (buildTemplate == null)
            {
                throw new Exception("Build template not found, please check your configuration");
            }

            _templateInvoker.InvokeTemplate(buildTemplate, projectContext);
        }
Ejemplo n.º 4
0
        public void creating_a_visual_studio_setup_using_the_template(DirectoryInfo root, ITemplate template, ICraneContext context, ITemplateInvoker templateInvoker)
        {
            "Given I have a project root folder"
            ._(() =>
            {
                context = ServiceLocator.Resolve <ICraneContext>(); var fileManager = ServiceLocator.Resolve <IFileManager>();
                context.ProjectRootDirectory = new DirectoryInfo(fileManager.GetTemporaryDirectory());
                templateInvoker = ServiceLocator.Resolve <ITemplateInvoker>();
            });

            "And I have a psake template builder"
            ._(() => template = ServiceLocator.Resolve <TemplateResolver>().Resolve(TemplateType.Source));

            "When I call create on the template with ServiceStack as the project name and solution name"
            ._(() => templateInvoker.InvokeTemplate(template, new ProjectContext {
                ProjectName = "ServiceStack", SolutionPath = "ServiceStack"
            }));

            "It should rename the class library folder name with the current project name"
            ._(() => Directory.Exists(Path.Combine(context.SourceDirectory.FullName, "ServiceStack")).Should().BeTrue());

            "It should rename the test class library folder name with the current project name"
            ._(() => Directory.Exists(Path.Combine(context.SourceDirectory.FullName, "ServiceStack.UnitTests")).Should().BeTrue());

            "It should rename the solution file with the current project name"
            ._(() => File.Exists(Path.Combine(context.SourceDirectory.FullName, "ServiceStack.sln")).Should().BeTrue());

            "It should replace the tokens in the solution file"
            ._(() => File.ReadAllText(Path.Combine(context.SourceDirectory.FullName, "ServiceStack.sln"))
               .Should().NotContain("%GUID-1%").And.NotContain("%GUID-2%"));

            "It should replace the tokens in the project file"
            ._(() => File.ReadAllText(Path.Combine(context.SourceDirectory.FullName, "ServiceStack", string.Format("{0}.csproj", "ServiceStack")))
               .Should().NotContain("%GUID-1%"));

            "It should replace the tokens in the project unit test file"
            ._(() => File.ReadAllText(Path.Combine(context.SourceDirectory.FullName, string.Format("{0}.UnitTests", "ServiceStack"), string.Format("{0}.UnitTests.csproj", "ServiceStack")))
               .Should().NotContain("%GUID-1%"));

            "It should rename the nuGet specification file with the current project name"
            ._(() => File.Exists(Path.Combine(context.SourceDirectory.FullName, "ServiceStack", string.Format("{0}.nuspec", "ServiceStack"))).Should().BeTrue());

            "It should replace the tokens in the nuGet specification file"
            ._(() => File.ReadAllText(Path.Combine(context.SourceDirectory.FullName, "ServiceStack", string.Format("{0}.nuspec", "ServiceStack")))
               .Should().NotContain("%username%")
               .And.NotContain("%context.ProjectName%")
               .And.NotContain("%DateTime.Now.Year%"));

            "It should create a .gitignore file in the project root"
            ._(() =>
               File.Exists(Path.Combine(context.ProjectRootDirectory.FullName, ".gitignore"))
               .Should().Be(true)
               );

            "It should create a .gitattributes file in the project root"
            ._(() =>
               File.Exists(Path.Combine(context.ProjectRootDirectory.FullName, ".gitattributes"))
               .Should().Be(true)
               )
            .Teardown(() => Directory.Delete(context.ProjectRootDirectory.FullName, recursive: true));
        }