示例#1
0
        public void build_a_new_default_crane_project_sucessfully(CraneRunner craneRunner, RunResult result, CraneTestContext craneTestContext)
        {
            "Given I have my own private copy of the crane console"
            ._(() => craneTestContext = ServiceLocator.Resolve <CraneTestContext>());

            "And I have a crane run context"
            ._(() => craneRunner = new CraneRunner());

            "And I have a new crane project 'SallyFx'"
            ._(() => craneRunner.Command(craneTestContext.BuildOutputDirectory, "crane init SallyFx").ErrorOutput.Should().BeEmpty());

            "When I build the project"
            ._(() =>
            {
                result = new BuildScriptRunner().Run(Path.Combine(craneTestContext.BuildOutputDirectory, "SallyFx"));
                result.ErrorOutput.Should().BeEmpty();
            });

            "It should have build the main 'SallyFx' class library"
            ._(() => File.Exists(Path.Combine(craneTestContext.BuildOutputDirectory, "SallyFx", "build-output", "SallyFx.dll")));

            "It should have build the 'SallyFx' unit test library"
            ._(() => File.Exists(Path.Combine(craneTestContext.BuildOutputDirectory, "SallyFx", "build-output", "SallyFx.UnitTests.dll")));

            "It should have a default assembly version 0.0.0.0 which is done via assembly info patching"
            ._(() => FileVersionInfo.GetVersionInfo(Path.Combine(craneTestContext.BuildOutputDirectory, "SallyFx", "build-output", "SallyFx.dll"))
               .FileVersion.Should().Be("0.0.0.0"));

            "It should build successfully"
            ._(() => result.Should().BeBuiltSuccessfulyWithAllTestsPassing().And.BeErrorFree());

            "It should not throw an error"
            ._(() => result.ErrorOutput.Should().BeEmpty())
            .Teardown(() => craneTestContext.TearDown());
        }
示例#2
0
        public void Assemble_with_a_folder_name_creates_a_build_when_solution_is_a_different_name_and_in_different_location(
            CraneRunner craneRunner,
            RunResult result,
            CraneTestContext craneTestContext,
            SolutionBuilderContext solutionBuilderContext)
        {
            "Given I have my own private copy of the crane console"
            ._(() => craneTestContext = ServiceLocator.Resolve <CraneTestContext>());

            "And I have a run context"
            ._(() => craneRunner = new CraneRunner());

            "And I have a project called SolutionInDirectoryProject with no build"
            ._(() =>
            {
                solutionBuilderContext = ServiceLocator.Resolve <SolutionBuilderContext>();
                solutionBuilderContext
                .CreateBuilder()
                .WithSolution(solution => solution.Path = Path.Combine(craneTestContext.BuildOutputDirectory, "SolutionInDirectoryProject", "src", "solutions", "MySolution.sln"))
                .WithFile(file => file.AddSolutionPackagesConfigWithXUnitRunner(Path.Combine(craneTestContext.BuildOutputDirectory, "SolutionInDirectoryProject", "src", "solutions", ".nuGet", "packages.config")))
                .WithProject(project =>
                {
                    project.Name = "ServiceStack";
                    project.Path = Path.Combine(craneTestContext.BuildOutputDirectory, "SolutionInDirectoryProject", "src", "ServiceStack", "ServiceStack.csproj");
                })
                .Build();
            });

            "When I run crane assemble SolutionInDirectoryProject"
            ._(() => result = craneRunner.Command(craneTestContext.BuildOutputDirectory, "crane Assemble SolutionInDirectoryProject"));

            "It should say 'Assemble success.'"
            ._(() =>
            {
                result.ErrorOutput.Should().BeEmpty();
                result.StandardOutput.Should().Be("Assemble success.");
            });

            "It should create a build.ps1 in the top level folder"
            ._(
                () => new DirectoryInfo(Path.Combine(craneTestContext.BuildOutputDirectory, "SolutionInDirectoryProject")).GetFiles()
                .Count(f => f.Name.ToLower() == "build.ps1")
                .Should()
                .Be(1)
                );

            "It should be able to be built successfully with all tests passing"
            ._(() =>
            {
                var buildResult = new BuildScriptRunner().Run(Path.Combine(craneTestContext.BuildOutputDirectory, "SolutionInDirectoryProject"));
                buildResult.Should().BeBuiltSuccessfulyWithAllTestsPassing().And.BeErrorFree();
            });


            "It should create a build for the project with a reference to the solution file"
            ._(() => File.ReadAllText(Path.Combine(craneTestContext.BuildOutputDirectory, "SolutionInDirectoryProject", "build", "default.ps1")).Should().Contain("MySolution.sln"))
            .Teardown(() => craneTestContext.TearDown());
        }
