예제 #1
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());
        }
        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());
        }
예제 #3
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())));
            });
        }
        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());
        }