public void Api_can_tell_which_projects_in_a_solution_are_test_projects(CraneRunner craneRunner, RunResult result, CraneTestContext craneTestContext,
                                                                                ISolutionContext solutionContext)
        {
            "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"));

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

            "It should determine that the ServiceStack project is not a test project"
            ._(() => solutionContext.Solution.Projects.First(p => p.Name == "ServiceStack").TestProject.Should().BeFalse());

            "It should determine that the ServiceStack.UnitTests is a test project"
            ._(() => solutionContext.Solution.Projects.First(p => p.Name == "ServiceStack.UnitTests").TestProject.Should().BeTrue());

            "It should have only the ServiceStack project in the code projects collection"
            ._(() =>
            {
                solutionContext.Solution.CodeProjects.Count().Should().Be(1);
                solutionContext.Solution.CodeProjects.First().Name.Should().Be("ServiceStack");
            }).Teardown(() => craneTestContext.TearDown());
        }
        public void Api_returns_null_when_source_control_is_not_being_used(CraneRunner craneRunner, RunResult result, CraneTestContext craneTestContext,
                                                                           ISolutionContext solutionContext, ISourceControlInformation sourceControlInformation,
                                                                           ICraneApi craneApi)
        {
            "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 the solution context using the api"
            ._(() =>
            {
                craneApi        = ServiceLocator.Resolve <ICraneApi>();
                solutionContext = craneApi.GetSolutionContext(Path.Combine(craneTestContext.BuildOutputDirectory, "ServiceStack"));
            });

            "When I get the source information using the api"
            ._(() => sourceControlInformation = craneApi.GetSourceControlInformation(solutionContext));

            "It should return null as the source control information"
            ._(() => sourceControlInformation.Should().BeNull())
            .Teardown(() => craneTestContext.TearDown());
        }
        public void can_get_crane_context(CraneTestContext craneTestContext, PowerShellApiRunner apiRunner, RunResult commandResult, CraneRunner craneRunner)
        {
            "Given I have my own private copy of the crane console"
            ._(() => craneTestContext = ServiceLocator.Resolve <CraneTestContext>());

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

            "And I have initialized a project called ServiceStack"
            ._(() =>
            {
                craneRunner = new CraneRunner();
                craneRunner.Command(craneTestContext.BuildOutputDirectory, "crane init ServiceStack");
            });

            "When I get the context using powershell"
            ._(() => commandResult = apiRunner.Run("Get-CraneSolutionContext -Path \'{0}\' | FL", Path.Combine(craneTestContext.BuildOutputDirectory, "ServiceStack")));

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

            "It should write the solution context to the powershell pipeline"
            ._(() => commandResult.StandardOutput.Should()
               .Contain(Path.Combine(craneTestContext.BuildOutputDirectory, "ServiceStack")))
            .Teardown(() => craneTestContext.TearDown());
        }
Ejemplo n.º 4
0
        public void should_update_all_code_assembly_infos(CraneTestContext craneTestContext, PowerShellApiRunner apiRunner, RunResult commandResult,
                                                          ICraneApi craneApi, string projectDir)
        {
            "Given I have my own private copy of the crane console"
            ._(() => craneTestContext = ServiceLocator.Resolve <CraneTestContext>());

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

            "And I have a crane api"
            ._(() => craneApi = ServiceLocator.Resolve <ICraneApi>());

            "And I have initialized a project called ServiceStack"
            ._(() =>
            {
                var craneRunner = new CraneRunner();
                craneRunner.Command(craneTestContext.BuildOutputDirectory, "crane init ServiceStack");
                projectDir = Path.Combine(craneTestContext.BuildOutputDirectory, "ServiceStack");
            });

            "When I update the solution assembly infos"
            ._(() => commandResult = apiRunner.Run(@"$context = Get-CraneSolutionContext -Path '{0}'; Update-CraneAllProjectsAssemblyInfos -SolutionContext $context -Version '4.5.6.7'", projectDir));

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

            "And the assembly info file should be patched for each code project"
            ._(() =>
               craneApi.GetSolutionContext(projectDir).Solution.Projects.Where(p => !p.TestProject)
               .All(p => p.AssemblyInfo.Version.ToString() == "4.5.6.7")
               .Should()
               .BeTrue()
               ).Teardown(() => craneTestContext.TearDown());
        }
