コード例 #1
0
            public void Should_Append_Source_Directory_To_Arguments()
            {
                // Given
                const string expected = "\"/Working/source\"";
                var          fixture  = new CMakeRunnerFixture();

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

                // Then
                Assert.Equal(expected, result.Args);
            }
コード例 #2
0
            public void ShouldSetWorkingDirectoryToSourcePathIfNoOutputDirectorySpecified()
            {
                // Given
                const string Expected = "/Working/source";
                var          fixture  = new CMakeRunnerFixture();

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

                // Then
                Assert.Equal(Expected, result.Process.WorkingDirectory.FullPath);
            }
コード例 #3
0
            public void Should_Set_Working_Directory_To_Source_Path_If_No_Output_Directory_Specified()
            {
                // Given
                const string expected = "/Working/source";
                var          fixture  = new CMakeRunnerFixture();

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

                // Then
                Assert.Equal(expected, result.Process.WorkingDirectory.FullPath);
            }
コード例 #4
0
            public void ShouldAppendSourceDirectoryToArguments()
            {
                // Given
                const string Expected = "-S \"/Working/source\"";
                var          fixture  = new CMakeRunnerFixture();

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

                // Then
                Assert.Equal(Expected, result.Args);
            }
コード例 #5
0
            public void Should_Use_CMake_Executable_From_Tool_Path_If_Provided(string toolPath, string expected)
            {
                // Given
                var fixture = new CMakeRunnerFixture(toolPath: expected);

                fixture.Settings.ToolPath = toolPath;

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

                // Then
                Assert.Equal(expected, result.Path.FullPath);
            }
コード例 #6
0
            public void Should_Set_Working_Directory_To_Output_Path_If_Set()
            {
                // Given
                const string expected = "/Working/build";
                var          fixture  = new CMakeRunnerFixture();

                fixture.Settings.OutputPath = "./build";

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

                // Then
                Assert.Equal(expected, result.Process.WorkingDirectory.FullPath);
            }
コード例 #7
0
            public void Should_Set_Working_Directory_To_Source_Path_If_No_Output_Directory_Specified()
            {
                // Given
                var fixture = new CMakeRunnerFixture();

                // When
                fixture.Run();

                // Then
                fixture.ProcessRunner.Received(1).Start(
                    Arg.Any <FilePath>(),
                    Arg.Is <ProcessSettings>(
                        p => p.WorkingDirectory.FullPath == "/Working/source"));
            }
コード例 #8
0
            public void Should_Append_Toolset_To_Arguments()
            {
                // Given
                const string expected = "\"/Working/source\" -T \"cool_toolset\"";
                var          fixture  = new CMakeRunnerFixture();

                fixture.Settings.Toolset = "cool_toolset";

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

                // Then
                Assert.Equal(expected, result.Args);
            }
コード例 #9
0
            public void Should_Append_Source_Directory_To_Arguments()
            {
                // Given
                var fixture = new CMakeRunnerFixture();

                // When
                fixture.Run();

                // Then
                fixture.ProcessRunner.Received(1).Start(
                    Arg.Any <FilePath>(),
                    Arg.Is <ProcessSettings>(
                        p => p.Arguments.Render() == "\"/Working/source\""));
            }
コード例 #10
0
            public void Should_Append_Platform_To_Arguments()
            {
                // Given
                const string expected = "\"/Working/source\" -A \"x64\"";
                var          fixture  = new CMakeRunnerFixture();

                fixture.Settings.Platform = "x64";

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

                // Then
                Assert.Equal(expected, result.Args);
            }
コード例 #11
0
            public void Should_Use_CMake_Executable_From_Tool_Path_If_Provided(string toolPath, string expected)
            {
                // Given
                var fixture = new CMakeRunnerFixture(toolPath: expected);

                fixture.Settings.ToolPath = toolPath;

                // When
                fixture.Run();

                // Then
                fixture.ProcessRunner.Received(1).Start(
                    Arg.Is <FilePath>(p => p.FullPath == expected),
                    Arg.Any <ProcessSettings>());
            }
