public void TestDbFails() { var emailService = new DummyEmailService(); var registrationRepository = new DummyRegistrationRepository(true); var service = new SubscriptionService(emailService, registrationRepository); Assert.Throws <DatabaseUnresponsiveException>(() => service.Subscribe("*****@*****.**")); Assert.IsTrue(registrationRepository.CreateHasBeenCalled); Assert.IsFalse(emailService.SendHasBeenCalled); }
public void TestAllOk() { var emailService = new DummyEmailService(); var registrationRepository = new DummyRegistrationRepository(); var service = new SubscriptionService(emailService, registrationRepository); service.Subscribe("*****@*****.**"); Assert.IsTrue(emailService.SendHasBeenCalled); Assert.IsTrue(registrationRepository.CreateHasBeenCalled); }