Ejemplo n.º 5
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());
        }
        public void Api_can_tell_which_projects_have_nuget_specifications(CraneRunner craneRunner, RunResult result, CraneTestContext craneTestContext,
                                                                          ISolutionContext solutionContext)
        {
            "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"));

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

            "It should determine that the ServiceStack project has a nuGet specification"
            ._(() => solutionContext.Solution.Projects.First(p => p.Name == "ServiceStack").NugetSpec.Should().NotBeNull());

            "It should determine the path of the nuGet specification file"
            ._(() => File.Exists(solutionContext.Solution.Projects.First(p => p.Name == "ServiceStack").NugetSpec.Path).Should().BeTrue());

            "It should determine that the ServiceStack.UnitTests project does not have nuGet specification"
            ._(() => solutionContext.Solution.Projects.First(p => p.Name == "ServiceStack.UnitTests").NugetSpec.Should().BeNull());
        }
Ejemplo n.º 7
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());
        }
Ejemplo n.º 8
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();
            });
        }
Ejemplo n.º 9
0
        public void generate_markdown_dynamic_documentation_for_crane_commands(CraneRunner craneRunner, RunResult result, CraneTestContext craneTestContext, string docDirectory, string rootDirectory, IEnumerable <ICraneCommand> userCommands)
        {
            "Given I have my own private copy of the crane console"
            ._(() =>
            {
                craneTestContext = ServiceLocator.Resolve <CraneTestContext>();
                rootDirectory    = craneTestContext.RootDirectory;
                docDirectory     = Path.Combine(rootDirectory, "doc");
                userCommands     = ServiceLocator.Resolve <IPublicCommandResolver>().Resolve();
                if (Directory.Exists(docDirectory))
                {
                    Directory.Delete(docDirectory, true);
                }
            });

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

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

            "Then there should be no errors"
            ._(() => result.Should().BeErrorFree());

            "And there should be an index.md created in the doc folder"
            ._(() => File.Exists(Path.Combine(docDirectory, "index.md")).Should().BeTrue());

            "And the index page list all commands with links to command markdown file"
            ._(() =>
            {
                var index = File.ReadAllText(Path.Combine(docDirectory, "index.md"));
                userCommands.ForEach(
                    command =>
                    index.Should()
                    .Contain(string.Format("[`crane {0}`]({0}.md)", command.Name()),
                             "missing link to command page {0} in index.md", command.Name()));
            });

            "And there should be a markdown file for each public crane command in the doc directory"
            ._(() => ServiceLocator.Resolve <IPublicCommandResolver>().Resolve().ForEach(
                   command => File.Exists(Path.Combine(docDirectory, command.Name() + ".md")).Should().BeTrue("missing {0} in directory {1}", command.Name() + ".md", docDirectory)));

            "And each command help file should have valid content"
            ._(() => userCommands.ForEach(
                   command =>
                   File.ReadAllText(Path.Combine(docDirectory, command.Name() + ".md"))
                   .Should()
                   .Contain(string.Format("usage: crane {0}", command.Name()))));

            "And it should update the mkdocs.yml file to configure add the command links to the navigation bar"
            ._(() =>
            {
                var mkdocs = File.ReadAllText(Path.Combine(rootDirectory, "mkdocs.yml"));
                userCommands.ForEach(command => mkdocs.Should().Contain(string.Format(" - ['{0}.md', 'Commands', '{0}']", command.Name())));
            });
        }
Ejemplo n.º 10
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());
        }
Ejemplo n.º 11
0
        public void showing_help_for_a_command_that_has_no_arguments(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 run context"
            ._(() => craneRunner = new CraneRunner());

            "When I run crane help listcommands"
            ._(() => result = craneRunner.Command(craneTestContext.BuildOutputDirectory, "crane help listcommands"));

            "Then crane outputs the usage statement for the command'"
            ._(() => result.StandardOutput.Line(0).Should().Contain("usage: crane listcommands"))
            .Teardown(() => craneTestContext.TearDown());
        }
Ejemplo n.º 12
0
        public void Calling_crane_with_a_command_that_does_not_exist_prompts_for_help(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());

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

            "Then I receive a message saying 'error: crane foosadf is not a crane command. See 'crane listcommands'"
            ._(() => result.StandardOutput.Should().Be("error: crane foobar is not a crane command. See 'crane listcommands'"))
            .Teardown(() => craneTestContext.TearDown());
        }
