public void ShouldCreateWorkingDirectoryIfItDoesntExistOrIsNotARepository()
        {
            hg = new Mercurial((IHistoryParser)mockHistoryParser.MockInstance, (ProcessExecutor)mockProcessExecutor.MockInstance,
                               (IFileSystem)mockFileSystem.MockInstance, (IFileDirectoryDeleter)mockFileDirectoryDeleter.MockInstance);
            hg.WorkingDirectory = tempWorkDir;
            hg.Repository       = @"C:\foo";

            mockFileSystem.Expect("EnsureFolderExists", tempWorkDir);
            mockFileSystem.Expect("EnsureFolderExists", tempHgDir);
            mockFileSystem.ExpectAndReturn("DirectoryExists", true, tempWorkDir);
            mockFileSystem.ExpectAndReturn("DirectoryExists", false, tempHgDir);
            mockFileDirectoryDeleter.Expect("DeleteIncludingReadOnlyObjects", new object[] { tempWorkDir });
            mockFileSystem.ExpectAndReturn("DirectoryExists", false, tempWorkDir);
            ExpectToExecuteArguments(@"init " + StringUtil.AutoDoubleQuoteString(tempWorkDir), Directory.GetParent(Path.GetFullPath(tempWorkDir)).FullName);
            ExpectToExecuteArguments(@"pull C:\foo", tempWorkDir);

            hg.GetModifications(IntegrationResult(from), IntegrationResult(to));
        }
Exemple #2
0
        public void ShouldCreateWorkingDirectoryIfItDoesntExistOrIsNotARepository()
        {
            hg = new Mercurial((IHistoryParser)mockHistoryParser.Object, (ProcessExecutor)mockProcessExecutor.Object,
                               (IFileSystem)mockFileSystem.Object, (IFileDirectoryDeleter)mockFileDirectoryDeleter.Object);
            hg.WorkingDirectory = tempWorkDir;
            hg.Repository       = @"C:\foo";

            MockSequence sequence = new MockSequence();

            mockFileSystem.Setup(fileSystem => fileSystem.EnsureFolderExists(tempWorkDir)).Verifiable();
            mockFileSystem.Setup(fileSystem => fileSystem.EnsureFolderExists(tempHgDir)).Verifiable();
            mockFileSystem.InSequence(sequence).Setup(fileSystem => fileSystem.DirectoryExists(tempWorkDir)).Returns(true).Verifiable();
            mockFileSystem.Setup(fileSystem => fileSystem.DirectoryExists(tempHgDir)).Returns(false).Verifiable();
            mockFileDirectoryDeleter.Setup(deleter => deleter.DeleteIncludingReadOnlyObjects(tempWorkDir)).Verifiable();
            mockFileSystem.InSequence(sequence).Setup(fileSystem => fileSystem.DirectoryExists(tempWorkDir)).Returns(false).Verifiable();
            ExpectToExecuteArguments(sequence, @"init " + StringUtil.AutoDoubleQuoteString(tempWorkDir), Directory.GetParent(Path.GetFullPath(tempWorkDir)).FullName);
            ExpectToExecuteArguments(sequence, @"pull C:\foo", tempWorkDir);

            hg.GetModifications(IntegrationResult(from), IntegrationResult(to));
        }
        public void ShouldBuildUrlIfUrlBuilderSpecified()
        {
            IMock mockUrlBuilder = new DynamicMock(typeof(IModificationUrlBuilder));

            Modification[] modifications = new Modification[2] {
                new Modification(), new Modification()
            };
            hg.UrlBuilder = (IModificationUrlBuilder)mockUrlBuilder.MockInstance;

            mockProcessExecutor.ExpectAndReturn("Execute", new ProcessResult("", "", 0, false), new IsAnything());
            mockProcessExecutor.ExpectAndReturn("Execute", new ProcessResult("3", "", 0, false), new IsAnything());
            mockProcessExecutor.ExpectAndReturn("Execute", new ProcessResult("4", "", 0, false), new IsAnything());
            mockHistoryParser.ExpectAndReturn("Parse", modifications, new IsAnything(), new IsAnything(), new IsAnything());
            mockUrlBuilder.ExpectAndReturn("SetupModification", modifications, new object[] { modifications });

            Modification[] result = hg.GetModifications(IntegrationResult(from), IntegrationResult(to));
            Assert.That(result, Is.EqualTo(modifications));
            mockUrlBuilder.Verify();
        }
Exemple #4
0
        public void ShouldBuildUrlIfUrlBuilderSpecified()
        {
            var mockUrlBuilder = new Mock <IModificationUrlBuilder>();

            Modification[] modifications = new Modification[2] {
                new Modification(), new Modification()
            };
            hg.UrlBuilder = (IModificationUrlBuilder)mockUrlBuilder.Object;
            MockSequence sequence = new MockSequence();

            mockProcessExecutor.InSequence(sequence).Setup(executor => executor.Execute(It.IsAny <ProcessInfo>())).Returns(new ProcessResult("", "", 0, false)).Verifiable();
            mockProcessExecutor.InSequence(sequence).Setup(executor => executor.Execute(It.IsAny <ProcessInfo>())).Returns(new ProcessResult("3", "", 0, false)).Verifiable();
            mockProcessExecutor.InSequence(sequence).Setup(executor => executor.Execute(It.IsAny <ProcessInfo>())).Returns(new ProcessResult("4", "", 0, false)).Verifiable();
            mockHistoryParser.Setup(parser => parser.Parse(It.IsAny <TextReader>(), It.IsAny <DateTime>(), It.IsAny <DateTime>())).Returns(modifications).Verifiable();
            mockUrlBuilder.Setup(builder => builder.SetupModification(modifications)).Verifiable();

            Modification[] result = hg.GetModifications(IntegrationResult(from), IntegrationResult(to));
            Assert.That(result, Is.EqualTo(modifications));
            mockUrlBuilder.Verify();
        }