public void Execute_NoPreviousBackup_CreatesZippedFileWithNameCreatedFromLastDir() { string zippedBackupFileName = Path.Combine(Environment.CurrentDirectory, string.Format("{0}\\{1}.bak.000.zip", _workingDir, DstSubDir)); var backupFilesDeploymentStep = new BackupFilesDeploymentStep(_dstDir); backupFilesDeploymentStep.Prepare(); backupFilesDeploymentStep.Execute(); var fileInfo = new FileInfo(zippedBackupFileName); Assert.IsTrue(fileInfo.Exists); }
public void Execute_PreviousBackupExistAndFilesRotationOn_CreatesNewBackupAndMovingOldOne() { const int maxBackupCount = 4; var backupFilesDeploymentStep = new BackupFilesDeploymentStep(_dstDir, maxBackupCount); backupFilesDeploymentStep.Prepare(); for (int i = 0; i < maxBackupCount + 1; i++) { backupFilesDeploymentStep.Execute(); Thread.Sleep(50); } string[] files = Directory.GetFiles(_workingDir); Array.Sort(files); for (int fileIndex = 0; fileIndex < files.Length - 2; fileIndex++) { Assert.Greater(new FileInfo(files[fileIndex]).LastWriteTime, new FileInfo(files[fileIndex + 1]).LastWriteTime); } Assert.AreEqual(4, files.Length); }