Ejemplo n.º 13
0
        public void Init_with_no_arguments_returns_did_you_mean_init_projectname(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 run context"
            ._(() => craneRunner = new CraneRunner());

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

            "Then I receive an error message 'error: The argument 'ProjectName' is required'"
            ._(() => result.StandardOutput.Should().Contain("error: The argument 'ProjectName' is required"))
            .Teardown(() => craneTestContext.TearDown());
        }
Ejemplo n.º 14
0
        public void Calling_crane_listcommands_will_list_all_possible_commands_except_unknown(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 run context"
            ._(() => craneRunner = new CraneRunner());

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

            "Then I receive a message containing all of the possible commands listed alphabetically"
            ._(() => result.StandardOutput.Should().Be(PossibleCommands))
            .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());
        }
        public void Api_can_read_the_latest_git_commit_from_a_solution_in_git(CraneRunner craneRunner, RunResult result, CraneTestContext craneTestContext,
                                                                              ISolutionContext solutionContext, string projectDir, Git git, ISourceControlInformation sourceControlInformation,
                                                                              ICraneApi craneApi)
        {
            "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 initialize that as a git repository"
            ._(() =>
            {
                projectDir = Path.Combine(craneTestContext.BuildOutputDirectory, "ServiceStack");
                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 ServiceStack\"", projectDir).ErrorOutput.Should().BeEmpty();
            });


            "And I have the solution context using the api"
            ._(() =>
            {
                craneApi        = ServiceLocator.Resolve <ICraneApi>();
                solutionContext = craneApi.GetSolutionContext(projectDir);
            });
            "When I get the source information using the api"
            ._(() => sourceControlInformation = craneApi.GetSourceControlInformation(solutionContext));

            "It should set the provider name to git"
            ._(() => sourceControlInformation.ProviderName.Should().Be("git"));

            "It should return the latest commit message as 'First commit of ServiceStack'"
            ._(() => sourceControlInformation.LastCommitMessage.Should().Contain("First commit of ServiceStack"))
            .Teardown(() => craneTestContext.TearDown());
        }
Ejemplo n.º 17
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());
        }
Ejemplo n.º 18
0
        public void Init_with_a_project_name_creates_a_project_with_build(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 run context"
            ._(() => craneRunner = new CraneRunner());

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

            "It should say 'Init success.'"
            ._(() => result.StandardOutput.Should().Be("Init success."));

            "It should replace the solution file name in the build script with the project name"
            ._(() => File.ReadAllText(Path.Combine(craneTestContext.BuildOutputDirectory, "ServiceStack", "build", "default.ps1")).Should().Contain("ServiceStack.sln"))
            .Teardown(() => craneTestContext.TearDown());
        }
Ejemplo n.º 19
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();
            });
        }
Ejemplo n.º 20
0
        public void Init_with_a_project_name_twice_gives_error(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 run context"
            ._(() => craneRunner = new CraneRunner());

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

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

            "It should give an error'"
            ._(() => result.StandardOutput.Should().Contain("ServiceStack"));

            "It should not have an exit code of 0"
            ._(() => result.ExitCode.Should().NotBe(0))
            .Teardown(() => craneTestContext.TearDown());
        }
