Ejemplo n.º 1
0
        public void ShouldCopyFileToDirectory()
        {
            SystemPath file1 = tempRoot.CreateEmptyFile("File1");

            new SystemIoFileSystem().Copy(file1.ToString(), tempSubRoot.ToString());
            Assert.IsTrue(tempSubRoot.Combine("File1").Exists());
        }
Ejemplo n.º 2
0
        public void ShouldCopyDirectoryToDirectoryRecursively()
        {
            tempRoot.CreateEmptyFile("File1");
            tempSubRoot.CreateEmptyFile("File2");
            new SystemIoFileSystem().Copy(tempRoot.ToString(), tempOtherRoot.ToString());

            Assert.IsTrue(tempOtherRoot.Combine("File1").Exists());
            Assert.IsTrue(tempOtherRoot.Combine("subrepo").Combine("File2").Exists());
        }
Ejemplo n.º 3
0
        public void ShouldSaveToFile()
        {
            SystemPath tempFile = tempRoot.Combine("foo.txt");

            Assert.IsFalse(tempFile.Exists());
            new SystemIoFileSystem().Save(tempFile.ToString(), "bar");
            Assert.IsTrue(tempFile.Exists());
            using (StreamReader reader = File.OpenText(tempFile.ToString()))
            {
                Assert.AreEqual("bar", reader.ReadToEnd());
            }
        }
Ejemplo n.º 4
0
        public static void AppendText(SaveLocation saveLocation, string relativePath, string content)
        {
            var path = SystemPath.Combine(_saveLocations[saveLocation], relativePath).AbsolutePath;

            Directory.CreateDirectory(Path.GetDirectoryName(path));
            File.AppendAllText(path, content);
        }
        public void CopyFiles()
        {
            SystemPath subRoot    = srcRoot.CreateSubDirectory("SubDir");
            SystemPath subSubRoot = subRoot.CreateSubDirectory("SubSubDir");

            srcRoot.CreateTextFile(fileName, fileContents);
            subRoot.CreateTextFile(fileName, fileContents);
            subSubRoot.CreateTextFile(fileName, fileContents);

            publisher.Run(result);

            Assert.IsTrue(labelPubDir.Combine(fileName).Exists(), "File not found in build number directory");
            SystemPath subPubDir = labelPubDir.Combine("SubDir");

            Assert.IsTrue(subPubDir.Combine(fileName).Exists(), "File not found in sub directory");
            Assert.IsTrue(subPubDir.Combine("SubSubDir").Combine(fileName).Exists(), "File not found in sub sub directory");
        }
Ejemplo n.º 6
0
        public void SetUp()
        {
            fileSystemMock = new Mock <IFileSystem>();

            tempRoot    = SystemPath.UniqueTempPath();
            tempSubRoot = tempRoot.Combine("subrepo");

            sc = new FileSourceControl((IFileSystem)fileSystemMock.Object);
            sc.RepositoryRoot = tempRoot.ToString();
        }
Ejemplo n.º 7
0
        public void SetUp()
        {
            fileSystemMock = new DynamicMock(typeof(IFileSystem));

            tempRoot    = SystemPath.UniqueTempPath();
            tempSubRoot = tempRoot.Combine("subrepo");

            sc = new FileSourceControl((IFileSystem)fileSystemMock.MockInstance);
            sc.RepositoryRoot = tempRoot.ToString();
        }
        public void ShouldNotCopyFilesIfBuildBrokenAndAlwaysCopyIsSetToFalse()
        {
            SystemPath subRoot    = srcRoot.CreateSubDirectory("SubDir");
            SystemPath subSubRoot = subRoot.CreateSubDirectory("SubSubDir");

            srcRoot.CreateTextFile(fileName, fileContents);
            subRoot.CreateTextFile(fileName, fileContents);
            subSubRoot.CreateTextFile(fileName, fileContents);

            result = IntegrationResultMother.CreateFailed("99");

            publisher.Run(result);

            Assert.IsFalse(labelPubDir.Combine(fileName).Exists(), "File found in build number directory");
            SystemPath subPubDir = labelPubDir.Combine("SubDir");

            Assert.IsFalse(subPubDir.Combine(fileName).Exists(), "File found in sub directory");
            Assert.IsFalse(subPubDir.Combine("SubSubDir").Combine(fileName).Exists(), "File found in sub sub directory");
        }
        public void SetUp()
        {
            srcRoot = SystemPath.UniqueTempPath();
            pubRoot = SystemPath.UniqueTempPath();

            publisher            = new BuildPublisher();
            publisher.PublishDir = pubRoot.ToString();
            publisher.SourceDir  = srcRoot.ToString();
            result      = IntegrationResultMother.CreateSuccessful("99");
            labelPubDir = pubRoot.Combine("99");
        }
        public void PublishDirShouldBeRelativeToIntegrationArtifactDirectory()
        {
            srcRoot.CreateSubDirectory("foo").CreateTextFile(fileName, fileContents);
            result.ArtifactDirectory = pubRoot.ToString();

            publisher.PublishDir = "bar";
            publisher.Run(result);

            labelPubDir = pubRoot.Combine("bar").Combine("99").Combine("foo");
            Assert.IsTrue(labelPubDir.Combine(fileName).Exists(), "File not found in build number directory");
        }
        public void DeleteFilesAtPublishFolderWhenCleanPublishDirPriorToCopyIsTrue()
        {
            SystemPath rootFile = srcRoot.CreateDirectory().CreateTextFile(fileName, fileContents);

            publisher.UseLabelSubDirectory = false;
            publisher.Run(result);

            Assert.IsTrue(pubRoot.Combine(fileName).Exists(), "File not found in publish folder");

            // simulate deletion of a file
            rootFile.DeleteFile();
            Assert.IsFalse(srcRoot.Combine(fileName).Exists(), "File found in root folder");


            // publish again
            publisher.CleanPublishDirPriorToCopy = true;
            publisher.Run(result);


            Assert.IsFalse(pubRoot.Combine(fileName).Exists(), "File found in publish folder");
        }
Ejemplo n.º 12
0
 public static string Combine(string path1, string path2, string path3, string path4)
 {
     return(SystemPath.Combine(path1, path2, path3, path4));
 }
Ejemplo n.º 13
0
 public static string Combine(params string[] paths)
 {
     return(SystemPath.Combine(paths));
 }
Ejemplo n.º 14
0
 public static string GetPath(SaveLocation saveLocation, string relativePath)
 {
     return(saveLocation != SaveLocation.Absolute
         ? SystemPath.Combine(_saveLocations[saveLocation], relativePath).AbsolutePath
         : SystemPath.Create(relativePath).AbsolutePath);
 }