示例#1
0
            public void WhenBuild_IfNoPhysicalDirectoryExist_ShouldThrow()
            {
                // Arrange
                var mock = new CoreMockGenerator()
                           .MockApplication()
                           .MockApplicationPhysicalDirectoryDoesNotExist();

                // Act, Assert
                var helper = new BuildHelper(mock.FileSystem.Object, mock.EnvironmentSystem.Object, mock.ProcessRunner.Object);
                var exception = Assert.Throws<Exception>(() => helper.Build(
                    mock.MockApplicationPhysicalPath,
                    mock.MockApplicationName));

                Assert.Equal(string.Format("Application directory '{0}' does not exist.", mock.MockApplicationPhysicalPath), exception.Message);
            }
示例#2
0
            public void WhenBuild_IfNoPhysicalDirectoryExist_ShouldThrow()
            {
                // Arrange
                var mock = new CoreMockGenerator()
                           .MockApplication()
                           .MockApplicationPhysicalDirectoryDoesNotExist();

                // Act, Assert
                var helper    = new BuildHelper(mock.FileSystem.Object, mock.EnvironmentSystem.Object, mock.ProcessRunner.Object);
                var exception = Assert.Throws <Exception>(() => helper.Build(
                                                              mock.MockApplicationPhysicalPath,
                                                              mock.MockApplicationName));

                Assert.Equal(string.Format("Application directory '{0}' does not exist.", mock.MockApplicationPhysicalPath), exception.Message);
            }
示例#3
0
            public void WhenBuild_IfProcessStartNormallyFromProgramFiles_ShouldWorkOk()
            {
                // Arrange
                var mock = new CoreMockGenerator();
                mock.MockApplication()
                    .MockApplicationPhysicalDirectory()
                    .MockApplicationProjectFile()
                    .MockGetMsBuildPathProgramFilesMsbuild()
                    .MockBuildProcessStartNormally(mock.MockProgramFilesMsbuilPath);

                // Act, Assert
                var helper = new BuildHelper(mock.FileSystem.Object, mock.EnvironmentSystem.Object, mock.ProcessRunner.Object);
                helper.Build(
                    mock.MockApplicationPhysicalPath,
                    mock.MockApplicationName);
            }
示例#4
0
            public void WhenBuild_IfProcessStartNormallyFromDotNet_ShouldWorkOk()
            {
                // Arrange
                var mock = new CoreMockGenerator();

                mock.MockApplication()
                .MockApplicationPhysicalDirectory()
                .MockApplicationProjectFile()
                .MockGetMsBuildDotNetMsbuild()
                .MockBuildProcessStartNormally(mock.MockDotNetMsbuilPath);

                // Act, Assert
                var helper = new BuildHelper(mock.FileSystem.Object, mock.EnvironmentSystem.Object, mock.ProcessRunner.Object);

                helper.Build(
                    mock.MockApplicationPhysicalPath,
                    mock.MockApplicationName);
            }
示例#5
0
            public void WhenBuild_IfMsbuildNotFound_ShouldThrow()
            {
                // Arrange
                var mock = new CoreMockGenerator();

                mock.MockApplication()
                .MockApplication()
                .MockApplicationPhysicalDirectory()
                .MockApplicationProjectFile()
                .MockGetMsBuildPathNotFound();

                // Act, Assert
                var helper    = new BuildHelper(mock.FileSystem.Object, mock.EnvironmentSystem.Object, mock.ProcessRunner.Object);
                var exception = Assert.Throws <Exception>(() => helper.Build(
                                                              mock.MockApplicationPhysicalPath,
                                                              mock.MockApplicationName));

                Assert.Equal("MsBuild.exe was not found on the machine.", exception.Message);
            }
示例#6
0
            public void WhenBuild_IfProcessStartReturnsFalse_ShouldThrow()
            {
                // Arrange
                var mock = new CoreMockGenerator();
                mock.MockApplication()
                    .MockApplicationPhysicalDirectory()
                    .MockApplicationProjectFile()
                    .MockGetMsBuildPathProgramFilesMsbuild()
                    .MockBuildProcessStartFalse(mock.MockProgramFilesMsbuilPath);

                // Act, Assert
                var helper = new BuildHelper(mock.FileSystem.Object, mock.EnvironmentSystem.Object, mock.ProcessRunner.Object);
                var exception = Assert.Throws<Exception>(() => helper.Build(
                    mock.MockApplicationPhysicalPath,
                    mock.MockApplicationName));

                Assert.Equal(string.Format(@"Failed to start msbuild to build a project '{0}' at '{1}'",
                            mock.MockApplicationName + ".csproj", mock.MockApplicationPhysicalPath), exception.Message);
            }