Ejemplo n.º 21
0
        public void showing_help_for_a_command(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 run context"
            ._(() => craneRunner = new CraneRunner());

            "When I run crane help init"
            ._(() => result = craneRunner.Command(craneTestContext.BuildOutputDirectory, "crane help init"));

            "Then crane outputs the usage statement for the command'"
            ._(() => result.StandardOutput.Line(0).Should().Contain("usage: crane init"));

            "And it should output the example usage"
            ._(() => result.StandardOutput.Should().Contain("example 1"));

            "And it should output the more information message"
            ._(() => result.StandardOutput.Should().Contain("For more information, visit"))
            .Teardown(() => craneTestContext.TearDown());
        }
        public void Api_can_read_a_solution_by_path_direct_to_sln_file(CraneRunner craneRunner, RunResult result, CraneTestContext craneTestContext,
                                                                       ISolutionContext solutionContext)
        {
            "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"));

            "When I get the solution context using the api"
            ._(() =>
            {
                var craneApi    = ServiceLocator.Resolve <ICraneApi>();
                solutionContext = craneApi.GetSolutionContext(Path.Combine(craneTestContext.BuildOutputDirectory, "ServiceStack", "src", "ServiceStack.sln"));
            });

            "It should have the correct path to the solution"
            ._(() => solutionContext.Solution.Path.Should()
               .Be(Path.Combine(craneTestContext.BuildOutputDirectory, "ServiceStack", "src",
                                "ServiceStack.sln")));

            "It should set the solution context path to the root folder"
            ._(() => solutionContext.Path.Should().Be(Path.Combine(craneTestContext.BuildOutputDirectory, "ServiceStack")));

            "It should have 2 projects"
            ._(() => solutionContext.Solution.Projects.Count().Should().Be(2));

            "It should have one project called ServiceStack"
            ._(() => solutionContext.Solution.Projects.Count(p => p.Name == "ServiceStack").Should().Be(1));

            "It should have one project called ServiceStack.UnitTests"
            ._(() => solutionContext.Solution.Projects.Count(p => p.Name == "ServiceStack.UnitTests").Should().Be(1))
            .Teardown(() => craneTestContext.TearDown());
        }
Ejemplo n.º 23
0
        public void patch_solution_assembly_should_only_patch_non_test_projects(CraneRunner craneRunner, RunResult result, CraneTestContext craneTestContext,
                                                                                ISolutionContext solutionContext, ICraneApi craneApi, AssemblyInfo originalAssemblyInfo)
        {
            "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 an instance of the crane api"
            ._(() => craneApi = ServiceLocator.Resolve <ICraneApi>());

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

            "And I have got the solution context using the api"
            ._(() =>
            {
                craneApi             = ServiceLocator.Resolve <ICraneApi>();
                solutionContext      = craneApi.GetSolutionContext(Path.Combine(craneTestContext.BuildOutputDirectory, "ServiceStack"));
                originalAssemblyInfo =
                    solutionContext.Solution.Projects.First(p => p.Name == "ServiceStack.UnitTests").AssemblyInfo;
            });

            "And I have created one a solution with one code project called ServiceStack"
            ._(() => solutionContext.Solution.Projects.First(p => p.Name == "ServiceStack").TestProject.Should().BeFalse());

            "And I have created one a solution with one test project called ServiceStack.UnitTests"
            ._(() => solutionContext.Solution.Projects.First(p => p.Name == "ServiceStack.UnitTests").TestProject.Should().BeTrue());

            "When I path the solution assembly info for all projects"
            ._(() =>
            {
                craneApi.PatchSolutionAssemblyInfo(solutionContext, "1.2.3.4");
                solutionContext = craneApi.GetSolutionContext(Path.Combine(craneTestContext.BuildOutputDirectory, "ServiceStack"));
            });

            "It should patch the code project's assemblyinfo version"
            ._(() => solutionContext.Solution.Projects.First(p => !p.TestProject)
               .AssemblyInfo.Version.ToString().Should().Be("1.2.3.4"));

            "It should patch the code project's assemblyinfo file version"
            ._(() => solutionContext.Solution.Projects.First(p => !p.TestProject)
               .AssemblyInfo.FileVersion.ToString().Should().Be("1.2.3.4"));

            "It should patch the code project's assemblyinfo file informational version"
            ._(() => solutionContext.Solution.Projects.First(p => !p.TestProject)
               .AssemblyInfo.InformationalVersion.Should().Be("1.2.3.4"));

            "It should not patch the test project's assemblyinfo version"
            ._(() => solutionContext.Solution.Projects.First(p => p.TestProject)
               .AssemblyInfo.Version.Should().Be(originalAssemblyInfo.Version));

            "It should not patch the test project's assemblyinfo file version"
            ._(() => solutionContext.Solution.Projects.First(p => p.TestProject)
               .AssemblyInfo.FileVersion.Should().Be(originalAssemblyInfo.FileVersion));

            "It should not patch the test project's file informational version"
            ._(() => solutionContext.Solution.Projects.First(p => p.TestProject)
               .AssemblyInfo.InformationalVersion.Should().Be(originalAssemblyInfo.InformationalVersion))
            .Teardown(() => craneTestContext.TearDown());
        }