示例#3
0
        public void can_publish_build_to_nuget(CraneRunner craneRunner, RunResult result, CraneTestContext craneTestContext,
                                               ISolutionContext solutionContext, string projectDir, ICraneApi craneApi, NuGetServerContext nuGetServer)
        {
            "Given I have my own private copy of the crane console"
            ._(() => craneTestContext = ServiceLocator.Resolve <CraneTestContext>());

            "And I have a nuGet server running"
            ._(() =>
            {
                nuGetServer = new NuGetServerContext(craneTestContext);
                nuGetServer.PackageCount.Should().BeGreaterThan(-1);
            });

            "And I have a run context"
            ._(() => craneRunner = new CraneRunner());

            "And I have run crane init ServiceStack"
            ._(() => result = craneRunner.Command(craneTestContext.BuildOutputDirectory, "crane init ServiceStack"));

            "And I have build the project"
            ._(() =>
            {
                result = new BuildScriptRunner().Run(Path.Combine(craneTestContext.BuildOutputDirectory, "ServiceStack"));
                result.Should().BeBuiltSuccessfulyWithAllTestsPassing().And.BeErrorFree();;
            });

            "And I have the solution context using the api"
            ._(() =>
            {
                projectDir      = Path.Combine(craneTestContext.BuildOutputDirectory, "ServiceStack");
                craneApi        = ServiceLocator.Resolve <ICraneApi>();
                solutionContext = craneApi.GetSolutionContext(projectDir);
            });

            "And I have packaged the nuget spec"
            ._(() =>
            {
                var buildOutputPath = Path.Combine(solutionContext.Path, "build-output");
                craneApi.NugetPack(solutionContext, buildOutputPath, Path.Combine(buildOutputPath, "nuGet"), "0.0.0.0").First().Should().BeErrorFree();
            });

            "When I publish to nuGet using the api"
            ._(
                () =>
                craneApi.NugetPublish(solutionContext,
                                      Path.Combine(solutionContext.Path, "build-output", "nuGet"), "0.0.0.0",
                                      nuGetServer.Source.ToString(), nuGetServer.ApiKey).First().Should().BeErrorFree());

            "It should push the package to the nuGet server"
            ._(() => nuGetServer.PackageExists("ServiceStack", "0.0.0.0").Should().BeTrue())
            .Teardown(() =>
            {
                nuGetServer.TearDown();
                craneTestContext.TearDown();
            });
        }
