Beispiel #1
0
        //Let's call it as a dependency here, for the sake of showing that the DI is working, but not very clever to do async here
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, IMailjetEmailClient mailjetEmailClient, IMailjetSimpleClient mailjetSimpleClient, IMailjetOptions mailjetOptions, IMailjetSmsClient mailjetSmsClient)
        {
            var email = new EmailMessage("Test Testsson", "*****@*****.**");
            //var emailResponse = mailjetEmailClient.SendAsync(email).GetAwaiter().GetResult();

            var sms = new SmsMessage
            {
                To   = Environment.GetEnvironmentVariable("MAILJET_TEST_PHONE"),
                From = "Max Test",
                Text = "You should receive this :)"
            };
            var smsResponse = mailjetSmsClient.SendAsync(sms).GetAwaiter().GetResult();

            //The low level MailjetSimpleClient takes an IRequestFactory for sending a request. Anything that implements this (properly) can send whatever type of request
            //This is essentially the equivalent of what is being done in SendAsync() above.
            var basicResponse  = mailjetSimpleClient.SendRequestAsync(new SendEmailRequest(email, mailjetOptions)).GetAwaiter().GetResult();
            var basicResponse2 = mailjetSimpleClient.SendRequestAsync(new SendSmsRequest(sms, mailjetOptions));

            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            app.Run(async(context) =>
            {
                await context.Response.WriteAsync("Hello World!");
            });
        }
Beispiel #2
0
 public EmailServiceTests()
 {
     _loggerMock        = Substitute.For <ILogger <EmailService> >();
     _configurationMock = Substitute.For <IConfig>();
     _configurationMock.MailjetConfig = new NyssFuncAppConfig.MailjetConfigOptions {
         EnableFeedbackSms = true
     };
     _mailjetEmailClientMock = Substitute.For <IMailjetEmailClient>();
     _emailService           = new EmailService(
         _loggerMock,
         _configurationMock,
         _mailjetEmailClientMock);
 }
Beispiel #3
0
 public EmailService(ILogger <EmailService> logger, IConfig config, IMailjetEmailClient emailClient)
 {
     _logger      = logger;
     _config      = config;
     _emailClient = emailClient;
 }