public GetTweetResponse GetTweetsSince(GetTweetsRequest request) { OAuthAccessToken accessToken = request.AccessToken; _twitterService.AuthenticateWith(accessToken.Token, accessToken.TokenSecret); IEnumerable<TwitterStatus> tweets = _twitterService.ListTweetsOnHomeTimelineSince(request.LastTweetId); TweeterStatusAdapter adapter = new TweeterStatusAdapter(); return new GetTweetResponse { TweeterStatuses = adapter.Convert(tweets) }; }
public void GetTweetsSince_ShouldReturnTweetsSinceTweetId() { List<TwitterStatus> twitterStatuses = Builder<TwitterStatus> .CreateListOfSize(2) .WhereAll() .Have(ts => ts.User = Builder<TwitterUser>.CreateNew().Build()) .Build() .ToList(); OAuthAccessToken accessToken = new OAuthAccessToken { Token = "abcd", TokenSecret = "A@c#" }; Mock.Get(_mockTwitterService).Setup(mockService => mockService.AuthenticateWith(accessToken.Token, accessToken.TokenSecret)); Mock.Get(_mockTwitterService).Setup(mockService => mockService.ListTweetsOnHomeTimelineSince(100)).Returns( twitterStatuses); GetTweetsRequest getTweetsRequest = new GetTweetsRequest { AccessToken = accessToken, LastTweetId = 100 }; GetTweetResponse response = _authenticationService.GetTweetsSince(getTweetsRequest); Mock.Get(_mockTwitterService).VerifyAll(); Assert.IsNotNull(response); Assert.AreEqual(2, response.TweeterStatuses.Count()); }