コード例 #1
0
        public void ResumePausedSchedule_Data()
        {
            var sagaId = Guid.NewGuid();
            var scheduleMessageId = Guid.NewGuid();

            var scheduledSmsData = new ScheduledSmsData
            {
                Id = sagaId,
                ScheduleMessageId = scheduleMessageId,
                Originator = "place",
                OriginalMessageId = Guid.NewGuid().ToString(),
                OriginalMessage = new ScheduleSmsForSendingLater { SmsData = new SmsData("1", "msg"), SmsMetaData = new SmsMetaData(),SendMessageAtUtc = DateTime.Now }
            };

            Test.Initialize();
            var rescheduleMessage = new ResumeScheduledMessageWithOffset(scheduleMessageId, new TimeSpan(0, 1, 0, 0));
            var resheduledTime = scheduledSmsData.OriginalMessage.SendMessageAtUtc.Add(rescheduleMessage.Offset);
            Test.Saga<ScheduleSms>()
                .WithExternalDependencies(a => a.Data = scheduledSmsData)
                    .ExpectTimeoutToBeSetAt<ScheduleSmsTimeout>((state, span) => span == resheduledTime)
                    //.ExpectSend<ScheduleResumed>(s =>
                    //{
                    //    return s.ScheduleId == scheduleMessageId &&
                    //    s.RescheduledTime == resheduledTime;
                    //})
                    .ExpectPublish<MessageRescheduled>()
                .When(s => s.Handle(rescheduleMessage));
        }
コード例 #2
0
        public void ResumePausedSchedule_Data()
        {
            var sagaId = Guid.NewGuid();
            var scheduleMessageId = Guid.NewGuid();

            var scheduledEmailData = new ScheduledEmailData
                {
                    Id = sagaId,
                    ScheduleMessageId = scheduleMessageId,
                    Originator = "place",
                    OriginalMessageId = Guid.NewGuid().ToString(),
                    OriginalMessageData = new OriginalEmailMessageData(new ScheduleEmailForSendingLater { EmailData = new EmailData()}) {OriginalRequestSendTime = DateTime.Now }
                };

            Test.Initialize();
            var rescheduleMessage = new ResumeScheduledMessageWithOffset(scheduleMessageId, new TimeSpan(0, 1, 0, 0));
            var rescheduledTime = scheduledEmailData.OriginalMessageData.OriginalRequestSendTime.Add(rescheduleMessage.Offset);
            Test.Saga<EmailScheduler>()
                .WithExternalDependencies(a => { a.Data = scheduledEmailData; })
                .ExpectTimeoutToBeSetAt<ScheduleEmailTimeout>((state, span) => span == rescheduledTime)
                .ExpectPublish<MessageRescheduled>()
                .When(s => s.Handle(rescheduleMessage));
        }
コード例 #3
0
        public void ResumePausedSchedule_Data()
        {
            var sagaId = Guid.NewGuid();
            var scheduleMessageId = Guid.NewGuid();
            StoreDocument(new ScheduleTrackingData { ScheduleId = scheduleMessageId, MessageStatus = MessageStatus.Paused }, scheduleMessageId.ToString());
            var ravenDocStore = MockRepository.GenerateMock<IRavenDocStore>();
            ravenDocStore.Expect(r => r.GetStore().OpenSession("SmsTracking")).Return(DocumentStore.OpenSession());

            var scheduledSmsData = new ScheduledSmsData
            {
                Id = sagaId,
                ScheduleMessageId = scheduleMessageId,
                Originator = "place",
                OriginalMessageId = Guid.NewGuid().ToString(),
                OriginalMessage = new ScheduleSmsForSendingLater { SmsData = new SmsData("1", "msg"), SmsMetaData = new SmsMetaData(),SendMessageAtUtc = DateTime.Now }
            };

            Test.Initialize();
            var rescheduleMessage = new ResumeScheduledMessageWithOffset(scheduleMessageId, new TimeSpan(0, 1, 0, 0));
            var rescheduledTime = scheduledSmsData.OriginalMessage.SendMessageAtUtc.Add(rescheduleMessage.Offset);
            Test.Saga<ScheduleSms>()
                .WithExternalDependencies(a => { a.Data = scheduledSmsData; a.RavenDocStore = ravenDocStore; })
                    .ExpectTimeoutToBeSetAt<ScheduleSmsTimeout>((state, span) => span == rescheduledTime)
                    .ExpectPublish<MessageRescheduled>()
                .When(s => s.Handle(rescheduleMessage));

            var schedule = GetSchedule(scheduleMessageId.ToString());
            Assert.That(schedule.MessageStatus, Is.EqualTo(MessageStatus.Scheduled));
            Assert.That(schedule.ScheduleTimeUtc, Is.EqualTo(rescheduledTime));
        }