public async Task TestWipeWithConfirmAll() { ProgressContext progress = new ProgressContext(); FileOperationsController controller = new FileOperationsController(progress); int confirmationCount = 0; controller.WipeQueryConfirmation += (object sender, FileOperationEventArgs e) => { if (confirmationCount++ > 0) { throw new InvalidOperationException("The event should not be raised a second time."); } e.ConfirmAll = true; }; progress.NotifyLevelStart(); FileOperationContext status = await controller.WipeFileAsync(New <IDataStore>(_helloWorldAxxPath)); Assert.That(status.ErrorStatus, Is.EqualTo(ErrorStatus.Success), "The wipe should indicate success."); IDataStore fileInfo = New <IDataStore>(_helloWorldAxxPath); Assert.That(!fileInfo.IsAvailable, "The file should not exist after wiping."); Assert.DoesNotThrowAsync(async() => { status = await controller.WipeFileAsync(New <IDataStore>(_davidCopperfieldTxtPath)); }); Assert.That(status.ErrorStatus, Is.EqualTo(ErrorStatus.Success), "The wipe should indicate success."); progress.NotifyLevelFinished(); fileInfo = New <IDataStore>(_davidCopperfieldTxtPath); Assert.That(!fileInfo.IsAvailable, "The file should not exist after wiping."); }
public void TestSimpleWipeOnThreadWorker() { FileOperationsController controller = new FileOperationsController(); controller.WipeQueryConfirmation += (object sender, FileOperationEventArgs e) => { e.Cancel = false; e.Skip = false; e.ConfirmAll = false; }; string destinationPath = String.Empty; FileOperationContext status = new FileOperationContext(String.Empty, ErrorStatus.Unknown); controller.Completed += (object sender, FileOperationEventArgs e) => { destinationPath = e.SaveFileFullName; status = e.Status; }; controller.WipeFileAsync(New <IDataStore>(_davidCopperfieldTxtPath)); Assert.That(status.ErrorStatus, Is.EqualTo(ErrorStatus.Success), "The status should indicate success."); IDataStore destinationInfo = New <IDataStore>(destinationPath); Assert.That(!destinationInfo.IsAvailable, "After wiping the destination file should not exist."); }
private Task <FileOperationContext> WipeFileWorkAsync(IDataStore file, IProgressContext progress) { FileOperationsController operationsController = new FileOperationsController(progress); operationsController.WipeQueryConfirmation += (object sender, FileOperationEventArgs e) => { FileSelectionEventArgs fileSelectionArgs = new FileSelectionEventArgs(new string[] { file.FullName, }) { FileSelectionType = FileSelectionType.WipeConfirm, }; OnSelectingFiles(fileSelectionArgs); e.Cancel = fileSelectionArgs.Cancel; e.Skip = fileSelectionArgs.Skip; e.ConfirmAll = fileSelectionArgs.ConfirmAll; e.SaveFileFullName = fileSelectionArgs.SelectedFiles.FirstOrDefault() ?? String.Empty; }; operationsController.Completed += async(object sender, FileOperationEventArgs e) => { if (e.Skip) { return; } if (e.Status.ErrorStatus == ErrorStatus.Success) { await New <ActiveFileAction>().RemoveRecentFiles(new IDataStore[] { New <IDataStore>(e.SaveFileFullName) }, progress); } }; return(operationsController.WipeFileAsync(file)); }
public async Task TestWipeWithSkip() { FileOperationsController controller = new FileOperationsController(); controller.WipeQueryConfirmation += (object sender, FileOperationEventArgs e) => { e.Skip = true; }; FileOperationContext status = await controller.WipeFileAsync(New <IDataStore>(_helloWorldAxxPath)); Assert.That(status.ErrorStatus, Is.EqualTo(ErrorStatus.Success), "The wipe should indicate success even when skipping."); IDataStore fileInfo = New <IDataStore>(_helloWorldAxxPath); Assert.That(fileInfo.IsAvailable, "The file should still exist after wiping that was skipped during confirmation."); }
public async Task TestSimpleWipe() { FileOperationsController controller = new FileOperationsController(); controller.WipeQueryConfirmation += (object sender, FileOperationEventArgs e) => { e.Cancel = false; e.Skip = false; e.ConfirmAll = false; }; FileOperationContext status = await controller.WipeFileAsync(New <IDataStore>(_helloWorldAxxPath)); Assert.That(status.ErrorStatus, Is.EqualTo(ErrorStatus.Success), "The wipe should indicate success."); IDataStore fileInfo = New <IDataStore>(_helloWorldAxxPath); Assert.That(!fileInfo.IsAvailable, "The file should not exist after wiping."); }