public void CreateTempDir() { tempFolderFullPath = TempFileUtil.CreateTempDir(TEMP_FOLDER); //create mock files string rootLevelPath = TempFileUtil.CreateTempDir(Path.Combine(tempFolderFullPath, "RootLevel")); TempFileUtil.CreateTempFile(rootLevelPath, "FileB.txt"); string firstLevelAPath = TempFileUtil.CreateTempDir(Path.Combine(rootLevelPath, "FirstLevelA")); TempFileUtil.CreateTempFile(firstLevelAPath, "FileA.txt"); string firstLevelASecondLevelAPath = TempFileUtil.CreateTempDir(Path.Combine(firstLevelAPath, "SecondLevelA")); string firstLevelAThirdLevelAPath = TempFileUtil.CreateTempDir(Path.Combine(firstLevelASecondLevelAPath, "ThirdLevelA")); TempFileUtil.CreateTempFile(firstLevelAThirdLevelAPath, "FileA.txt"); string firstLevelBPath = TempFileUtil.CreateTempDir(Path.Combine(rootLevelPath, "FirstLevelB")); TempFileUtil.CreateTempFile(firstLevelBPath, "FileB.txt"); string firstLevelBSecondLevelAPath = TempFileUtil.CreateTempDir(Path.Combine(firstLevelBPath, "SecondLevelA")); TempFileUtil.CreateTempFile(firstLevelBSecondLevelAPath, "FileA.txt"); TempFileUtil.CreateTempFile(firstLevelBSecondLevelAPath, "FileB.txt"); string firstLevelBSecondLevelAThirdLevelAPath = TempFileUtil.CreateTempDir(Path.Combine(firstLevelBSecondLevelAPath, "ThirdLevelA")); TempFileUtil.CreateTempFile(firstLevelBSecondLevelAThirdLevelAPath, "FileA.txt"); TempFileUtil.CreateTempFile(firstLevelBSecondLevelAThirdLevelAPath, "FileB.txt"); string firstLevelBSecondLevelBPath = TempFileUtil.CreateTempDir(Path.Combine(firstLevelBPath, "SecondLevelB")); TempFileUtil.CreateTempFile(firstLevelBSecondLevelBPath, "FileA.txt"); }
protected void DeleteTempFile() { if (tempfile != null) { TempFileUtil.DeleteTempFile(tempfile); } }
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); }
protected void AddTraceListener() { tempfile = TempFileUtil.CreateTempFile(TempDir, "ccnet.log"); listener = new LogFileTraceListener(tempfile); backup = new TraceListenerBackup(); backup.AddTraceListener(listener); }
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 SetUp() { TempFileUtil.DeleteTempDir(FULL_CONFIGURED_LOG_DIR); TempFileUtil.DeleteTempDir(ARTIFACTS_DIR); TempFileUtil.CreateTempDir(ARTIFACTS_DIR); publisher = new XmlLogPublisher(); }
public void LoadConfiguration_BadXml() { FileInfo configFile = new FileInfo(TempFileUtil.CreateTempXmlFile(TempFileUtil.CreateTempDir(this), "loadernet.config" , "<test><a><b/></test>")); Assert.That(delegate { fileLoader.LoadConfiguration(configFile); }, Throws.TypeOf <ConfigurationException>()); }
public void SetUp() { TempFileUtil.DeleteTempDir(FULL_CONFIGURED_LOG_DIR); TempFileUtil.DeleteTempDir(ARTIFACTS_DIR); TempFileUtil.CreateTempDir(ARTIFACTS_DIR); publisher = new ModificationHistoryPublisher(); }
protected CruiseManager CreateCCServer() { string configData = ConfigurationFixture.GenerateConfigXml(GenerateProjectXml()); string tempFile = TempFileUtil.CreateTempFile(TEMP_DIR, TEMP_FILE, configData); CruiseManager cc = new CruiseManager(tempFile); return(cc); }
public void Setup() { processExecutorMock = new DynamicMock(typeof(ProcessExecutor)); processInfoCreatorMock = new DynamicMock(typeof(IP4ProcessInfoCreator)); p4Purger = new ProcessP4Purger((ProcessExecutor)processExecutorMock.MockInstance, (IP4ProcessInfoCreator)processInfoCreatorMock.MockInstance); tempDirPath = TempFileUtil.CreateTempDir("tempDir"); }
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); }
public void Setup() { processExecutorMock = new Mock <ProcessExecutor>(); processInfoCreatorMock = new Mock <IP4ProcessInfoCreator>(); p4Purger = new ProcessP4Purger((ProcessExecutor)processExecutorMock.Object, (IP4ProcessInfoCreator)processInfoCreatorMock.Object); tempDirPath = TempFileUtil.CreateTempDir("tempDir"); }
public void ShouldFailWhenInputInvalid() { string input = @"<This is some invalid xml"; string xslfile = TempFileUtil.CreateTempXmlFile(TestFolder, "samplestylesheet.xsl", TestData.StyleSheetContents); Assert.That(delegate { new XslTransformer().Transform(input, xslfile, null); }, Throws.TypeOf <CruiseControlException>()); }
public void LoadConfigurationFile() { string xml = "<cruisecontrol />"; FileInfo configFile = new FileInfo(TempFileUtil.CreateTempXmlFile(TempFileUtil.CreateTempDir(this), "loadernet.config", xml)); XmlDocument config = fileLoader.LoadConfiguration(configFile); Assert.IsNotNull(config); Assert.AreEqual(xml, config.OuterXml); }
protected void TearDown() { Verify(); mockHistoryParser.Verify(); mockFileSystem.Verify(); mockFileDirectoryDeleter.Verify(); TempFileUtil.DeleteTempDir(tempWorkDir); TempFileUtil.DeleteTempDir(tempHgDir); }
public void ShouldFailOnFailedProcessResult() { TempFileUtil.CreateTempXmlFile(string.Format(logfile, task.LogFileId), "<output/>"); ExpectToExecuteAndReturn(FailedProcessResult()); task.Run(result); Assert.AreEqual(2, result.TaskResults.Count); Assert.AreEqual("<output/>" + ProcessResultOutput, result.TaskOutput); Assert.IsTrue(result.Failed); }
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 ShouldAutomaticallyMergeTheBuildOutputFile() { TempFileUtil.CreateTempXmlFile(string.Format(logfile, task.LogFileId), "<output/>"); ExpectToExecuteAndReturn(SuccessfulProcessResult()); task.Run(result); Assert.AreEqual(2, result.TaskResults.Count); Assert.That(result.TaskOutput, Is.EqualTo("<output/>")); Assert.IsTrue(result.Succeeded); }
public void ShouldTransformData() { string input = TestData.LogFileContents; string xslfile = TempFileUtil.CreateTempXmlFile(TestFolder, "samplestylesheet.xsl", TestData.StyleSheetContents); string output = new XslTransformer().Transform(input, xslfile, null); Assert.IsNotNull(output); Assert.IsTrue(!String.Empty.Equals(output), "Transform returned no data"); }
public void ShouldFailOnFailedProcessResult() { AddDefaultAssemblyToCheck(task); TempFileUtil.CreateTempXmlFile(logfile, "<output/>"); ExpectToExecuteAndReturn(FailedProcessResult()); task.Run(result); Assert.AreEqual(1, result.TaskResults.Count); Assert.That(result.TaskOutput, Is.EqualTo(ProcessResultOutput)); Assert.IsTrue(result.Failed); }
public void ShouldAutomaticallyMergeTheBuildOutputFile() { AddDefaultAssemblyToCheck(task); TempFileUtil.CreateTempXmlFile(logfile, "<output/>"); ExpectToExecuteAndReturn(SuccessfulProcessResult()); task.Run(result); Assert.AreEqual(1, result.TaskResults.Count); Assert.That(result.TaskOutput, Is.Empty); Assert.IsTrue(result.Succeeded); }
protected void SetUp() { CreateProcessExecutorMock(GendarmeTask.defaultExecutable); result = IntegrationResult(); result.Label = "1.0"; result.ArtifactDirectory = Path.GetTempPath(); logfile = Path.Combine(result.ArtifactDirectory, GendarmeTask.logFilename); TempFileUtil.DeleteTempFile(logfile); task = new GendarmeTask((ProcessExecutor)mockProcessExecutor.MockInstance); }
public void TestCreateTempXmlDoc() { TempFileUtil.CreateTempDir(TempDir); string path = TempFileUtil.CreateTempXmlFile(TempDir, "foobar.xml", "<test />"); Assert.IsTrue(File.Exists(path)); XmlDocument doc = new XmlDocument(); doc.Load(path); }
public void IfExecutableIsFoundInWorkingDirectoryThenUseCombinedPathAsExecutablePath() { string workingDir = TempFileUtil.CreateTempDir("working"); string executablePath = TempFileUtil.CreateTempFile("working", "myExecutable"); ProcessInfo infoWithoutPathQualifiedExecutable = new ProcessInfo("myExecutable", "", workingDir); ProcessInfo infoWithPreQualifiedExecutable = new ProcessInfo(executablePath, "", workingDir); Assert.AreEqual(infoWithPreQualifiedExecutable, infoWithoutPathQualifiedExecutable); }
/// <summary> /// Gets a <see cref="Stream"/> that automatically cleans up /// after itself. /// </summary> /// <returns>A stream that allows to write and read temporary /// data.</returns> public TempStream CreateTempStream() { //create unique file name using a GUID string fileName = Guid.NewGuid().ToString(); var tempFilePath = TempFileUtil.CreateTempFilePath(TempFileRootDirectory, fileName, "tmp"); //return temp stream var fi = new FileInfo(tempFilePath); return(new TempFileStream(fi)); }
public void CreateTempFileWithContent() { string expected = "hello my name is rosebud"; string path = TempFileUtil.CreateTempFile(TempDir, "TestCreateTempFile_withContent.txt", expected); Assert.IsTrue(File.Exists(path)); using (StreamReader stream = File.OpenText(path)) { Assert.AreEqual(expected, stream.ReadToEnd()); } }
public void StringWithPrefixAndWildcardsReturnsAllMatchingFiles() { string tempFile1Path = TempFileUtil.CreateTempFile(TEMP_FOLDER, "prefix-foo.txt", "foofoo"); string tempFile2Path = TempFileUtil.CreateTempFile(TEMP_FOLDER, "prefix-bar.txt", "barbar"); WildCardPath wildCard = new WildCardPath(Path.Combine(tempFolderFullPath, "prefix-*.txt")); IList files = wildCard.GetFiles(); Assert.AreEqual(2, files.Count); AssertListContainsPath(files, tempFile2Path); AssertListContainsPath(files, tempFile1Path); }
public void ShouldPassThroughXSLTArgs() { string input = TestData.LogFileContents; string xslfile = TempFileUtil.CreateTempXmlFile(TestFolder, "samplestylesheet.xsl", TestData.StyleSheetContentsWithParam); Hashtable xsltArgs = new Hashtable(); xsltArgs["myParam"] = "myValue"; string output = new XslTransformer().Transform(input, xslfile, xsltArgs); Assert.IsTrue(output.IndexOf("myValue") > 0); }
public void ShouldHandleArtifactDirectoryNotExisting() { // Setup mockSourceControl.ExpectNoCall("Purge", typeof(IProject)); TempFileUtil.DeleteTempDir("artifactDir"); Assert.IsFalse(Directory.Exists(artifactDirPath)); // Execute project.Purge(false, true, false); // Verify VerifyAll(); }