Пример #1
0
        public JsonResult Get(DateTime sinceDateTime)
        {
            var tweets = _getPBPTweetsService.GeTweetsSince(sinceDateTime).ToList();

            var response = new GetPBPTweetsResponseModel
            {
                tweets = tweets.OrderByDescending(tweet => tweet.TweetedAt)
                    .Select(tweet =>
                        new GetPBPTweetsResponseModel.Tweet
                        {
                            text = tweet.Text,
                            tweetedAt = tweet.TweetedAt.ToString("G"),
                            user = tweet.User
                        })
                    .ToArray(),

                userAggregateData = TweetAggregator.Process(tweets)
                    .ToDictionary(pair => pair.Key, pair =>
                        new GetPBPTweetsResponseModel.UserAggregateData
                        {
                            mentions = pair.Value.Mentions,
                            totalTweets = pair.Value.TotalTweets
                        })
            };

            return Json(response, JsonRequestBehavior.AllowGet);
        }
        public void TotalTweetsForNancyShouldBe1()
        {
            Given_tweets_from_multiple_users_with_mentions();

            var result = TweetAggregator.Process(_tweets);

            result["nancy"].TotalTweets.Should().Be(1);
        }
        public void TotalMentionsOfDrewByBobShouldBe1()
        {
            Given_tweets_from_multiple_users_with_mentions();

            var result = TweetAggregator.Process(_tweets);

            result["bob"].Mentions["drew"].Should().Be(1);
        }
        public void TotalMentionsOfNancyByBobShouldBe3()
        {
            Given_tweets_from_multiple_users_with_mentions();

            var result = TweetAggregator.Process(_tweets);

            result["bob"].Mentions["nancy"].Should().Be(3);
        }
        public void TotalUniqueMentionsByBobShouldBe2()
        {
            Given_tweets_from_multiple_users_with_mentions();

            var result = TweetAggregator.Process(_tweets);

            result["bob"].Mentions.Keys.Count.Should().Be(2);
        }
        public void TotalTweetsForBobShouldBe3()
        {
            Given_tweets_from_multiple_users_with_mentions();

            var result = TweetAggregator.Process(_tweets);

            result["bob"].TotalTweets.Should().Be(3);
        }
        public void TotalUniqueMentionsByNancyShouldBe0()
        {
            Given_tweets_from_multiple_users_with_mentions();

            var result = TweetAggregator.Process(_tweets);

            result["nancy"].Mentions.Count.Should().Be(0);
        }