public void Setup() { this.mocks = new MockRepository(); mockery = new Mockery(); targetMock = mockery.NewDynamicMock(typeof(IIntegrationRunnerTarget)); resultManagerMock = mockery.NewDynamicMock(typeof(IIntegrationResultManager)); quietPeriodMock = mockery.NewDynamicMock(typeof(IQuietPeriod)); runner = new IntegrationRunner((IIntegrationResultManager)resultManagerMock.MockInstance, (IIntegrationRunnerTarget)targetMock.MockInstance, (IQuietPeriod)quietPeriodMock.MockInstance); request = ModificationExistRequest(); endTime = new DateTime(2005, 2, 1); modifications = new Modification[] { new Modification() }; resultMock = mockery.NewDynamicMock(typeof(IIntegrationResult)); resultMock.SetupResult("WorkingDirectory", TempFileUtil.GetTempPath("workingDir")); resultMock.SetupResult("ArtifactDirectory", TempFileUtil.GetTempPath("artifactDir")); resultMock.SetupResult("BuildProgressInformation", new ThoughtWorks.CruiseControl.Core.Util.BuildProgressInformation("", string.Empty)); resultMock.SetupResult("IntegrationProperties", new Dictionary <string, string>()); result = (IIntegrationResult)resultMock.MockInstance; lastResultMock = mockery.NewDynamicMock(typeof(IIntegrationResult)); lastResult = (IIntegrationResult)lastResultMock.MockInstance; }
public void GetModificationsForModificationInRootFolder() { sandboxRoot = TempFileUtil.GetTempPath("MksSandBox"); Modification addedModification = ModificationMother.CreateModification("myFile.file", null); addedModification.Type = "Added"; mksHistoryParserWrapper.Setup(parser => parser.Parse(It.IsAny <TextReader>(), FROM, TO)).Returns(new Modification[] { addedModification }).Verifiable(); mksHistoryParserWrapper.Setup(parser => parser.ParseMemberInfoAndAddToModification(It.IsAny <Modification>(), It.IsAny <StringReader>())).Verifiable(); mockExecutorWrapper.Setup(executor => executor.Execute(It.IsAny <ProcessInfo>())).Returns(new ProcessResult("", null, 0, false)).Verifiable(); string expectedCommand = string.Format(@"memberinfo --xmlapi --user=CCNetUser --password=CCNetPassword --quiet {0}", GeneratePath(@"{0}\myFile.file", sandboxRoot)); ProcessInfo expectedProcessInfo = ExpectedProcessInfo(expectedCommand); mockExecutorWrapper.Setup(executor => executor.Execute(expectedProcessInfo)).Returns(new ProcessResult(null, null, 0, false)).Verifiable(); string expectedDisconnectCommand = string.Format(@"disconnect --user=CCNetUser --password=CCNetPassword --quiet --forceConfirm=yes"); ProcessInfo expectedDisconnectProcessInfo = ExpectedProcessInfo(expectedDisconnectCommand); mockExecutorWrapper.Setup(executor => executor.Execute(expectedDisconnectProcessInfo)).Returns(new ProcessResult(null, null, 0, false)).Verifiable(); mks = CreateMks(CreateSourceControlXml(), mksHistoryParser, mockProcessExecutor); Modification[] modifications = mks.GetModifications(IntegrationResultMother.CreateSuccessful(FROM), IntegrationResultMother.CreateSuccessful(TO)); Assert.AreEqual(1, modifications.Length); }
public void Setup() { this.mocks = new MockRepository(MockBehavior.Default); mockery = new Mockery(); targetMock = mockery.NewDynamicMock <IIntegrationRunnerTarget>(); resultManagerMock = mockery.NewDynamicMock <IIntegrationResultManager>(); quietPeriodMock = mockery.NewDynamicMock <IQuietPeriod>(); runner = new IntegrationRunner((IIntegrationResultManager)resultManagerMock.Object, (IIntegrationRunnerTarget)targetMock.Object, (IQuietPeriod)quietPeriodMock.Object); request = ModificationExistRequest(); endTime = new DateTime(2005, 2, 1); modifications = new Modification[] { new Modification() }; resultMock = mockery.NewDynamicMock <IIntegrationResult>(); resultMock.SetupGet(_result => _result.WorkingDirectory).Returns(TempFileUtil.GetTempPath("workingDir")); resultMock.SetupGet(_result => _result.ArtifactDirectory).Returns(TempFileUtil.GetTempPath("artifactDir")); resultMock.SetupGet(_result => _result.BuildProgressInformation).Returns(new ThoughtWorks.CruiseControl.Core.Util.BuildProgressInformation("", string.Empty)); resultMock.SetupGet(_result => _result.IntegrationProperties).Returns(new Dictionary <string, string>()); result = (IIntegrationResult)resultMock.Object; lastResultMock = mockery.NewDynamicMock <IIntegrationResult>(); lastResult = (IIntegrationResult)lastResultMock.Object; }
public void TestCreateTempDirOverride() { TempFileUtil.CreateTempDir(TempDir); TempFileUtil.CreateTempFiles(TempDir, new String[] { "test.tmp" }); Assert.AreEqual(1, Directory.GetFiles(TempFileUtil.GetTempPath(TempDir)).Length); TempFileUtil.CreateTempDir(TempDir); Assert.AreEqual(0, Directory.GetFiles(TempFileUtil.GetTempPath(TempDir)).Length); }
private string GenerateProjectXml() { string buildXml = ConfigurationFixture.GenerateMockBuildXml(); string sourceControlXml = ConfigurationFixture.GenerateDefaultSourceControlXml(); // string scheduleXml = ConfigurationFixture.GenerateScheduleXml(Schedule.Infinite); string historyXml = ConfigurationFixture.GenerateStateManagerXml(TempFileUtil.GetTempPath(TEMP_DIR)); return(ConfigurationFixture.GenerateProjectXml(PROJECT_NAME, buildXml, sourceControlXml, null, null, historyXml)); }
public void CreateWorkingDirectoryIfItDoesNotExist() { string workingDirectory = TempFileUtil.GetTempPath("VSS"); TempFileUtil.DeleteTempDir(workingDirectory); Assert.IsFalse(Directory.Exists(workingDirectory)); ExpectToExecuteAndReturn(SuccessfulProcessResult()); vss.AutoGetSource = true; vss.WorkingDirectory = workingDirectory; vss.GetSource(IntegrationResultMother.CreateFailed()); Assert.IsTrue(Directory.Exists(workingDirectory)); TempFileUtil.DeleteTempDir(workingDirectory); }
public void RebaseRelativeWorkingDirectoryPathFromProjectWorkingDirectory() { string expectedWorkingDirectory = TempFileUtil.GetTempPath("VSS"); ProcessInfo info = new ProcessInfo(DEFAULT_SS_EXE_PATH, ForGetCommand(), expectedWorkingDirectory); info.TimeOut = DefaultTimeout; ExpectToExecute(info); IntegrationResult result = IntegrationResultMother.CreateSuccessful(today); result.WorkingDirectory = Path.GetTempPath(); vss.AutoGetSource = true; vss.WorkingDirectory = "VSS"; vss.GetSource(result); Directory.Delete(expectedWorkingDirectory); }
public void SetUp() { sandboxRoot = TempFileUtil.GetTempPath("MksSandBox"); mockHistoryParserWrapper = new Mock <IHistoryParser>(); mockHistoryParser = (IHistoryParser)mockHistoryParserWrapper.Object; mksHistoryParserWrapper = new Mock <MksHistoryParser>(); mksHistoryParser = (MksHistoryParser)mksHistoryParserWrapper.Object; mockExecutorWrapper = new Mock <ProcessExecutor>(); mockProcessExecutor = (ProcessExecutor)mockExecutorWrapper.Object; mockIntegrationResult = new Mock <IIntegrationResult>(); integrationResult = (IIntegrationResult)mockIntegrationResult.Object; }
public void SetUp() { sandboxRoot = TempFileUtil.GetTempPath("MksSandBox"); mockHistoryParserWrapper = new DynamicMock(typeof(IHistoryParser)); mockHistoryParser = (IHistoryParser)mockHistoryParserWrapper.MockInstance; mksHistoryParserWrapper = new DynamicMock(typeof(MksHistoryParser)); mksHistoryParser = (MksHistoryParser)mksHistoryParserWrapper.MockInstance; mockExecutorWrapper = new DynamicMock(typeof(ProcessExecutor)); mockProcessExecutor = (ProcessExecutor)mockExecutorWrapper.MockInstance; mockIntegrationResult = new DynamicMock(typeof(IIntegrationResult)); integrationResult = (IIntegrationResult)mockIntegrationResult.MockInstance; }
public void GetSourceWithSpacesInSandbox() { sandboxRoot = TempFileUtil.GetTempPath("Mks Sand Box"); string expectedResyncCommand = string.Format(@"resync --overwriteChanged --restoreTimestamp --forceConfirm=yes --includeDropped -R -S ""{0}\myproject.pj"" --user=CCNetUser --password=CCNetPassword --quiet", sandboxRoot); mockExecutorWrapper.Setup(executor => executor.Execute(ExpectedProcessInfo(expectedResyncCommand))).Returns(new ProcessResult(null, null, 0, false)).Verifiable(); string expectedAttribCommand = string.Format(@"-R /s ""{0}\*""", sandboxRoot); mockExecutorWrapper.Setup(executor => executor.Execute(ExpectedProcessInfo("attrib", expectedAttribCommand))).Returns(new ProcessResult(null, null, 0, false)).Verifiable(); string expectedDisconnectCommand = string.Format(@"disconnect --user=CCNetUser --password=CCNetPassword --quiet --forceConfirm=yes"); ProcessInfo expectedDisconnectProcessInfo = ExpectedProcessInfo(expectedDisconnectCommand); mockExecutorWrapper.Setup(executor => executor.Execute(expectedDisconnectProcessInfo)).Returns(new ProcessResult(null, null, 0, false)).Verifiable(); mks = CreateMks(CreateSourceControlXml(), mockHistoryParser, mockProcessExecutor); mks.GetSource(new IntegrationResult()); }
private void AssertNumberOfFiles(int expectedFiles) { AssertEquals(expectedFiles, Directory.GetFiles(TempFileUtil.GetTempPath(TEMP_DIR)).Length); }
public void TestCreateTempDir() { TempFileUtil.CreateTempDir(TempDir); Assert.IsTrue(Directory.Exists(TempFileUtil.GetTempPath(TempDir))); TempFileUtil.DeleteTempDir(TempDir); }
public void TearDown() { TempFileUtil.DeleteTempDir(TempDir); Assert.IsTrue(!Directory.Exists(TempFileUtil.GetTempPath(TempDir))); }
public void SetUp() { TempFileUtil.DeleteTempDir(TempDir); Assert.IsTrue(!Directory.Exists(TempFileUtil.GetTempPath(TempDir)), "Temp folder exists before test!"); }