public GetListOfCoordinatedSchedules ( IDocumentStore documentStore ) : List |
||
documentStore | IDocumentStore | |
return | List |
public void CreaetExcludeMultiplePreviousCoordinatorMessagesRemovesMatchingNumbers_TrickleBetweenDates() { var CoordinatorToExclude1 = Guid.NewGuid(); var CoordinatorToExclude2 = Guid.NewGuid(); var model = new CoordinatedSharedMessageModel { Numbers = "04040404040, 1, 2, 3, 7, 12", Message = "asfdkjadfskl asflkj;faskjf;aslkjf;lasdkjfaslkfjas;lkfjslkfjas;lkfjsalkfjas;fklasj;flksdjf;lkasjflskdjflkasjflksjlk lskaf jlsk fdaskl dflksjfalk sflkj sfkl jlkjs flkj skjkj sadflkjsaflj", StartTime = DateTime.Now.AddHours(2), SendAllBy = DateTime.Now.AddHours(3), CoordinatorsToExclude = new List<Guid> { CoordinatorToExclude1, CoordinatorToExclude2 }, Topic = "frank", UserTimeZone = "Australia/Sydney" }; var bus = MockRepository.GenerateMock<IBus>(); var mapper = MockRepository.GenerateMock<ICoordinatorModelToMessageMapping>(); var ravenDocStore = MockRepository.GenerateMock<IRavenDocStore>(); var docStore = MockRepository.GenerateMock<IDocumentStore>(); var configSession = MockRepository.GenerateMock<IDocumentSession>(); var trackingSession = MockRepository.GenerateMock<IDocumentSession>(); var currentUser = MockRepository.GenerateStub<ICurrentUser>(); ravenDocStore.Expect(r => r.GetStore()).Return(docStore); docStore.Expect(d => d.OpenSession("Configuration")).Return(configSession); docStore.Expect(d => d.OpenSession("SmsTracking")).Return(trackingSession); configSession.Expect(d => d.Load<CountryCodeReplacement>("CountryCodeConfig")).Return(new CountryCodeReplacement()); var previousCoordinatorToExclude1 = new CoordinatorTrackingData(new List<MessageSendingStatus> { new MessageSendingStatus { Number = "04040404040" }, new MessageSendingStatus { Number = "1" } }); trackingSession.Expect(d => d.Load<CoordinatorTrackingData>(CoordinatorToExclude1.ToString())).Return( previousCoordinatorToExclude1); var previousCoordinatorToExclude2 = new CoordinatorTrackingData(new List<MessageSendingStatus> { new MessageSendingStatus { Number = "7" } }); trackingSession.Expect(d => d.Load<CoordinatorTrackingData>(CoordinatorToExclude2.ToString())).Return( previousCoordinatorToExclude2); var coordinatorMessage = new CoordinatedSharedMessageModel(); var excludeList1 = previousCoordinatorToExclude1.GetListOfCoordinatedSchedules(ravenDocStore.GetStore()).Select(s => s.Number).ToList(); var excludeList2 = previousCoordinatorToExclude2.GetListOfCoordinatedSchedules(ravenDocStore.GetStore()).Select(s => s.Number).ToList(); List<string> excludeList = null; mapper .Expect(m => m.MapToTrickleOverPeriod(Arg<CoordinatedSharedMessageModel>.Is.Anything, Arg<CountryCodeReplacement>.Is.Anything, Arg<List<string>>.Is.Anything, Arg<string>.Is.Anything)) .Return(new TrickleSmsOverCalculatedIntervalsBetweenSetDates()) .WhenCalled(t => coordinatorMessage = (CoordinatedSharedMessageModel)(t.Arguments[0])) .WhenCalled(t => excludeList = (List<string>)(t.Arguments[2])); bus.Expect(b => b.Send(Arg<TrickleSmsOverCalculatedIntervalsBetweenSetDates>.Is.NotNull)); var controller = new CoordinatorController { ControllerContext = new ControllerContext(), Bus = bus, Mapper = mapper, RavenDocStore = ravenDocStore, CurrentUser = currentUser }; var actionResult = (RedirectToRouteResult)controller.Create(model); Assert.That(actionResult.RouteValues["action"], Is.EqualTo("Details")); Assert.That(coordinatorMessage.Message, Is.EqualTo(model.Message.Substring(0, 160))); Assert.That(excludeList.ToList(), Is.EqualTo(excludeList1.Union(excludeList2).Distinct().ToList())); bus.VerifyAllExpectations(); mapper.VerifyAllExpectations(); configSession.VerifyAllExpectations(); trackingSession.VerifyAllExpectations(); }
private string CoordinatorToExcludeText(CoordinatorTrackingData coordinatorTrackingData) { return string.Format( "'{0}', {1} Sent, Started {2}", coordinatorTrackingData.MetaData.Topic, coordinatorTrackingData.GetListOfCoordinatedSchedules(RavenDocStore.GetStore()).Count(c => c.Status == MessageStatusTracking.CompletedSuccess).ToString(), coordinatorTrackingData.CreationDateUtc.ToLocalTime().ToShortDateString()); }