public When_EmailDeliveryStatusService_Is_Called_To_Send_Email_With_Invalid_Email_And_No_Opportunity()
        {
            var configuration = new MatchingConfiguration
            {
                MatchingServiceSupportEmailAddress = SupportEmailAddress
            };

            var logger = Substitute.For <ILogger <Application.Services.EmailDeliveryStatusService> >();

            _emailService = Substitute.For <IEmailService>();
            _emailService.GetEmailBodyFromNotifyClientAsync(_notificationId).Returns(
                new EmailDeliveryStatusDto
            {
                Body    = "Body",
                Subject = "Subject",
                EmailDeliveryStatusType = EmailDeliveryStatusType.PermanentFailure
            });

            _emailService.GetEmailHistoryAsync(_notificationId).Returns(
                new EmailHistoryDto
            {
                NotificationId    = _notificationId,
                OpportunityId     = null,
                OpportunityItemId = null,
                SentTo            = "*****@*****.**",
                Status            = "permanent-failure",
                EmailTemplateId   = 11,
                EmailTemplateName = "EmployerAupaBlank",
                CreatedBy         = "CreatedBy"
            });

            var messageQueueService = Substitute.For <IMessageQueueService>();

            _opportunityRepository = Substitute.For <IOpportunityRepository>();
            _opportunityRepository.GetEmailDeliveryStatusForEmployerAsync(1, "*****@*****.**").Returns(
                new EmailBodyDtoBuilder()
                .AddEmployerEmail().Build());

            var emailDeliveryStatusService = new Application.Services.EmailDeliveryStatusService(configuration,
                                                                                                 _emailService,
                                                                                                 _opportunityRepository,
                                                                                                 messageQueueService,
                                                                                                 logger);

            emailDeliveryStatusService.SendEmailDeliveryStatusAsync(_notificationId).GetAwaiter().GetResult();
        }
Esempio n. 2
0
        public When_EmailDeliveryStatusService_Is_Called_To_Send_Email_With_Inbox_Full()
        {
            var configuration = new MatchingConfiguration
            {
                MatchingServiceSupportEmailAddress = "*****@*****.**"
            };

            var logger = Substitute.For <ILogger <Application.Services.EmailDeliveryStatusService> >();

            _emailService = Substitute.For <IEmailService>();
            _emailService.GetEmailBodyFromNotifyClientAsync(_notificationId).Returns(
                new EmailDeliveryStatusDto
            {
                Body    = "Body",
                Subject = "Subject",
                EmailDeliveryStatusType = EmailDeliveryStatusType.TemporaryFailure
            });

            _emailService.GetEmailHistoryAsync(_notificationId).Returns(
                new EmailHistoryDto
            {
                NotificationId    = _notificationId,
                OpportunityId     = OpportunityId,
                OpportunityItemId = OpportunityItemId,
                SentTo            = "*****@*****.**",
                Status            = "unknown-failure",
                EmailTemplateId   = 7,
                EmailTemplateName = "ProviderReferralV5",
                CreatedBy         = "CreatedBy"
            });

            var messageQueueService = Substitute.For <IMessageQueueService>();

            _opportunityRepository = Substitute.For <IOpportunityRepository>();
            _opportunityRepository.GetEmailDeliveryStatusForProviderAsync(OpportunityId, "*****@*****.**").Returns(
                new EmailBodyDtoBuilder().AddProviderEmail().Build());

            var emailDeliveryStatusService = new Application.Services.EmailDeliveryStatusService(configuration,
                                                                                                 _emailService,
                                                                                                 _opportunityRepository,
                                                                                                 messageQueueService,
                                                                                                 logger);

            emailDeliveryStatusService.SendEmailDeliveryStatusAsync(_notificationId).GetAwaiter().GetResult();
        }