public void Handle(SmsScheduled message) { var context = GlobalHost.ConnectionManager.GetHubContext <ScheduleStatus>(); UpdateCoordinatorData(message.CoordinatorId, context); }
public void CoordinateMessagesOneMessageScheduled() { 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 smsScheduled = new SmsScheduled { CoordinatorId = coordinatorId, ScheduleSendingTimeUtc = DateTime.UtcNow }; var ravenDocStore = MockRepository.GenerateMock<IRavenDocStore>(); ravenDocStore.Expect(r => r.GetStore()).Return(DocumentStore); var coordinatorTracker = new ScheduleTracker { RavenStore = ravenDocStore }; coordinatorTracker.Handle(smsScheduled); 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(smsScheduled.ScheduleSendingTimeUtc)); Assert.That(updatedMessageData.ActualSentTimeUtc, Is.Null); Assert.That(updatedMessageData.Cost, Is.Null); } }
public void HandleMessageScheduled() { var scheduleId = Guid.NewGuid(); var ravenDocStore = MockRepository.GenerateMock<IRavenDocStore>(); ravenDocStore.Expect(r => r.GetStore()).Return(DocumentStore); var tracker = new ScheduleTracker { RavenStore = ravenDocStore }; var scheduleCreated = new SmsScheduled {ScheduleMessageId = scheduleId}; tracker.Handle(scheduleCreated); using (var session = DocumentStore.OpenSession()) { var scheduleTracking = session.Load<ScheduleTrackingData>(scheduleId.ToString()); Assert.That(scheduleTracking.SmsData, Is.EqualTo(scheduleCreated.SmsData)); Assert.That(scheduleTracking.SmsMetaData, Is.EqualTo(scheduleCreated.SmsMetaData)); Assert.That(scheduleTracking.ScheduleId, Is.EqualTo(scheduleCreated.ScheduleMessageId)); Assert.That(scheduleTracking.MessageStatus, Is.EqualTo(MessageStatus.Scheduled)); } }