public void task_file_cannot_be_deleted_but_then_modified_to_retry() { _queue.DeleteTaskFileAfterImport = true; var attribute = File.GetAttributes(_pathToTask); File.SetAttributes(_pathToTask, attribute | FileAttributes.ReadOnly); _queue.PollFileSystem(); Assert.That(File.Exists(_pathToTask), Is.True); //file cannot be deleted _commandBus.Received(1).Send(Arg.Any <ICommand>(), "import-from-file"); _queue.PollFileSystem(); _commandBus.Received(1).Send(Arg.Any <ICommand>(), "import-from-file"); attribute = File.GetAttributes(_pathToTask); File.SetAttributes(_pathToTask, attribute & ~FileAttributes.ReadOnly); File.SetLastWriteTime(_pathToTask, DateTime.UtcNow); _queue.PollFileSystem(); _commandBus.Received(2).Send(Arg.Any <ICommand>(), "import-from-file"); }