コード例 #1
0
        public void EmailStatusUpdate_EmailIsComplained_ReplyFailed()
        {
            const EmailStatus emailStatus = EmailStatus.Complained;
            var emailData = new EmailData
            {
                ToAddress = "toaddress"
            };
            var requestMessage = new ScheduleEmailForSendingLater(DateTime.Now.AddMinutes(5), emailData, new SmsMetaData(), Guid.NewGuid(), "username");
            var data = new ScheduledEmailData
            {
                ScheduleMessageId = requestMessage.CorrelationId,
                OriginalMessageData = new OriginalEmailMessageData(requestMessage)
            };
            var emailStatusUpdate = new EmailStatusUpdate { Status = emailStatus };

            Test.Initialize();
            Test.Saga<EmailScheduler>()
                .WithExternalDependencies(a => { a.Data = data; })
                .WhenReceivesMessageFrom("address")
                .ExpectPublish<ScheduledEmailFailed>(m =>
                    m.CoordinatorId == requestMessage.CorrelationId
                    && m.EmailStatus == emailStatus
                    && m.ScheduledSmsId == data.ScheduleMessageId
                    && m.ToAddress == emailData.ToAddress
                    && m.Username == requestMessage.Username)
                .ExpectSendLocal<ScheduleStatusChanged>(s =>
                    s.Status == MessageStatus.Failed
                    && s.ScheduleId == data.ScheduleMessageId)
                .When(s => s.Handle(emailStatusUpdate))
                .AssertSagaCompletionIs(true);
        }
コード例 #2
0
 public EmailTrackingData(EmailStatusUpdate statusUpdate)
 {
     EmailStatus = statusUpdate.Status;
     EmailId = statusUpdate.EmailId;
     //SentTime = statusUpdate - do we need the sent time??
     ToAddress = statusUpdate.ToAddress;
     FromAddress = statusUpdate.FromAddress;
     FromDisplayName = statusUpdate.FromDisplayName;
     ReplyToAddress = statusUpdate.ReplyToAddress;
     Subject = statusUpdate.Subject;
     BodyHtml = statusUpdate.BodyHtml;
     BodyText = statusUpdate.BodyText;
     CorrelationId = statusUpdate.CorrelationId;
     ConfirmationEmailAddress = statusUpdate.ConfirmationEmailAddress;
     Username = statusUpdate.Username;
 }
コード例 #3
0
        public void EmailStatusUpdate_EmailIsDelivered_SetsTimeoutForFurtherInformation_TimeoutExpires_PublishSuccess()
        {
            const EmailStatus emailStatus = EmailStatus.Delivered;
            var emailData = new EmailData
            {
                ToAddress = "toaddress"
            };
            var requestMessage = new ScheduleEmailForSendingLater(DateTime.Now.AddMinutes(5), emailData, new SmsMetaData(), Guid.NewGuid(), "username");
            var data = new ScheduledEmailData
            {
                ScheduleMessageId = requestMessage.CorrelationId,
                OriginalMessageData = new OriginalEmailMessageData(requestMessage)
            };
            var emailStatusUpdate = new EmailStatusUpdate { Status = emailStatus };

            Test.Initialize();
            Test.Saga<EmailScheduler>()
                .WithExternalDependencies(a => { a.Data = data; })
                .WhenReceivesMessageFrom("address")
                    .ExpectTimeoutToBeSetIn<ScheduleEmailDeliveredTimeout>((message, timespan) => timespan.Ticks == new TimeSpan(1, 0, 0, 0).Ticks)
                .When(s => s.Handle(emailStatusUpdate))
                    .ExpectPublish<ScheduledEmailSent>(m =>
                        m.CoordinatorId == requestMessage.CorrelationId
                        && m.EmailStatus == emailStatus
                        && m.ScheduledSmsId == data.ScheduleMessageId
                        && m.ToAddress == emailData.ToAddress
                        && m.Username == requestMessage.Username)
                    .ExpectSendLocal<ScheduleStatusChanged>(s =>
                        s.Status == MessageStatus.Sent
                        && s.ScheduleId == data.ScheduleMessageId)
                .WhenSagaTimesOut()
                .AssertSagaCompletionIs(true);
        }