Exemple #1
0
        public void CopyDirectoryContnet_SourceDirDoesNotExist_ThrowsDirectoryNotFoundException()
        {
            var sourceDir = fileSystem.DirectoryInfo.FromDirectoryName(@"D:\not");
            var destDir   = fileSystem.DirectoryInfo.FromDirectoryName(@"C:\Archive");

            Assert.That(() => Copier.CopyDirectoryContent(sourceDir, destDir, fileSystem),
                        Throws.TypeOf(typeof(DirectoryNotFoundException)));
        }
Exemple #2
0
        public void CopyDirectoryContnet_UsualCase_CorrectAmountOfCopiedFilesReturned()
        {
            var sourceDir = fileSystem.DirectoryInfo.FromDirectoryName(@"C:\source1");
            var destDir   = fileSystem.Directory.CreateDirectory(@"C:\Archive\source1_copy");

            (int success, _) = Copier.CopyDirectoryContent(sourceDir, destDir, fileSystem);
            int sourceFilesAmount = fileSystem.Directory.EnumerateFiles(destDir.FullName, "*", SearchOption.AllDirectories).Count();

            Assert.That(sourceFilesAmount == success);
        }
Exemple #3
0
        public void CopyDirectoryContnet_SourceDirectoryHasSystemFiles_NoExceptions()
        {
            var file = fileSystem.FileInfo.FromFileName(@"C:\source1\file.bin");

            file.Attributes = FileAttributes.System | FileAttributes.ReadOnly;
            var destDir   = fileSystem.Directory.CreateDirectory(@"C:\Archive\source1");
            var sourceDir = fileSystem.DirectoryInfo.FromDirectoryName(@"C:\source1");
            var a         = destDir.GetDirectories();

            Assert.DoesNotThrow(() => Copier.CopyDirectoryContent(sourceDir, destDir, fileSystem));
        }
Exemple #4
0
        public void CopyDirectoryContnet_DestDirIsSubdirOfSourceDir_NoEndlessLoop()
        {
            fileSystem.AddFile(@"C:\Archive\1.txt", new MockFileData(new string('0', 1000)));
            fileSystem.AddFile(@"C:\Archive\1\1.txt", new MockFileData(new string('0', 1000)));
            fileSystem.AddFile(@"C:\Archive\1\1.txt", new MockFileData(new string('0', 1000)));
            fileSystem.AddFile(@"C:\Archive\2\1.txt", new MockFileData(new string('0', 1000)));
            var destDir   = fileSystem.DirectoryInfo.FromDirectoryName(@"C:\Archive\dest");
            var sourceDir = fileSystem.DirectoryInfo.FromDirectoryName(@"C:\Archive");

            Assert.DoesNotThrow(() => Copier.CopyDirectoryContent(sourceDir, destDir, fileSystem));
        }