Beispiel #1
0
        public void MakeCopies_SourceDirsListIsEmpty_NoCopiesMade()
        {
            var destDir    = fileSystem.DirectoryInfo.FromDirectoryName(@"C:\Archive");
            var sourceDirs = new List <IDirectoryInfo>();

            Assert.DoesNotThrow(() => Copier.MakeCopies(sourceDirs, destDir, "HH-mm-ss", fileSystem));
            Assert.That(destDir.GetDirectories(), Is.Empty);
            Assert.That(destDir.GetFiles(), Is.Empty);
        }
Beispiel #2
0
        public void MakeCopies_SourceDirIsDestDir_NoEndlessLoop()
        {
            var destDir    = fileSystem.DirectoryInfo.FromDirectoryName(@"C:\Archive");
            var sourceDirs = new List <IDirectoryInfo>
            {
                fileSystem.DirectoryInfo.FromDirectoryName(@"C:\Archive")
            };

            Assert.DoesNotThrow(() => Copier.MakeCopies(sourceDirs, destDir, "HH-mm-ss", fileSystem));
        }
Beispiel #3
0
        public void MakeCopies_SourceListHasInvalidDirs_InvalidDirSkipped()
        {
            var destDir    = fileSystem.DirectoryInfo.FromDirectoryName(@"C:\Archive");
            var sourceDirs = new List <IDirectoryInfo>
            {
                fileSystem.DirectoryInfo.FromDirectoryName(@"C:\source1"),
                fileSystem.DirectoryInfo.FromDirectoryName(@"C:\source2"),
                fileSystem.DirectoryInfo.FromDirectoryName(@"C:\source_invalid"),
            };

            Assert.DoesNotThrow(() => Copier.MakeCopies(sourceDirs, destDir, "'_copy'", fileSystem));
            Assert.That(destDir.GetDirectories().Length == sourceDirs.Count - 1);
        }
Beispiel #4
0
        public void MakeCopies_UsualCase_AllDirsCopied()
        {
            var destDir    = fileSystem.DirectoryInfo.FromDirectoryName(@"C:\Archive");
            var sourceDirs = new List <IDirectoryInfo>
            {
                fileSystem.DirectoryInfo.FromDirectoryName(@"C:\source1"),
                fileSystem.DirectoryInfo.FromDirectoryName(@"C:\source2"),
                fileSystem.DirectoryInfo.FromDirectoryName(@"C:\source3"),
            };

            Copier.MakeCopies(sourceDirs, destDir, "'_copy'", fileSystem);

            Assert.That(destDir.GetDirectories().Length == sourceDirs.Count);
            Assert.That(destDir.GetFiles(), Is.Empty);
        }
Beispiel #5
0
        public void MakeCopies_PathToNewDirectoryIsTooLong_SkipsThatDirectory()
        {
            var longName   = new string('1', 252);
            var destDir    = fileSystem.DirectoryInfo.FromDirectoryName(@"C:\Archive");
            var sourceDirs = new List <IDirectoryInfo>
            {
                fileSystem.Directory.CreateDirectory($"C:\\source1_copy\\{longName}"),
                fileSystem.Directory.CreateDirectory($"C:\\source2_copy\\short_name"),
                fileSystem.Directory.CreateDirectory($"C:\\source3_copy\\short_name2"),
                fileSystem.Directory.CreateDirectory($"C:\\source4_copy\\{longName}_2"),
            };

            var dict = Copier.MakeCopies(sourceDirs, destDir, "HH-mm-ss", fileSystem);

            Assert.That(dict.Count == 2);
        }