EmailSenderJob had a dependancy on SendGridClient and so in dev environment emails could not be logged to debug console.
Summary of change
Added IEmailSender interface and two implementations:
DevelopmentEmailSender: sender for dev env that simply logs email to debug console;
SendGridEmailSender: sender that depends on SendGridClient and actually sends emails in NOT dev env.
EmailSenderJob now depends on IEmailSender instead of SendGridClient.
Delete DevEmailSender as it's responsibility now implemented by DevelopmentEmailSender.
Registration of appropriate email sender is based on environment.
Split registration of EmailSenderService and EmailSenders into different extension methods.
Adjust existing unit tests to work correctly with made changes and cover new senders with unit tests.
Sumary of issue
EmailSenderJob
had a dependancy onSendGridClient
and so in dev environment emails could not be logged to debug console.Summary of change
Added
IEmailSender
interface and two implementations:DevelopmentEmailSender
: sender for dev env that simply logs email to debug console;SendGridEmailSender
: sender that depends onSendGridClient
and actually sends emails in NOT dev env.EmailSenderJob
now depends onIEmailSender
instead ofSendGridClient
. DeleteDevEmailSender
as it's responsibility now implemented byDevelopmentEmailSender
. Registration of appropriate email sender is based on environment. Split registration of EmailSenderService and EmailSenders into different extension methods. Adjust existing unit tests to work correctly with made changes and cover new senders with unit tests.