Esempio n. 1
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();
            });
        }
Esempio n. 2
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();
            });
        }
Esempio n. 3
0
        public void invoking_command_packages_nuget_spec_file_correctly(
            CraneRunner craneRunner,
            RunResult buildResult,
            RunResult commandResult,
            CraneTestContext craneTestContext,
            NuGetServerContext nuGetServer,
            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 a crane api"
            ._(() => craneApi = ServiceLocator.Resolve <ICraneApi>());

            "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)));

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

            "And I have packed the nuget spec files"
            ._(() =>
               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").Should().BeErrorFree());

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

            "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(() =>
            {
                nuGetServer.TearDown();
                craneTestContext.TearDown();
            });
        }