public void UnreadableDatabaseFileExceptionTest() { UnreadableDatabaseFileException ex = new UnreadableDatabaseFileException("C:\\somepath\\sms.db"); UnreadableDatabaseFileException exUnserialized = (UnreadableDatabaseFileException)SerializeUnserialize(ex); Assert.AreEqual(ex.Filename, exUnserialized.Filename); }
public DatabaseErrorDialog(BackupDatabaseReadException ex) { InitializeComponent(); Loaded += delegate { if ((ex is MissingBackupPathException) || (ex is MissingBackupFileException) || (ex is NoBackupsFoundException)) { errorDetailTextBox.Text = string.Format(MissingDatabaseError, ex.Message); troubleshootingLink.Visibility = Visibility.Visible; } else if (ex is UnreadableDatabaseFileException) { UnreadableDatabaseFileException unreadableDatabaseException = (UnreadableDatabaseFileException)ex; errorDetailTextBox.Text = string.Format(UnreadableDatabaseFileError, unreadableDatabaseException.Filename); } else { throw new ArgumentException("Unrecognized database error type."); } }; }
private void OnWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { if (e.Cancelled) { if (_conversationManager == null) { Application.Current.Shutdown(); } else if (_progressDialog != null) { _progressDialog.Close(); } } else if (e.Error != null) { _progressDialog.Close(); // // If the database file is unreadable, don't auto-open it. // if (_displayOptions != null) { _phoneSelectOptions.PhoneDataPath = ""; _phoneSelectOptions.Save(); } if (e.Error is DirectoryNotFoundException) { ShowDatabaseErrorDialog(new MissingBackupPathException()); } else if (e.Error is FileNotFoundException) { FileNotFoundException ex = (FileNotFoundException)e.Error; ShowDatabaseErrorDialog(new MissingBackupFileException(ex.FileName, ex)); } else if (e.Error is UnreadableDatabaseFileException) { UnreadableDatabaseFileException ex = (UnreadableDatabaseFileException)e.Error; ShowDatabaseErrorDialog(ex); } else { FailHandler.HandleUnrecoverableFailure(e.Error); } Application.Current.Shutdown(); } else { _conversationManager = (IConversationManager)e.Result; UpdateModels(); PopulateConversationList(); Update(); _progressDialog.Close(); _progressCallback = null; _progressDialog = null; ShowTextsOutOfDateWarningIfNeeded(); } }