public void SmsFailed() { var ravenDocStore = MockRepository.GenerateMock <IRavenDocStore>(); var database = "database"; ravenDocStore.Expect(r => r.Database()).Return(database); ravenDocStore.Expect(r => r.GetStore().OpenSession(database)).Return(DocumentStore.OpenSession()); var trackingData = new ScheduleTrackingData { ScheduleId = Guid.NewGuid(), MessageStatus = MessageStatus.WaitingForScheduling, }; StoreDocument(trackingData, trackingData.ScheduleId.ToString()); var scheduleStatusHandlers = new ScheduleStatusHandlers { RavenDocStore = ravenDocStore }; var scheduleFailed = new ScheduleFailed { ScheduleId = trackingData.ScheduleId, Message = "fail", MoreInfo = "link" }; scheduleStatusHandlers.Handle(scheduleFailed); var updatedData = GetSchedule(trackingData.ScheduleId.ToString()); Assert.That(updatedData.MessageStatus, Is.EqualTo(MessageStatus.Failed)); Assert.That(updatedData.SmsFailureData.Message, Is.EqualTo(scheduleFailed.Message)); Assert.That(updatedData.SmsFailureData.MoreInfo, Is.EqualTo(scheduleFailed.MoreInfo)); Assert.That(updatedData.SmsFailureData.Status, Is.EqualTo(scheduleFailed.Status)); Assert.That(updatedData.SmsFailureData.Code, Is.EqualTo(scheduleFailed.Code)); }
public void Handle(ScheduleFailed message) { using (var session = RavenDocStore.GetStore().OpenSession(RavenDocStore.Database())) { var scheduleTrackingData = session.Load <ScheduleTrackingData>(message.ScheduleId.ToString()); scheduleTrackingData.MessageStatus = MessageStatus.Failed; scheduleTrackingData.SmsFailureData = new SmsFailed("", message.Code, message.Message, message.MoreInfo, message.Status); session.SaveChanges(); } }