コード例 #12
0
            public void Should_Throw_If_Source_Path_Is_Null()
            {
                // Given
                var fixture = new CMakeRunnerFixture();

                fixture.SourcePath = null;

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

                // Then
                Assert.NotNull(result);
                Assert.IsType <ArgumentNullException>(result);
                Assert.Equal("sourcePath", ((ArgumentNullException)result).ParamName);
            }
コード例 #13
0
            public void Should_Throw_If_File_System_Is_Null()
            {
                // Given
                var fixture = new CMakeRunnerFixture();

                fixture.FileSystem = null;

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

                // Then
                Assert.NotNull(result);
                Assert.IsType <ArgumentNullException>(result);
                Assert.Equal("fileSystem", ((ArgumentNullException)result).ParamName);
            }
コード例 #14
0
            public void ShouldLookInProgramFiles()
            {
                // Given
                var          fixture  = new CMakeRunnerFixture(defaultToolExist: false);
                const string Expected = "/ProgramFilesX86/cmake/bin/cmake.exe";

                fixture.FileSystem.CreateFile(Expected);
                fixture.Environment.SetSpecialPath(SpecialPath.ProgramFilesX86, "/ProgramFilesX86");

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

                // Then
                Assert.Equal(Expected, result.Path.FullPath);
            }
コード例 #15
0
            public void Should_Set_Working_Directory_To_Output_Path_If_Set()
            {
                // Given
                var fixture = new CMakeRunnerFixture();

                fixture.Settings.OutputPath = "./build";

                // When
                fixture.Run();

                // Then
                fixture.ProcessRunner.Received(1).Start(
                    Arg.Any <FilePath>(),
                    Arg.Is <ProcessSettings>(
                        p => p.WorkingDirectory.FullPath == "/Working/build"));
            }
コード例 #16
0
            public void Should_Throw_If_Globber_Is_Null()
            {
                // Given
                var fixture = new CMakeRunnerFixture {
                };

                fixture.Tools = null;

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

                // Then
                Assert.NotNull(result);
                Assert.IsType <ArgumentNullException>(result);
                Assert.Equal("globber", ((ArgumentNullException)result).ParamName);
            }
コード例 #17
0
            public void Should_Append_Options_To_Arguments()
            {
                // Given
                const string expected = "\"/Working/source\" \"-DCMAKE_IS_COOL\" \"-DCAKE_IS_COOL\"";
                var          fixture  = new CMakeRunnerFixture();

                fixture.Settings.Options = new List <string> {
                    "-DCMAKE_IS_COOL", "-DCAKE_IS_COOL"
                };

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

                // Then
                Assert.Equal(expected, result.Args);
            }
コード例 #18
0
            public void Should_Append_Toolset_To_Arguments()
            {
                // Given
                var fixture = new CMakeRunnerFixture();

                fixture.Settings.Toolset = "cool_toolset";

                // When
                fixture.Run();

                // Then
                fixture.ProcessRunner.Received(1).Start(
                    Arg.Any <FilePath>(),
                    Arg.Is <ProcessSettings>(
                        p => p.Arguments.Render() == "\"/Working/source\" -T \"cool_toolset\""));
            }
コード例 #19
0
            public void ShouldThrowIfProcessRunnerIsNull()
            {
                // Given
                var fixture = new CMakeRunnerFixture
                {
                    ProcessRunner = null
                };

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

                // Then
                Assert.NotNull(result);
                Assert.IsType <ArgumentNullException>(result);
                Assert.Equal("processRunner", ((ArgumentNullException)result).ParamName);
            }
コード例 #20
0
            public void ShouldUseCMakeExecutableFromToolPathIfProvided(string toolPath, string expected)
            {
                // Given
                var fixture = new CMakeRunnerFixture(toolPath: expected)
                {
                    Settings =
                    {
                        ToolPath = toolPath
                    }
                };

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

                // Then
                Assert.Equal(expected, result.Path.FullPath);
            }
