public async Task TestGetSet() { const string userId = "test"; DateTime latestUpdateTime = DateTime.Parse(DateTime.Now.ToString()); // To ignore millisecond precision await _repository.AddOrUpdateAsync(userId, latestUpdateTime); UserLatestUpdateTime userLatestUpdateTime = await _repository.GetAsync(userId); Assert.AreEqual(userId, userLatestUpdateTime.UserId); Assert.AreEqual(latestUpdateTime, userLatestUpdateTime.LatestUpdateTime.ToLocalTime()); }
private async Task PollUser(string userId, CancellationToken cancellationToken) { _logger.LogInformation("Polling {}", userId); IEnumerable <Update> updates = await GetUpdates(userId, cancellationToken) .ToListAsync(cancellationToken); foreach (Update update in updates) { await SendUpdate(update); await Task.Delay(_config.SendDelay, cancellationToken); } if (updates.Any()) { await _userLatestUpdateTimesRepository.AddOrUpdateAsync(userId, DateTime.Now); } else { _logger.LogInformation("No new updates found for {}", userId); } }