public async Task VerifySampleStream()
        {
            client.Setup(c => c.GetClient()).Returns(client.Object);
            client.Setup(c => c.GetStreamAsync()).Returns(Task.FromResult(stream));

            var app = new TwitterStream(stats.Object, client.Object.GetClient);

            await app.Start();

            stats.Verify(x => x.Track(It.IsAny <ITweet>()), Times.Once());
        }
Exemplo n.º 2
0
        private void StreamTweets()
        {
            var stream = new TwitterStream(
                _options.Credential.ApiKey,
                _options.Credential.ApiSecret,
                _options.Credential.TokenKey,
                _options.Credential.TokenSecret
                );

            // Set Proxy
            if (!string.IsNullOrEmpty(_options.ProxyConnectionString))
            {
                stream.SetProxy(_options.ProxyConnectionString);
            }

            stream.StreamStarted      += stream_StreamStarted;
            stream.StreamStopped      += stream_StreamStopped;
            stream.TweetReceived      += stream_TweetReceived;
            stream.JsonObjectReceived += stream_JsonObjectReceived;

            stream.Start(_options.Track, _options.MatchCondition, _options.SearchLocations);
        }