public void Correctly_attempts_to_send_email_and_provide_feedback_when_email_cannot_be_sent() { MockRepository mocks = new MockRepository(); IForgottenPasswordMailer mailer = mocks.CreateMock <IForgottenPasswordMailer>(); ISystemUserRepository repository = mocks.CreateMock <ISystemUserRepository>(); using (mocks.Record()) { Expect.Call(mailer.SendForgottenPasswordEmail("*****@*****.**", repository)).Return(false); } using (mocks.Playback()) { IForgottenPasswordService service = new ForgottenPasswordService(mailer); string userFeedback = service.SendEmailTo("*****@*****.**", repository); Assert.That(userFeedback, Is.EqualTo("We could not find a user with the e-mail address [email protected]")); } mocks.VerifyAll(); }
public ForgottenPasswordService(IForgottenPasswordMailer mailer) { _mailer = mailer; }