public void AddAndRemoveEmails() { var emailDeletionService = new MockEmailDeletionService(); var emailFolder = new EmailFolder() { EmailDeletionService = emailDeletionService }; Assert.IsFalse(emailFolder.Emails.Any()); var email1 = new Email(); emailFolder.AddEmail(email1); Assert.AreEqual(email1, emailFolder.Emails.Single()); var email2 = new Email(); emailFolder.AddEmail(email2); AssertHelper.SequenceEqual(new[] { email1, email2 }, emailFolder.Emails); bool deleteEmailCalled = false; emailDeletionService.DeleteEmailAction = (folder, email) => { deleteEmailCalled = true; Assert.AreEqual(emailFolder, folder); Assert.AreEqual(email1, email); }; emailFolder.RemoveEmail(email1); Assert.IsTrue(deleteEmailCalled); }
private void DeleteEmail() { var nextEmail = CollectionHelper.GetNextElementOrDefault(EmailListViewModel.Emails, EmailListViewModel.SelectedEmail); EmailFolder.RemoveEmail(EmailListViewModel.SelectedEmail); EmailListViewModel.SelectedEmail = nextEmail ?? EmailListViewModel.Emails.LastOrDefault(); EmailListViewModel.FocusItem(); }
private void DeleteEmail() { // Use the EmailCollectionView, which represents the sorted/filtered state of the emails, to determine the next email to select. var nextEmail = CollectionHelper.GetNextElementOrDefault(EmailListViewModel.EmailCollectionView, EmailListViewModel.SelectedEmail); EmailFolder.RemoveEmail(EmailListViewModel.SelectedEmail); EmailListViewModel.SelectedEmail = nextEmail ?? EmailListViewModel.EmailCollectionView.LastOrDefault(); EmailListViewModel.FocusItem(); }