public void OpenedHandle() { using (var fs = new FileStream(state.ExistingFiles[0].FullName, FileMode.Append)) { var ctSource = new CancellationTokenSource(); var cpJob = new FileTransferJob( new FileTransferArguments(state.ExistingFiles[0], state.NonExistingFiles[0], TransferSettings.None), state.OnProgressDebugPrint , ctSource.Token); try { cpJob.Run(); } catch (FileTransferException e) { state.ExceptionThrown = true; Assert.IsTrue(e.InnerException is IOException); } Assert.IsTrue(state.ExceptionThrown); state.NonExistingFiles[0].Refresh(); Assert.IsFalse(state.NonExistingFiles[0].Exists); } }
public void DestinationFileExists() { File.WriteAllText(state.NonExistingFiles[0].FullName, "Oh this suddenly exists.."); var ctSource = new CancellationTokenSource(); var cpJob = new FileTransferJob( new FileTransferArguments(state.ExistingFiles[0], state.NonExistingFiles[0], TransferSettings.None), state.OnProgressDebugPrint , ctSource.Token); try { cpJob.Run(); } catch (FileTransferException e) { state.ExceptionThrown = true; Assert.IsTrue(e.InnerException is IOException); } Assert.IsTrue(state.ExceptionThrown); Assert.IsTrue(state.NonExistingFiles[0].Exists); Assert.AreNotEqual(File.ReadAllText(state.ExistingFiles[0].FullName), File.ReadAllText(state.NonExistingFiles[0].FullName)); }
public void SourceDoesNotExist() { var cts = new CancellationTokenSource(); var moveJob = new FileTransferJob( new FileTransferArguments(state.NonExistingFiles[0], state.NonExistingFiles[1], TransferSettings.DeleteOriginal), state.OnProgressDebugPrint , cts.Token); try { moveJob.Run(); } catch (FileTransferException e) { state.ExceptionThrown = true; Assert.IsTrue(e.InnerException is FileNotFoundException); } state.NonExistingFiles[1].Refresh(); Assert.IsFalse(state.NonExistingFiles[1].Exists); Assert.IsTrue(state.ExceptionThrown); }
public void DestinationWithoutRights() { var cts = new CancellationTokenSource(); var moveJob = new FileTransferJob( new FileTransferArguments(state.ExistingFiles[0], state.NonExistentFileWithoutRights, TransferSettings.DeleteOriginal), state.OnProgressDebugPrint , cts.Token); try { moveJob.Run(); } catch (FileTransferException e) { state.ExceptionThrown = true; Assert.IsTrue(e.InnerException is UnauthorizedAccessException); } state.ExistingFiles[0].Refresh(); state.NonExistentFileWithoutRights.Refresh(); Assert.IsTrue(state.ExceptionThrown); Assert.IsTrue(state.ExistingFiles[0].Exists); }
public void DestinationAlreadyExists() { var cts = new CancellationTokenSource(); var moveJob = new FileTransferJob( new FileTransferArguments(state.ExistingFiles[0], state.ExistingFiles[1], TransferSettings.DeleteOriginal), state.OnProgressDebugPrint , cts.Token); try { moveJob.Run(); } catch (FileTransferException e) { state.ExceptionThrown = true; Assert.IsTrue(e.InnerException is IOException); } state.ExistingFiles[0].Refresh(); state.ExistingFiles[1].Refresh(); Assert.IsTrue(state.ExceptionThrown); Assert.IsTrue(state.ExistingFiles[0].Exists); Assert.IsTrue(state.ExistingFiles[1].Exists); Assert.AreNotEqual(File.ReadAllText(state.ExistingFiles[0].FullName), File.ReadAllText(state.ExistingFiles[1].FullName)); }
public void RunSynchronously() { var ctSource = new CancellationTokenSource(); var cpJob = new FileTransferJob( new FileTransferArguments(state.ExistingFiles[0], state.NonExistingFiles[0], TransferSettings.None), state.OnProgressDebugPrint , ctSource.Token); cpJob.Run(); state.NonExistingFiles[0].Refresh(); Assert.IsTrue(state.NonExistingFiles[0].Exists); Assert.AreEqual(File.ReadAllText(state.ExistingFiles[0].FullName), File.ReadAllText(state.NonExistingFiles[0].FullName)); }
public void RunSynchornously() { string existingFileContent = File.ReadAllText(state.ExistingFiles[0].FullName); var cts = new CancellationTokenSource(); var moveJob = new FileTransferJob( new FileTransferArguments(state.ExistingFiles[0], state.NonExistingFiles[0], TransferSettings.DeleteOriginal), state.OnProgressDebugPrint , cts.Token); moveJob.Run(); state.NonExistingFiles[0].Refresh(); state.ExistingFiles[0].Refresh(); Assert.IsTrue(state.NonExistingFiles[0].Exists); Assert.IsFalse(state.ExistingFiles[0].Exists); Assert.AreEqual(existingFileContent, File.ReadAllText(state.NonExistingFiles[0].FullName)); }