Пример #1
0
        public void CreateDirectoryWithTimeStamp_DestDirDoesntExist_CreatesDirectory()
        {
            var destDir = fileSystem.DirectoryInfo.FromDirectoryName(@"C:\fake");

            Assert.DoesNotThrow(() => Copier.CreateDirectoryWithTimeStamp(destDir, "test", "'_'", fileSystem));
            Assert.That(fileSystem.Directory.Exists(destDir.FullName));
        }
Пример #2
0
        public void CreateDirectoryWithTimeStamp_NameIsTooLong_ThrowsPathTooLongException()
        {
            var longName = new string('1', 360);

            var destDir = fileSystem.Directory.CreateDirectory($"C:\\destDir");

            Assert.That(() => Copier.CreateDirectoryWithTimeStamp(destDir, longName, "'_'", fileSystem),
                        Throws.TypeOf(typeof(PathTooLongException)));
        }
Пример #3
0
        public void CreateDirectoryWithTimeStamp_DirAlreadyExists_CreateDirWithSuffix()
        {
            var destDir = fileSystem.DirectoryInfo.FromDirectoryName(@"C:\Archive");

            fileSystem.AddDirectory(@"C:\Archive\test_");

            var d = Copier.CreateDirectoryWithTimeStamp(destDir, "test", "'_'", fileSystem);

            Assert.That(d.Name == "test_ (1)");
        }
Пример #4
0
        public void CreateDirectoryWithTimeStamp_AllDirsAlreadyExist_ThrowsDuplicateNameException()
        {
            var destDir = fileSystem.DirectoryInfo.FromDirectoryName(@"C:\Archive");
            var path    = @"C:\Archive\test_";

            fileSystem.AddDirectory(path);

            for (int i = 1; i <= 1000; i++)
            {
                fileSystem.AddDirectory($"{path} ({i})");
            }

            Assert.That(() => Copier.CreateDirectoryWithTimeStamp(destDir, "test", "'_'", fileSystem),
                        Throws.TypeOf(typeof(DuplicateNameException)));
        }