示例#4
0
        public void can_create_a_nuget_package(
            CraneRunner craneRunner,
            RunResult result,
            CraneTestContext craneTestContext,
            ISolutionContext solutionContext,
            string projectDir,
            ICraneApi craneApi,
            string buildOutputFolder,
            string nugetOutputFolder,
            IEnumerable <RunResult> runResults)
        {
            "Given I have my own private copy of the crane console"
            ._(() => craneTestContext = ServiceLocator.Resolve <CraneTestContext>());

            "And I have a run context"
            ._(() => craneRunner = new CraneRunner());

            "And I have run crane init ServiceStack"
            ._(() => result = craneRunner.Command(craneTestContext.BuildOutputDirectory, "crane init ServiceStack"));

            "And I have build the project"
            ._(() =>
            {
                result = new BuildScriptRunner().Run(Path.Combine(craneTestContext.BuildOutputDirectory, "ServiceStack"));
                result.Should().BeBuiltSuccessfulyWithAllTestsPassing().And.BeErrorFree();;
            });

            "And I have the solution context using the api"
            ._(() =>
            {
                projectDir        = Path.Combine(craneTestContext.BuildOutputDirectory, "ServiceStack");
                craneApi          = ServiceLocator.Resolve <ICraneApi>();
                solutionContext   = craneApi.GetSolutionContext(projectDir);
                buildOutputFolder = Path.Combine(solutionContext.Path, "build-output");
            });

            "When I create nuGet packages using the api"
            ._(
                () =>
            {
                nugetOutputFolder = Path.Combine(buildOutputFolder, "nuGet");
                runResults        = craneApi.NugetPack(solutionContext, buildOutputFolder, nugetOutputFolder, "0.0.0.0");
                runResults.ForEach(item => _log.Debug(result));
            });

            "It should create nuGet packages for all the projects in the built solution"
            ._(() => File.Exists(Path.Combine(nugetOutputFolder, "ServiceStack.0.0.0.0.nupkg")).Should().BeTrue("could not find nuget file {0}, it should have been created.", Path.Combine(nugetOutputFolder, "ServiceStack.0.0.0.0.nupkg")))
            .Teardown(() => craneTestContext.TearDown());
        }
        public void invoking_command_packages_nuget_spec_file_correctly(
            CraneRunner craneRunner,
            RunResult buildResult,
            RunResult commandResult,
            CraneTestContext craneTestContext,
            string projectDir,
            ICraneApi craneApi,
            PowerShellApiRunner apiRunner)
        {
            "Given I have my own private copy of the crane console"
            ._(() => craneTestContext = ServiceLocator.Resolve <CraneTestContext>());

            "And I have a run context"
            ._(() => craneRunner = new CraneRunner());

            "And I have run crane init ServiceStack"
            ._(() => buildResult = craneRunner.Command(craneTestContext.BuildOutputDirectory, "crane init ServiceStack"));

            "And I have build the project"
            ._(() =>
            {
                buildResult = new BuildScriptRunner().Run(Path.Combine(craneTestContext.BuildOutputDirectory, "ServiceStack"));
                buildResult.Should().BeBuiltSuccessfulyWithAllTestsPassing().And.BeErrorFree();
                projectDir = Path.Combine(craneTestContext.BuildOutputDirectory, "ServiceStack");
            });

            "And I have my powershell api runner"
            ._(() => apiRunner = new PowerShellApiRunner(craneTestContext, TimeSpan.FromSeconds(15)));

            "When I call invoke all nuget pack"
            ._(() => commandResult =
                   apiRunner.Run(
                       @"$context = Get-CraneSolutionContext -Path '{0}'; " +
                       "Invoke-CraneNugetPackAllProjects -SolutionContext $context -BuildOutputPath '{1}' -NugetOutputPath '{2}' -Version {3}" +
                       "| % {{ $_.StandardOutput }}",
                       projectDir, Path.Combine(projectDir, "build-output"), Path.Combine(projectDir, "build-output", "nuGet"), "0.0.0.0"));

            "Then there should be no error"
            ._(() => commandResult.Should().BeErrorFree());

            "And the nuget package should have been created"
            ._(() =>
               File.Exists(Path.Combine(projectDir, "build-output", "nuGet",
                                        "ServiceStack.0.0.0.0.nupkg")).Should().BeTrue())

            .Teardown(() => craneTestContext.TearDown());
        }