コード例 #21
0
            public void ShouldNotThrowIfSourcePathIsNull()
            {
                // Given
                var fixture = new CMakeRunnerFixture
                {
                    Settings =
                    {
                        SourcePath = null,
                        OutputPath = "./build"
                    }
                };

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

                // Then
                Assert.Null(result);
            }
コード例 #22
0
            public void ShouldAppendPlatformToArguments()
            {
                // Given
                const string Expected = "-S \"/Working/source\" -A \"x64\"";
                var          fixture  = new CMakeRunnerFixture
                {
                    Settings =
                    {
                        Platform = "x64"
                    }
                };

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

                // Then
                Assert.Equal(Expected, result.Args);
            }
コード例 #23
0
            public void ShouldAppendToolsetToArguments()
            {
                // Given
                const string Expected = "-S \"/Working/source\" -T \"cool_toolset\"";
                var          fixture  = new CMakeRunnerFixture
                {
                    Settings =
                    {
                        Toolset = "cool_toolset"
                    }
                };

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

                // Then
                Assert.Equal(Expected, result.Args);
            }
コード例 #24
0
            public void ShouldAppendGeneratorToArguments()
            {
                // Given
                const string Expected = "-S \"/Working/source\" -G \"cool_generator\"";
                var          fixture  = new CMakeRunnerFixture
                {
                    Settings =
                    {
                        Generator = "cool_generator"
                    }
                };

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

                // Then
                Assert.Equal(Expected, result.Args);
            }
コード例 #25
0
            public void ShouldSetWorkingDirectoryToOutputPathIfSet()
            {
                // Given
                const string Expected = "/Working/build";
                var          fixture  = new CMakeRunnerFixture
                {
                    Settings =
                    {
                        OutputPath = "./build"
                    }
                };

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

                // Then
                Assert.Equal(Expected, result.Process.WorkingDirectory.FullPath);
            }
コード例 #26
0
            public void Should_Look_In_Program_Files()
            {
                // Given
                var fixture = new CMakeRunnerFixture(defaultToolExist: false);

                fixture.FileSystem.Exist(
                    Arg.Is <FilePath>(p => p.FullPath == "/ProgramFilesX86/cmake/bin/cmake.exe")).Returns(true);
                fixture.Environment.GetSpecialPath(
                    Arg.Is <SpecialPath>(p => p == SpecialPath.ProgramFilesX86)).Returns(info => "/ProgramFilesX86");

                // When
                fixture.Run();

                // Then
                fixture.ProcessRunner.Received(1).Start(
                    Arg.Is <FilePath>(p => p.FullPath == "/ProgramFilesX86/cmake/bin/cmake.exe"),
                    Arg.Any <ProcessSettings>());
            }
コード例 #27
0
            public void ShouldThrowIfSourcePathAndOutputPathIsNull()
            {
                // Given
                var fixture = new CMakeRunnerFixture
                {
                    Settings =
                    {
                        SourcePath = null,
                        OutputPath = null
                    }
                };

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

                // Then
                Assert.NotNull(result);
                Assert.IsType <ArgumentException>(result);
                Assert.Equal("The settings properties OutputPath or SourcePath should not be null.", ((ArgumentException)result).Message);
            }
コード例 #28
0
            public void ShouldAppendOptionsToArguments()
            {
                // Given
                const string Expected = "-S \"/Working/source\" \"-DCMAKE_IS_COOL\" \"-DCAKE_IS_COOL\"";
                var          fixture  = new CMakeRunnerFixture
                {
                    Settings =
                    {
                        Options = new List <string>
                        {
                            "-DCMAKE_IS_COOL",
                            "-DCAKE_IS_COOL"
                        }
                    }
                };

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

                // Then
                Assert.Equal(Expected, result.Args);
            }