public void SendEmailAsyncWithCorrectTemplateId(bool isCallBack, string expectedTemplateId) { // arrange var contactUsEmailRequestModel = new ContactUsEmailRequestModel() { IsCallBack = isCallBack, }; var notifyOptions = new NotifyOptions() { ByEmailTemplateId = "ByEmailTemplateId", CallMeBackTemplateId = "CallMeBackTemplateId", }; var notifyEmailService = new NotifyEmailService <ContactUsEmailRequestModel>(fakeLogger, fakeNotifyClientProxy, notifyOptions); A.CallTo(() => fakeNotifyClientProxy.SendEmail(A <string> ._, A <string> ._, A <Dictionary <string, dynamic> > ._)).Returns(A.Dummy <EmailNotificationResponse>()); // act var result = notifyEmailService.SendEmailAsync(contactUsEmailRequestModel).Result; // assert result.Should().BeTrue(); A.CallTo(() => fakeNotifyClientProxy.SendEmail(A <string> ._, A <string> .That.IsEqualTo(expectedTemplateId), A <Dictionary <string, dynamic> > ._)).MustHaveHappened(); }
public void SendEmailAsyncReturnsFailedOnError() { // arrange var contactUsEmailRequestModel = new ContactUsEmailRequestModel(); var dummyNotifyOptions = new NotifyOptions(); var notifyEmailService = new NotifyEmailService <ContactUsEmailRequestModel>(fakeLogger, fakeNotifyClientProxy, dummyNotifyOptions); A.CallTo(() => fakeNotifyClientProxy.SendEmail(A <string> ._, A <string> ._, A <Dictionary <string, dynamic> > ._)).Throws <NotifyClientException>(); // act var result = notifyEmailService.SendEmailAsync(contactUsEmailRequestModel).Result; // assert result.Should().BeFalse(); A.CallTo(() => fakeNotifyClientProxy.SendEmail(A <string> ._, A <string> ._, A <Dictionary <string, dynamic> > ._)).MustHaveHappened(); }
public void SendEmailAsyncReturnsSuccess() { // arrange var contactUsEmailRequestModel = new ContactUsEmailRequestModel() { ToEmailAddress = "*****@*****.**", }; var dummyNotifyOptions = new NotifyOptions(); var notifyEmailService = new NotifyEmailService <ContactUsEmailRequestModel>(fakeLogger, fakeNotifyClientProxy, dummyNotifyOptions); A.CallTo(() => fakeNotifyClientProxy.SendEmail(A <string> ._, A <string> ._, A <Dictionary <string, dynamic> > ._)).Returns(A.Dummy <EmailNotificationResponse>()); // act var result = notifyEmailService.SendEmailAsync(contactUsEmailRequestModel).Result; // assert result.Should().BeTrue(); A.CallTo(() => fakeNotifyClientProxy.SendEmail(A <string> .That.IsEqualTo(contactUsEmailRequestModel.ToEmailAddress), A <string> ._, A <Dictionary <string, dynamic> > ._)).MustHaveHappened(); }