RemoveEmail() public method

public RemoveEmail ( Email email ) : void
email Email
return void
示例#1
0
        public void AddAndRemoveEmails()
        {
            var emailDeletionService = new MockEmailDeletionService();
            var emailFolder = new EmailFolder(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);
            Assert.IsTrue(emailFolder.Emails.SequenceEqual(new[] { email1, email2 }));

            bool deleteEmailCalled = false;
            emailDeletionService.DeleteEmailAction = (folder, email) =>
            {
                deleteEmailCalled = true;
                Assert.AreEqual(emailFolder, folder);
                Assert.AreEqual(email1, email);
            };
            emailFolder.RemoveEmail(email1);
            Assert.IsTrue(deleteEmailCalled);
        }