コード例 #1
0
        public void TrickleMessagesMessagesPausedConfirmedButAlreadySentThrowsException_Data()
        {
            var messageList = new SmsData("99999", "dj;alsdfkj");

            var scheduleId = Guid.NewGuid();
            var messageSchedulePaused = new MessageSchedulePaused { ScheduleId = scheduleId };

            var scheduledMessageStatuses = new List<ScheduledMessageStatus>
            {
                new ScheduledMessageStatus(new ScheduleSmsForSendingLater { SmsData = messageList, ScheduleMessageId = scheduleId }, MessageStatus.Sent)
            };

            var sagaData = new CoordinateSmsSchedulingData { ScheduledMessageStatus = scheduledMessageStatuses, Id = Guid.NewGuid(), Originator = "o", OriginalMessageId = "i" };

            var coordinateSmsScheduler = new CoordinateSmsScheduler {Data = sagaData};
            Assert.That(() => coordinateSmsScheduler.Handle(messageSchedulePaused), Throws.Exception.With.Message.EqualTo("Scheduled message " + scheduleId + " is already sent."));
        }
コード例 #2
0
        public void HandleMessagePaused()
        {
            var scheduleId = Guid.NewGuid();

            var ravenDocStore = MockRepository.GenerateMock<IRavenDocStore>();
            ravenDocStore.Expect(r => r.GetStore()).Return(DocumentStore);
            var tracker = new ScheduleTracker { RavenStore = ravenDocStore };

            using (var session = DocumentStore.OpenSession())
            {
                session.Store(new ScheduleTrackingData { ScheduleId = scheduleId, MessageStatus = MessageStatus.Scheduled }, scheduleId.ToString());
                session.SaveChanges();
            }

            var schedulePaused = new MessageSchedulePaused{ ScheduleId = scheduleId };
            tracker.Handle(schedulePaused);

            using (var session = DocumentStore.OpenSession())
            {
                var scheduleTracking = session.Load<ScheduleTrackingData>(scheduleId.ToString());
                Assert.That(scheduleTracking.MessageStatus, Is.EqualTo(MessageStatus.Paused));
            }
        }
コード例 #3
0
        public void CoordinateMessagesOneMessagePausedCurrentStatusSentThrowsException()
        {
            var coordinatorId = Guid.NewGuid();
            const string updatedNumber = "04040044";
            using (var session = DocumentStore.OpenSession())
            {
                var message = new CoordinatorCreated
                {
                    CoordinatorId = coordinatorId,
                    ScheduledMessages = new List<MessageSchedule> {
                new MessageSchedule { Number = updatedNumber, ScheduledTimeUtc = DateTime.Now.AddMinutes(5)},
                new MessageSchedule { Number = "07777777", ScheduledTimeUtc = DateTime.Now.AddMinutes(10)}
                }
                };
                var coordinatorTrackingData = new CoordinatorTrackingData
                {
                    CoordinatorId = message.CoordinatorId,
                    MessageStatuses = message.ScheduledMessages
                        .Select(s => new MessageSendingStatus { Number = s.Number, ScheduledSendingTimeUtc = s.ScheduledTimeUtc, Status = MessageStatusTracking.CompletedSuccess }).
                        ToList()
                };
                session.Store(coordinatorTrackingData, message.CoordinatorId.ToString());
                session.SaveChanges();
            }

            var messagePaused = new MessageSchedulePaused { CoordinatorId = coordinatorId };

            var ravenDocStore = MockRepository.GenerateMock<IRavenDocStore>();
            ravenDocStore.Expect(r => r.GetStore()).Return(DocumentStore);
            var coordinatorTracker = new ScheduleTracker { RavenStore = ravenDocStore };
            Assert.That(() => coordinatorTracker.Handle(messagePaused), Throws.Exception.With.Message.EqualTo("Cannot record pausing of message - it is already recorded as complete."));
        }
コード例 #4
0
        public void CoordinateMessagesOneMessagePausedCurrentStatusScheduled()
        {
            var coordinatorId = Guid.NewGuid();
            const string updatedNumber = "04040044";
            using (var session = DocumentStore.OpenSession())
            {
                var message = new CoordinatorCreated
                {
                    CoordinatorId = coordinatorId,
                    ScheduledMessages = new List<MessageSchedule> {
                new MessageSchedule { Number = updatedNumber, ScheduledTimeUtc = DateTime.Now.AddMinutes(5)},
                new MessageSchedule { Number = "07777777", ScheduledTimeUtc = DateTime.Now.AddMinutes(10)}
                }
                };
                var coordinatorTrackingData = new CoordinatorTrackingData
                {
                    CoordinatorId = message.CoordinatorId,
                    MessageStatuses = message.ScheduledMessages
                        .Select(s => new MessageSendingStatus { Number = s.Number, ScheduledSendingTimeUtc = s.ScheduledTimeUtc }).
                        ToList()
                };
                session.Store(coordinatorTrackingData, message.CoordinatorId.ToString());
                session.SaveChanges();
            }

            var messagePaused = new MessageSchedulePaused { CoordinatorId = coordinatorId };

            var ravenDocStore = MockRepository.GenerateMock<IRavenDocStore>();
            ravenDocStore.Expect(r => r.GetStore()).Return(DocumentStore);
            var coordinatorTracker = new ScheduleTracker { RavenStore = ravenDocStore };
            coordinatorTracker.Handle(messagePaused);

            using (var session = DocumentStore.OpenSession())
            {
                var trackingData = session.Load<CoordinatorTrackingData>(coordinatorId.ToString());
                var updatedMessageData = trackingData.MessageStatuses.First(m => m.Number == updatedNumber);
                Assert.That(updatedMessageData.Status, Is.EqualTo(MessageStatusTracking.Paused));
                Assert.That(updatedMessageData.ActualSentTimeUtc, Is.Null);
                Assert.That(updatedMessageData.Cost, Is.Null);
            }
        }