示例#6
0
        public void building_a_default_crane_project_that_is_also_a_git_repo(CraneRunner craneRunner, RunResult result,
                                                                             CraneTestContext craneTestContext, Git git)
        {
            string projectDir = null;

            "Given I have my own private copy of the crane console"
            ._(() => craneTestContext = ServiceLocator.Resolve <CraneTestContext>());

            "And I have a crane run context"
            ._(() => craneRunner = new CraneRunner());

            "And I have a new crane project 'SallyFx'"
            ._(() => craneRunner.Command(craneTestContext.BuildOutputDirectory, "crane init SallyFx").ErrorOutput.Should().BeEmpty());

            "And I initialize that as a git repository"
            ._(() =>
            {
                projectDir = Path.Combine(craneTestContext.BuildOutputDirectory, "SallyFx");
                git        = ServiceLocator.Resolve <Git>();
                git.Run("init", projectDir).ErrorOutput.Should().BeEmpty();
                git.Run("config user.email [email protected]", projectDir).ErrorOutput.Should().BeEmpty();
            });

            "And I have a previous commit"
            ._(() =>
            {
                git.Run("add -A", projectDir).ErrorOutput.Should().BeEmpty();
                git.Run("config user.email [email protected]", projectDir).ErrorOutput.Should().BeEmpty();
                git.Run("commit -m \"First commit of SallyFx\"", projectDir).ErrorOutput.Should().BeEmpty();
            });

            "When I build the project"
            ._(() =>
            {
                result = new BuildScriptRunner().Run(Path.Combine(craneTestContext.BuildOutputDirectory, "SallyFx"));
                result.ErrorOutput.Should().BeEmpty();
            });

            "It should have the commit message as part of the additional file information"
            ._(() =>
            {
                var fileVersionInfo = FileVersionInfo.GetVersionInfo(Path.Combine(craneTestContext.BuildOutputDirectory, "SallyFx", "build-output", "SallyFx.dll"));
                fileVersionInfo.ProductVersion.Should().Contain("First commit of SallyFx");
            })
            .Teardown(() => craneTestContext.TearDown());
        }
示例#7
0
        public void build_a_project_and_publish_to_nuget(
            NuGetServerContext nuGetServer,
            ICraneTestContext craneTestContext,
            CraneRunner craneRunner,
            RunResult result)
        {
            // .\src\packages\xunit.runners.1.9.2\tools\xunit.console.clr4.exe .\build-output\Crane.Integration.Tests.dll /trait "Debug=nuGet"
            "Given I have my own private copy of the crane console"
            ._(() => craneTestContext = ServiceLocator.Resolve <CraneTestContext>());

            "And I have a run context"
            ._(() => craneRunner = new CraneRunner());

            "And I have a nuGet server running"
            ._(() =>
            {
                nuGetServer = new NuGetServerContext(craneTestContext);
                nuGetServer.PackageCount.Should().BeGreaterThan(-1);
            });

            "And I have a project with a nuGet spec file (which is the default behaviour of crane init)"
            ._(() => craneRunner.Command(craneTestContext.BuildOutputDirectory, "crane init SallyFx").ErrorOutput.Should().BeEmpty());

            "When I build the project supplying the nuGet details"
            ._(() =>
            {
                result = new BuildScriptRunner().Run(Path.Combine(craneTestContext.BuildOutputDirectory, "SallyFx"),
                                                     "@('BuildSolution', 'NugetPublish')",
                                                     "-nuget_api_key", nuGetServer.ApiKey,
                                                     "-nuget_api_url", nuGetServer.Source.ToString());
                result.Should().BeBuiltSuccessfulyWithAllTestsPassing().And.BeErrorFree();
            });

            "It should push the package to the nuGet server"
            ._(() => nuGetServer.PackageExists("SallyFx", "0.0.0.0").Should().BeTrue())
            .Teardown(() =>
            {
                nuGetServer.TearDown();
                craneTestContext.TearDown();
            });
        }