예제 #1
0
 public SmtpService(SMTPServiceConfiguration smtpServiceConfiguration)
 {
     SmtpServiceConfiguration = smtpServiceConfiguration;
     // configure the smtp server
     SmtpClient             = new SmtpClient(smtpServiceConfiguration.Configuration.BaseUri);
     SmtpClient.Port        = smtpServiceConfiguration.Configuration.Port ?? 587;
     SmtpClient.EnableSsl   = true;
     SmtpClient.Credentials =
         new System.Net.NetworkCredential(
             smtpServiceConfiguration.Configuration.Key,
             smtpServiceConfiguration.Configuration.Secret);
 }
        public MailController_Test()
        {
            IConfiguration configuration = CreateConfiguration();
            CloudFoundryServicesOptions cfServiceOptions = new CloudFoundryServicesOptions(configuration);

            cfOptions = Options.Create <CloudFoundryServicesOptions>(cfServiceOptions);
            SMTPServiceConfiguration smtpConfig = new SMTPServiceConfiguration
            {
                ServiceBindingName = "smtp-service"
            };

            smptOptions   = Options.Create <SMTPServiceConfiguration>(smtpConfig);
            loggerFactory = new LoggerFactory();
            mockSMPTPLib  = new Mock <ISmtpLibrary>();
            mockSMPTPLib.Setup(method => method.Send(It.IsAny <MailModel>(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>(),
                                                     It.IsAny <int>()));
            mockSMPTPLib.Setup(method => method.SendAsync(It.IsAny <MailModel>(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>(),
                                                          It.IsAny <int>())).Returns(Task.FromResult(0)).Verifiable();
        }