public void ResolveTest() { List <TrackedFile> files = FileManagerDAL.GetFiles(); if (files != null && files.Count >= 2) { // Get reminder for second file TrackedFile file = files[1]; if (file.ReminderID != -999) { Reminder reminder = file.GetReminder(); DateTime defaultDateTime = new DateTime(); if (reminder.ResolvedOn == defaultDateTime) { // Verify the reminder for this file is not resolved. Assert.AreEqual(defaultDateTime, reminder.ResolvedOn); // Call reminder Resolve for this reminder to clear // the reminder. reminder.Resolve(); // Verify the reminder for this file is resolved. Assert.AreNotEqual(defaultDateTime, reminder.ResolvedOn); } } } }
public void GetFilesTest() { List <TrackedFile> files = FileManagerDAL.GetFiles(); if (files != null) { // Get reminder for first file TrackedFile file = files[0]; Reminder reminder = file.GetReminder(); // Get the count for all the files that // have this reminder. int reminderCount = 0; foreach (var f in files) { if (f.ReminderID == reminder.ReminderID) { reminderCount++; } } // Call reminder GetFiles for this reminder to get the // list of files with this reminder. List <TrackedFile> reminderfileList = reminder.GetFiles(); // Verify the counts are the same Assert.AreEqual(reminderCount, reminderfileList.Count); } }
private void btnViewReminder_Click(object sender, EventArgs e) { string prompt = "Check a single file to view its reminder."; bool isSelected = ForceSingleSelection(prompt); if (!isSelected) { return; } try { ListViewItem row = MainListView.CheckedItems[0]; bool hasReminder = (row.SubItems[6].Text == "X"); // Reminder column if (!hasReminder) { string noReminderPrompt = "Selected file does not have an open, unresolved reminder."; Messenger.Show(noReminderPrompt, caption); return; } int fileID = (int)row.Tag; TrackedFile tf = FileManager.GetFile(fileID); if (tf == null) { return; } Reminder rem = tf.GetReminder(); if (rem == null) { return; } FormFileAidViewReminder viewRem = new FormFileAidViewReminder(rem); viewRem.ShowDialog(); // Always refresh gui here because reminder may have been removed FillListView(); // Re-check the selected item if it is still in list foreach (ListViewItem item in MainListView.Items) { if ((int)item.Tag == fileID) { item.Checked = true; } } } catch (SqlException) { Messenger.ShowDbMsg(); } }
public void GetReminderTest() { List <TrackedFile> files = FileManagerDAL.GetFiles(); if (files != null) { // Test reminders for first file TrackedFile file = files[0]; Reminder reminder = file.GetReminder(); //Assert for file 1 Assert.AreEqual(1, reminder.ReminderID); Assert.AreEqual("First reminder", reminder.Name); Assert.AreEqual("Description for first reminder", reminder.Memo); } }
public void RemoveMemoTest() { string defaultMemo = "Description for memo test reminder"; string removedMemo = ""; List <TrackedFile> files = FileManagerDAL.GetFiles(); if (files != null) { // Get reminder for first file TrackedFile file = files[0]; if (file.ReminderID != -999) { Reminder reminder = file.GetReminder(); // Store reminder memo value string memo = reminder.Memo ?? ""; // Update reminder memo value to default text reminder.UpdateMemo(defaultMemo); // Verify reminder has default memo text Assert.AreEqual(defaultMemo, reminder.Memo); // Remove the reminder memo reminder.RemoveMemo(); // Verify the reminder memo has been removed Assert.AreEqual(removedMemo, reminder.Memo); // Update reminder memo with the original memo text reminder.UpdateMemo(memo); // Verify the reminder has the original memo text Assert.AreEqual(memo, reminder.Memo); } } }
public void RemoveFilesTest() { List <TrackedFile> files = FileManagerDAL.GetFiles(); if (files != null && files.Count >= 3) { // Get reminder for third file TrackedFile file = files[2]; if (file.ReminderID != -999) { Reminder reminder = file.GetReminder(); // Call reminder GetFiles for this reminder to get the // list of files with this reminder. List <TrackedFile> reminderfileList = reminder.GetFiles(); // Create an int list containing the third file id to remove the reminder. List <int> removeList = new List <int>() { file.FileID }; // Remove the reminder for the files in the remove list. reminder.RemoveFiles(removeList); // Get the list of files assigned the reminder that was removed from the third file. List <TrackedFile> reminderfileListAfterRemove = reminder.GetFiles(); // Verify the after remove file count list matches the before remove file // count list minus the number of files in the remove list. Assert.AreEqual(reminderfileListAfterRemove.Count, reminderfileList.Count - removeList.Count); } } }