public void RunSynchronously() { CancellationTokenSource cts = new CancellationTokenSource(); var delJob = new DeleteJob(new DeleteJobArguments(state.ExistingFiles[0]), state.OnProgressDebugPrint, cts.Token); delJob.Run(); state.ExistingFiles[0].Refresh(); Assert.IsFalse(state.ExistingFiles[0].Exists); }
public void DeleteNonEmptyDirectory() { var cts = new CancellationTokenSource(); var job = new DeleteJob(new DeleteJobArguments(state.ExistingNonEmptyDirectories[0], true), cts.Token); job.Run(); state.ExistingNonEmptyDirectories[0].Refresh(); Assert.IsFalse(state.ExistingNonEmptyDirectories[0].Exists); }
public void TargetDoesNotExist() { CancellationTokenSource cts = new CancellationTokenSource(); var delJob = new DeleteJob( new DeleteJobArguments(state.NonExistingFiles[0]), state.OnProgressDebugPrint , cts.Token); try { delJob.Run(); } catch (DeleteException e) { state.ExceptionThrown = true; Assert.IsTrue(e.InnerException is FileNotFoundException); } Assert.IsTrue(state.ExceptionThrown); }
public void TargetWithoutRights() { CancellationTokenSource cts = new CancellationTokenSource(); var delJob = new DeleteJob(new DeleteJobArguments(state.ExistentFileWithoutRights), state.OnProgressDebugPrint, cts.Token); try { delJob.Run(); } catch (DeleteException e) { state.ExceptionThrown = true; Assert.IsTrue(e.InnerException is UnauthorizedAccessException); } state.ExistentFileWithoutRights.Refresh(); Assert.IsTrue(state.ExistentFileWithoutRights.Exists); Assert.IsTrue(state.ExceptionThrown); }
public void OpenedHandle() { using (var fs = new FileStream(state.ExistingFiles[0].FullName, FileMode.Open)) { CancellationTokenSource cts = new CancellationTokenSource(); var delJob = new DeleteJob(new DeleteJobArguments(state.ExistingFiles[0]), state.OnProgressDebugPrint, cts.Token); try { delJob.Run(); } catch (DeleteException e) { state.ExceptionThrown = true; Assert.IsTrue(e.InnerException is IOException); } Assert.IsTrue(state.ExceptionThrown); state.ExistingFiles[0].Refresh(); Assert.IsTrue(state.ExistingFiles[0].Exists); } }