public async Task ProcessWithOneMessageTest() { List <DkimSchedulerState> records = new List <DkimSchedulerState> { new DkimSchedulerState("abc.com") }; A.CallTo(() => _dao.GetDkimRecordsToUpdate()).Returns(records); ProcessResult result = await _processor.Process(); Assert.That(result.ContinueProcessing, Is.True); A.CallTo(() => _dao.GetDkimRecordsToUpdate()).MustHaveHappenedOnceExactly(); A.CallTo(() => _publisher.Publish(A <DkimRecordsExpired> ._, A <string> ._)) .MustHaveHappenedOnceExactly(); A.CallTo(() => _dao.UpdateLastChecked(records)) .MustHaveHappenedOnceExactly(); }
public async Task <ProcessResult> Process() { Stopwatch stopwatch = Stopwatch.StartNew(); List <DkimSchedulerState> entitiesToUpdate = await _dkimPeriodicSchedulerDao.GetDkimRecordsToUpdate(); _log.LogInformation($"Found {entitiesToUpdate.Count} records to update."); if (entitiesToUpdate.Any()) { entitiesToUpdate.ForEach(async _ => await _publisher.Publish(_.ToDkimPollMessage(), _config.PublisherConnectionString)); await _dkimPeriodicSchedulerDao.UpdateLastChecked(entitiesToUpdate); _log.LogInformation($"Processing {entitiesToUpdate.Count} took: {stopwatch.Elapsed}"); } stopwatch.Stop(); return(entitiesToUpdate.Any() ? ProcessResult.Continue : ProcessResult.Stop); }