public void Should_Find_Octo_Executable_If_Tool_Path_Not_Provided()
            {
                // Given
                var fixture = new OctopusDeploymentQuerierFixture();

                // When
                var result = fixture.Run();

                // Then
                Assert.Equal("/Working/tools/Octo.exe", result.Path.FullPath);
            }
            public void Should_Throw_If_Process_Has_A_Non_Zero_Exit_Code()
            {
                // Given
                var fixture = new OctopusDeploymentQuerierFixture();

                fixture.GivenProcessExitsWithCode(1);

                // When
                var result = Record.Exception(() => fixture.Run());

                // Then
                AssertEx.IsCakeException(result, "Octo: Process returned an error (exit code 1).");
            }
            public void Should_Throw_If_Count_Is_Less_Than_1()
            {
                // Given
                var fixture = new OctopusDeploymentQuerierFixture();

                fixture.Settings.Count = 0;

                // When
                var result = Record.Exception(() => fixture.Run());

                // Then
                AssertEx.IsArgumentOutOfRangeException(result, "Query must return at least one result");
            }
            public void Should_Throw_If_Process_Was_Not_Started()
            {
                // Given
                var fixture = new OctopusDeploymentQuerierFixture();

                fixture.GivenProcessCannotStart();

                // When
                var result = Record.Exception(() => fixture.Run());

                // Then
                AssertEx.IsCakeException(result, "Octo: Process was not started.");
            }
            public void Should_Throw_If_Octo_Executable_Was_Not_Found()
            {
                // Given
                var fixture = new OctopusDeploymentQuerierFixture();

                fixture.GivenDefaultToolDoNotExist();

                // When
                var result = Record.Exception(() => fixture.Run());

                // Then
                AssertEx.IsCakeException(result, "Octo: Could not locate executable.");
            }
            public void Should_Add_TenantName_To_Query_Filter()
            {
                // Given
                var fixture = new OctopusDeploymentQuerierFixture();

                fixture.Settings.TenantName = "Tenant A";

                // When
                var result = fixture.Run();

                // Then
                Assert.Equal("list-deployments --tenant \"Tenant A\" --number 1 " +
                             "--server http://octopus --apiKey API-12345", result.Args);
            }
            public void Should_Map_Count_To_Query_Filter()
            {
                // Given
                var fixture = new OctopusDeploymentQuerierFixture();

                fixture.Settings.Count = 10;

                // When
                var result = fixture.Run();

                // Then
                Assert.Equal("list-deployments --number 10 " +
                             "--server http://octopus --apiKey API-12345", result.Args);
            }
            public void Should_Use_Octo_Executable_From_Tool_Path_If_Provided_On_Windows(string toolPath, string expected)
            {
                // Given
                var fixture = new OctopusDeploymentQuerierFixture();

                fixture.Settings.ToolPath = toolPath;
                fixture.GivenSettingsToolPathExist();

                // When
                var result = fixture.Run();

                // Then
                Assert.Equal(expected, result.Path.FullPath);
            }
            public void Should_Map_All_Query_Filter_Options()
            {
                // Given
                var fixture = new OctopusDeploymentQuerierFixture();

                fixture.Settings.ProjectName     = "Project A";
                fixture.Settings.EnvironmentName = "Env A";
                fixture.Settings.TenantName      = "Tenant A";
                fixture.Settings.Count           = 5;

                // When
                var result = fixture.Run();

                // Then
                Assert.Equal("list-deployments --environment \"Env A\" " +
                             "--project \"Project A\" " +
                             "--tenant \"Tenant A\" --number 5 " +
                             "--server http://octopus --apiKey API-12345", result.Args);
            }