예제 #1
0
        public void ShouldReturnTrueWhenCalled()
        {
            // Arrange
            var msbuildCloneTask = new Clone(new Mock <IGitFacade>().Object)
            {
                // Mock away IBuildEngine cause we are not interested in the logging functionality.
                BuildEngine       = new Mock <IBuildEngine>().Object,
                RepositoryToClone = string.Empty,
                TargetDirectory   = string.Empty
            };

            // Act
            bool result = msbuildCloneTask.Execute();

            // Assert
            Assert.IsTrue(result);
        }
예제 #2
0
        public void CloneRepository()
        {
            // Arrange
            var mock             = new Mock <IGitFacade>();
            var msbuildCloneTask = new Clone(mock.Object)
            {
                // Mock away IBuildEngine cause we are not interested in the logging functionality.
                BuildEngine       = new Mock <IBuildEngine>().Object,
                RepositoryToClone = string.Empty,
                TargetDirectory   = string.Empty
            };

            // Act
            Assert.IsTrue(msbuildCloneTask.Execute());

            // Assert
            mock.Verify(git => git.Clone(msbuildCloneTask.RepositoryToClone, msbuildCloneTask.TargetDirectory), Times.Once());
            mock.Verify(git => git.GetLatestSha(msbuildCloneTask.TargetDirectory), Times.Once());
        }
예제 #3
0
        public void ShouldReturnFalseWhenExceptionOccurs()
        {
            // Arrange
            var gitMock          = new Mock <IGitFacade>();
            var msbuildCloneTask = new Clone(gitMock.Object)
            {
                BuildEngine       = new Mock <IBuildEngine>().Object,
                RepositoryToClone = string.Empty,
                TargetDirectory   = string.Empty
            };

            gitMock.Setup(git => git.Clone(msbuildCloneTask.RepositoryToClone, msbuildCloneTask.TargetDirectory)).Throws <InvalidOperationException>();

            // Act
            bool result = msbuildCloneTask.Execute();

            // Assert
            Assert.IsFalse(result);
        }
예제 #4
0
        public void CloneRepository()
        {
            // Arrange
            var mock = new Mock<IGitFacade>();
            var msbuildCloneTask = new Clone(mock.Object)
                                        {
                                            // Mock away IBuildEngine cause we are not interested in the logging functionality.
                                            BuildEngine = new Mock<IBuildEngine>().Object,
                                            RepositoryToClone = string.Empty,
                                            TargetDirectory = string.Empty
                                        };

            // Act
            Assert.IsTrue(msbuildCloneTask.Execute());

            // Assert
            mock.Verify(git => git.Clone(msbuildCloneTask.RepositoryToClone, msbuildCloneTask.TargetDirectory), Times.Once());
            mock.Verify(git => git.GetLatestSha(msbuildCloneTask.TargetDirectory), Times.Once());
        }
예제 #5
0
        public void ShouldLogErrorWhenExceptionErrors()
        {
            // Arrange
            var gitMock          = new Mock <IGitFacade>();
            var buildengineMock  = new Mock <IBuildEngine>();
            var msbuildCloneTask = new Clone(gitMock.Object)
            {
                BuildEngine       = buildengineMock.Object,
                RepositoryToClone = string.Empty,
                TargetDirectory   = string.Empty
            };

            gitMock.Setup(git => git.Clone(msbuildCloneTask.RepositoryToClone, msbuildCloneTask.TargetDirectory)).Throws <InvalidOperationException>();

            // Act
            msbuildCloneTask.Execute();

            // Assert
            buildengineMock.Verify(msbuild => msbuild.LogErrorEvent(It.IsAny <BuildErrorEventArgs>()));
        }
예제 #6
0
        public static void CloneRepositoryCheckoutBranch()
        {
            // Arrange
            var mock             = new Mock <IGitFacade>();
            var msbuildCloneTask = new Clone(mock.Object)
            {
                // Mock away IBuildEngine cause we are not interested in the logging functionality.
                BuildEngine       = new Mock <IBuildEngine>().Object,
                RepositoryToClone = string.Empty,
                TargetDirectory   = string.Empty,
                BranchToSwitchTo  = "somebranchtoswitchto"
            };

            // Act
            msbuildCloneTask.Execute();

            // Assert
            mock.Verify(git => git.Clone(msbuildCloneTask.RepositoryToClone, msbuildCloneTask.TargetDirectory), Times.Once());
            mock.Verify(git => git.CheckoutBranch(msbuildCloneTask.TargetDirectory, msbuildCloneTask.BranchToSwitchTo), Times.Once());
            mock.Verify(git => git.GetLatestSHA(msbuildCloneTask.TargetDirectory), Times.Once());
        }
예제 #7
0
        public void ShouldLogErrorWhenExceptionErrors()
        {
            // Arrange
            var gitMock = new Mock<IGitFacade>();
            var buildengineMock = new Mock<IBuildEngine>();
            var msbuildCloneTask = new Clone(gitMock.Object)
            {
                BuildEngine = buildengineMock.Object,
                RepositoryToClone = string.Empty,
                TargetDirectory = string.Empty
            };
            gitMock.Setup(git => git.Clone(msbuildCloneTask.RepositoryToClone, msbuildCloneTask.TargetDirectory)).Throws<InvalidOperationException>();

            // Act
            msbuildCloneTask.Execute();

            // Assert
            buildengineMock.Verify(msbuild => msbuild.LogErrorEvent(It.IsAny<BuildErrorEventArgs>()));
        }
예제 #8
0
        public void ShouldReturnTrueWhenCalled()
        {
            // Arrange
            var msbuildCloneTask = new Clone(new Mock<IGitFacade>().Object)
            {
                // Mock away IBuildEngine cause we are not interested in the logging functionality.
                BuildEngine = new Mock<IBuildEngine>().Object,
                RepositoryToClone = string.Empty,
                TargetDirectory = string.Empty
            };

            // Act
            bool result = msbuildCloneTask.Execute();

            // Assert
            Assert.IsTrue(result);
        }
예제 #9
0
        public void ShouldReturnFalseWhenExceptionOccurs()
        {
            // Arrange
            var gitMock = new Mock<IGitFacade>();
            var msbuildCloneTask = new Clone(gitMock.Object)
                                    {
                                        BuildEngine = new Mock<IBuildEngine>().Object,
                                        RepositoryToClone = string.Empty,
                                        TargetDirectory = string.Empty
                                    };

            gitMock.Setup(git => git.Clone(msbuildCloneTask.RepositoryToClone, msbuildCloneTask.TargetDirectory)).Throws<InvalidOperationException>();

            // Act
            bool result = msbuildCloneTask.Execute();

            // Assert
            Assert.IsFalse(result);
        }