public async void FilesInDirectoryBackedUp() { var sourceDir = "source"; var backupDir = "backup"; var fileToBackup = "file"; await _fs.CreateDirectory(sourceDir); await _fs.CreateFile(_fs.CombinePath(sourceDir, fileToBackup), new byte[0]); await _backup.Dump(sourceDir, backupDir); Assert.True(await _fs.IsDirectoryExists(backupDir)); Assert.True(await _fs.IsFileExists(_fs.CombinePath(backupDir, sourceDir, fileToBackup))); }
public async void FilesInDirectoryBackedUpWithHistory() { var sourceDir = "source"; var backupDir = "backup"; var fileToBackup = "file"; var firstContent = new byte[0]; var secondContent = new byte[] { 42 }; // Ordinary case await _fs.CreateDirectory(sourceDir); await _fs.CreateFile(_fs.CombinePath(sourceDir, fileToBackup), firstContent); await _backup.Dump(sourceDir, backupDir); // Modify file await _fs.DeleteFile(fileToBackup); await _fs.CreateFile(fileToBackup, secondContent); await _backup.Dump(sourceDir, backupDir); // Latest file must exists Assert.True(await _fs.IsFileExists(_fs.CombinePath(backupDir, sourceDir, fileToBackup))); Assert.Equal(secondContent, await _fs.ReadAllBytes(fileToBackup)); // First file must exists in history var historyDirName = _history.ConvertFileNameToHistoryDirectoryName(fileToBackup); var historyDirPath = _fs.CombinePath(backupDir, sourceDir, historyDirName); Assert.True(await _fs.IsDirectoryExists(historyDirPath)); var filesInside = (await _fs.GetFiles(historyDirPath)).ToList(); Assert.True(filesInside.Count == 1); var fileName = filesInside[0]; var contentInHistory = await _fs.ReadAllBytes(_fs.CombinePath(backupDir, sourceDir, historyDirName, fileName)); Assert.Equal(firstContent, contentInHistory); }