private static void WriteFile(string path, byte[] contents) { using (FileStream fileStream = SystemIO.IO_OS.FileOpenWrite(path)) { Utility.CopyStream(new MemoryStream(contents), fileStream); } }
public void LongPath() { string folderPath = Path.Combine(this.DATAFOLDER, new string('x', 10)); SystemIO.IO_OS.DirectoryCreate(folderPath); string fileName = new string('y', 255); string filePath = SystemIO.IO_OS.PathCombine(folderPath, fileName); byte[] fileBytes = { 0, 1, 2 }; WriteFile(filePath, fileBytes); Dictionary <string, string> options = new Dictionary <string, string>(this.TestOptions); using (Controller c = new Controller("file://" + this.TARGETFOLDER, options, null)) { IBackupResults backupResults = c.Backup(new[] { this.DATAFOLDER }); Assert.AreEqual(0, backupResults.Errors.Count()); Assert.AreEqual(0, backupResults.Warnings.Count()); } Dictionary <string, string> restoreOptions = new Dictionary <string, string>(this.TestOptions) { ["restore-path"] = this.RESTOREFOLDER }; using (Controller c = new Controller("file://" + this.TARGETFOLDER, restoreOptions, null)) { IRestoreResults restoreResults = c.Restore(new[] { filePath }); Assert.AreEqual(0, restoreResults.Errors.Count()); Assert.AreEqual(0, restoreResults.Warnings.Count()); } string restoreFilePath = SystemIO.IO_OS.PathCombine(this.RESTOREFOLDER, fileName); Assert.IsTrue(SystemIO.IO_OS.FileExists(restoreFilePath)); MemoryStream restoredStream = new MemoryStream(); using (FileStream fileStream = SystemIO.IO_OS.FileOpenRead(restoreFilePath)) { Utility.CopyStream(fileStream, restoredStream); } Assert.AreEqual(fileBytes, restoredStream.ToArray()); }