private static void CreateCommunicationsTestData(int expirationDays, int delayMinutes) { var beginWindow = RockDateTime.Now.AddDays(0 - expirationDays).AddDays(0 - 2); var endWindow = RockDateTime.Now.AddMinutes(0 - delayMinutes).AddDays(2); var currentDateTime = beginWindow; var sender = GetNewPersonAlias(); var communications = new List <Rock.Model.Communication>(); communications.AddRange(CreateCommunication(sender, null, null)); while (beginWindow < endWindow) { communications.AddRange(CreateCommunication(sender, beginWindow, null)); communications.AddRange(CreateCommunication(sender, beginWindow, beginWindow.AddDays(2))); communications.AddRange(CreateCommunication(sender, null, beginWindow)); beginWindow = beginWindow.AddDays(1); } using (var rockContext = new RockContext()) { var communicationService = new CommunicationService(rockContext); communicationService.AddRange(communications); rockContext.SaveChanges(); } }