Beispiel #1
0
        public async Task StartProcessingAsync(CancellationToken cancellationToken)
        {
            // get the reporting data
            _data.ReportingData += (s, e) =>
            {
                var model = new ReportDataViewModel
                {
                    TotalNumberOfTweets                = e.TotalNumberOfTweets,
                    AverageNumberOfTweetsPerHour       = e.AverageNumberOfTweets(e.TimeCounter.TotalHours),
                    AverageNumberOfTweetsPerSecond     = e.AverageNumberOfTweets(e.TimeCounter.TotalSeconds),
                    AverageNumberOfTweetsPerMinute     = e.AverageNumberOfTweets(e.TimeCounter.TotalMinutes),
                    PercentOfTweetsThatContainEmojis   = e.PercentOfTweetsThatContainsEmojis,
                    PercentOfTweetsThatContainPhotoUrl = e.PercentOfTweetsThatContainPhotoUrl,
                    PercentOfTweetsThatContainUrl      = e.PercentOfTweetsThatContainUrl,
                    Top10EmojisInTweets                = e.EmojisInTweets,
                    Top10HashTags  = e.HashTagsInTweets,
                    Top10UrlTweets = e.UrlsInTweets,
                };
                _cache.Set("ReportData", model);// store it in cache
            };
            // start the stream
            await _data.StartStreamAsync(_configuration.GetSection("twitter-stream").Value, cancellationToken);

            _cache.Set("ReportData", "");// clear the cache
        }
Beispiel #2
0
 public async System.Threading.Tasks.Task start_stream_async_testAsync()
 {
     _mockHttpClient.Setup(p => p.GetAsync(It.IsAny <Uri>()));
     await _data.StartStreamAsync("https://api.twitter.com/2/tweets/sample/stream", new CancellationToken());
 }