示例#7
0
            public void WhenBuild_IfProcessStartReturnsFalse_ShouldThrow()
            {
                // Arrange
                var mock = new CoreMockGenerator();

                mock.MockApplication()
                .MockApplicationPhysicalDirectory()
                .MockApplicationProjectFile()
                .MockGetMsBuildPathProgramFilesMsbuild()
                .MockBuildProcessStartFalse(mock.MockProgramFilesMsbuilPath);

                // Act, Assert
                var helper    = new BuildHelper(mock.FileSystem.Object, mock.EnvironmentSystem.Object, mock.ProcessRunner.Object);
                var exception = Assert.Throws <Exception>(() => helper.Build(
                                                              mock.MockApplicationPhysicalPath,
                                                              mock.MockApplicationName));

                Assert.Equal(string.Format(@"Failed to start msbuild to build a project '{0}' at '{1}'",
                                           mock.MockApplicationName + ".csproj", mock.MockApplicationPhysicalPath), exception.Message);
            }
示例#8
0
            public void WhenBuild_IfBuildProcessExitCodeNotZero_ShouldThrow()
            {
                // Arrange
                var mock = new CoreMockGenerator();

                mock.MockApplication()
                .MockApplicationPhysicalDirectory()
                .MockApplicationProjectFile()
                .MockGetMsBuildDotNetMsbuild()
                .MockBuildProcessExitCodeNotZero(mock.MockDotNetMsbuilPath);

                // Act, Assert
                var helper    = new BuildHelper(mock.FileSystem.Object, mock.EnvironmentSystem.Object, mock.ProcessRunner.Object);
                var exception = Assert.Throws <Exception>(() => helper.Build(
                                                              mock.MockApplicationPhysicalPath,
                                                              mock.MockApplicationName));

                Assert.Equal(string.Format("There were some errors while trying to build a project '{0}' at '{1}': {2}",
                                           mock.MockApplicationName + ".csproj", mock.MockApplicationPhysicalPath, mock.MockBuildOutput), exception.Message);
            }
示例#9
0
            public void WhenBuild_IfBuildProcessExitCodeNotZero_ShouldThrow()
            {
                // Arrange
                var mock = new CoreMockGenerator();
                mock.MockApplication()
                    .MockApplicationPhysicalDirectory()
                    .MockApplicationProjectFile()
                    .MockGetMsBuildDotNetMsbuild()
                    .MockBuildProcessExitCodeNotZero(mock.MockDotNetMsbuilPath);

                // Act, Assert
                var helper = new BuildHelper(mock.FileSystem.Object, mock.EnvironmentSystem.Object, mock.ProcessRunner.Object);
                var exception = Assert.Throws<Exception>(() => helper.Build(
                    mock.MockApplicationPhysicalPath,
                    mock.MockApplicationName));

                Assert.Equal(string.Format("There were some errors while trying to build a project '{0}' at '{1}': {2}",
                    mock.MockApplicationName + ".csproj", mock.MockApplicationPhysicalPath, mock.MockBuildOutput), exception.Message);
            }
示例#10
0
            public void WhenBuild_IfMsbuildNotFound_ShouldThrow()
            {
                // Arrange
                var mock = new CoreMockGenerator();
                mock.MockApplication()
                    .MockApplication()
                    .MockApplicationPhysicalDirectory()
                    .MockApplicationProjectFile()
                    .MockGetMsBuildPathNotFound();

                // Act, Assert
                var helper = new BuildHelper(mock.FileSystem.Object, mock.EnvironmentSystem.Object, mock.ProcessRunner.Object);
                var exception = Assert.Throws<Exception>(() => helper.Build(
                    mock.MockApplicationPhysicalPath,
                    mock.MockApplicationName));

                Assert.Equal("MsBuild.exe was not found on the machine.", exception.Message);
            }