public void if_original_file_exists_create_backup_number_one() { FileInfo fileInfo = CreateFile(); IFileBackup backup = new RollingFileBackup(fileInfo, 5); backup.Create(); List<FileInfo> files = GetFiles(); Assert.AreEqual(2, files.Count); }
public void if_there_is_currently_more_than_maxBackups_the_rest_are_deleted() { CreateFiles(10); Assert.AreEqual(11, GetFiles().Count); var backup = new RollingFileBackup(new FileInfo(GetFilePath()), 5); IEnumerable<IFileBackupInfo> versions = backup.Create(); Assert.AreEqual(5, versions.Count()); }
public void if_at_max_backups_only_keep_newest() { FileInfo file = CreateFile(); var backup = new RollingFileBackup(file, 5); IEnumerable<IFileBackupInfo> versions = new GenerationalFileBackupInfo[0]; for (int i = 0; i < 10; i++) { versions = backup.Create(); } List<FileInfo> files = GetFiles(); //original + 5 backups Assert.AreEqual(6, files.Count); Assert.AreEqual(5, versions.Count()); }
public void if_there_is_one_backup_move_number_one_to_number_two_and_create_number_one() { CreateFiles(1); string file = GetFilePath(); var backup = new RollingFileBackup(new FileInfo(file), 5); backup.Create(); List<FileInfo> files = GetFiles(); Assert.AreEqual(3, files.Count); }