public void HandleMessageResumed()
        {
            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.Paused }, scheduleId.ToString());
                session.SaveChanges();
            }

            var scheduleCreated = new MessageRescheduled { ScheduleMessageId = scheduleId };
            tracker.Handle(scheduleCreated);

            using (var session = DocumentStore.OpenSession())
            {
                var scheduleTracking = session.Load<ScheduleTrackingData>(scheduleId.ToString());
                Assert.That(scheduleTracking.MessageStatus, Is.EqualTo(MessageStatus.Scheduled));
            }
        }
        public void CoordinateMessagesOneMessageResumedCurrentStatusPaused()
        {
            var coordinatorId = Guid.NewGuid();
            var scheduleId = Guid.NewGuid();
            const string updatedNumber = "04040044";
            var scheduledTime = DateTime.Now.AddMinutes(5);
            var rescheduledTime = DateTime.Now.AddMinutes(5);

            using (var session = DocumentStore.OpenSession())
            {
                var message = new CoordinatorCreated
                {
                    CoordinatorId = coordinatorId,
                    ScheduledMessages = new List<MessageSchedule>
                    {
                        new MessageSchedule { ScheduleMessageId = scheduleId, Number = updatedNumber, ScheduledTimeUtc = scheduledTime},
                        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.Paused, ScheduleMessageId = s.ScheduleMessageId}).
                        ToList()
                };
                session.Store(coordinatorTrackingData, message.CoordinatorId.ToString());
                session.SaveChanges();
            }

            var messageResumed = new MessageRescheduled { CoordinatorId = coordinatorId, ScheduleMessageId = scheduleId, RescheduledTimeUtc = rescheduledTime };

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

            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.Scheduled));
                Assert.That(updatedMessageData.ScheduledSendingTimeUtc, Is.EqualTo(rescheduledTime));
                Assert.That(updatedMessageData.ActualSentTimeUtc, Is.Null);
                Assert.That(updatedMessageData.Cost, Is.Null);
            }
        }