Exemple #1
0
            public void Should_Use_Correct_Default_Target_In_Process_Arguments()
            {
                // Given
                var fixture = new MSBuildRunnerFixture();
                var runner  = fixture.CreateRunner();

                // When
                runner.Run(new MSBuildSettings("./src/Solution.sln"));

                // Then
                fixture.ProcessRunner.Received(1).Start(Arg.Is <ProcessStartInfo>(
                                                            p => p.Arguments == "/m /target:Build \"src/Solution.sln\""));
            }
Exemple #2
0
            public void Should_Set_Working_Directory()
            {
                // Given
                var fixture  = new MSBuildRunnerFixture();
                var runner   = fixture.CreateRunner();
                var settings = new MSBuildSettings("./src/Solution.sln");

                // When
                runner.Run(settings);

                // Then
                fixture.ProcessRunner.Received(1).Start(Arg.Is <ProcessStartInfo>(
                                                            p => p.WorkingDirectory == "/Working"));
            }
Exemple #3
0
            public void Should_Throw_If_Process_Has_A_Non_Zero_Exit_Code()
            {
                // Given
                var fixture = new MSBuildRunnerFixture();

                fixture.Process.GetExitCode().Returns(1);
                var runner = fixture.CreateRunner();

                // When
                var result = Record.Exception(() => runner.Run(new MSBuildSettings("./src/Solution.sln")));

                // Then
                Assert.IsType <CakeException>(result);
                Assert.Equal("MSBuild: Process returned an error.", result.Message);
            }
Exemple #4
0
            public void Should_Throw_If_Process_Was_Not_Started()
            {
                // Given
                var fixture = new MSBuildRunnerFixture();

                fixture.ProcessRunner.Start(Arg.Any <ProcessStartInfo>()).Returns((IProcess)null);
                var runner = fixture.CreateRunner();

                // When
                var result = Record.Exception(() => runner.Run(new MSBuildSettings("./src/Solution.sln")));

                // Then
                Assert.IsType <CakeException>(result);
                Assert.Equal("MSBuild: Process was not started.", result.Message);
            }
Exemple #5
0
            public void Should_Get_Correct_Path_To_MSBuild_Version_35(MSBuildToolVersion version, PlatformTarget target, bool is64BitOperativeSystem, string expected)
            {
                // Given
                var fixture = new MSBuildRunnerFixture(is64BitOperativeSystem);
                var runner  = fixture.CreateRunner();

                // When
                runner.Run(new MSBuildSettings("./src/Solution.sln")
                {
                    ToolVersion    = version,
                    PlatformTarget = target
                });

                // Then
                fixture.ProcessRunner.Received(1).Start(Arg.Is <ProcessStartInfo>(
                                                            p => p.FileName == expected));
            }
Exemple #6
0
            public void Should_Append_Configuration_As_Property_To_Process_Arguments()
            {
                // Given
                var fixture = new MSBuildRunnerFixture();
                var runner  = fixture.CreateRunner();

                var settings = new MSBuildSettings("./src/Solution.sln");

                settings.SetConfiguration("Release");

                // When
                runner.Run(settings);

                // Then
                fixture.ProcessRunner.Received(1).Start(Arg.Is <ProcessStartInfo>(
                                                            p => p.Arguments == "/m /p:\"Configuration\"=\"Release\" /target:Build \"src/Solution.sln\""));
            }
Exemple #7
0
            public void Should_Use_Specified_Number_Of_Max_Processors()
            {
                // Given
                var fixture = new MSBuildRunnerFixture();
                var runner  = fixture.CreateRunner();

                var settings = new MSBuildSettings("./src/Solution.sln");

                settings.MaxCpuCount = 4;

                // When
                runner.Run(settings);

                // Then
                fixture.ProcessRunner.Received(1).Start(Arg.Is <ProcessStartInfo>(
                                                            p => p.Arguments == "/m:4 /target:Build \"src/Solution.sln\""));
            }
Exemple #8
0
            public void Should_Use_As_Many_Processors_As_Possible_If_MaxCpuCount_Is_Zero()
            {
                // Given
                var fixture = new MSBuildRunnerFixture();
                var runner  = fixture.CreateRunner();

                var settings = new MSBuildSettings("./src/Solution.sln");

                settings.MaxCpuCount = 0;

                // When
                runner.Run(settings);

                // Then
                fixture.ProcessRunner.Received(1).Start(Arg.Is <ProcessStartInfo>(
                                                            p => p.Arguments == "/m /target:Build \"src/Solution.sln\""));
            }
Exemple #9
0
            public void Should_Append_Property_With_Multiple_Values_To_Process_Arguments()
            {
                // Given
                var fixture = new MSBuildRunnerFixture();
                var runner  = fixture.CreateRunner();

                var settings = new MSBuildSettings("./src/Solution.sln");

                settings.WithProperty("A", new[] { "B", "E" });
                settings.WithProperty("C", "D");

                // When
                runner.Run(settings);

                // Then
                fixture.ProcessRunner.Received(1).Start(Arg.Is <ProcessStartInfo>(
                                                            p => p.Arguments == "/m /p:\"A\"=\"B\" /p:\"A\"=\"E\" /p:\"C\"=\"D\" /target:Build \"src/Solution.sln\""));
            }
Exemple #10
0
            public void Should_Append_Targets_To_Process_Arguments()
            {
                // Given
                var fixture = new MSBuildRunnerFixture();
                var runner  = fixture.CreateRunner();

                var settings = new MSBuildSettings("./src/Solution.sln");

                settings.WithTarget("A");
                settings.WithTarget("B");

                // When
                runner.Run(settings);

                // Then
                fixture.ProcessRunner.Received(1).Start(Arg.Is <ProcessStartInfo>(
                                                            p => p.Arguments == "/m /target:A;B \"src/Solution.sln\""));
            }
Exemple #11
0
            public void Should_Throw_If_MSBuild_Executable_Did_Not_Exist()
            {
                // Given
                var fixture = new MSBuildRunnerFixture(msBuildFileExist: false);
                var runner  = fixture.CreateRunner();

                // When
                var result = Record.Exception(() => runner.Run(
                                                  new MSBuildSettings("./src/Solution.sln")
                {
                    PlatformTarget = PlatformTarget.x86,
                    ToolVersion    = MSBuildToolVersion.NET20
                }));

                // Then
                Assert.IsType <CakeException>(result);
                Assert.Equal("MSBuild: Could not locate executable.", result.Message);
            }