public void GetSports_ShouldNot_EmptyCollection_IfHttpStatusNotOk()
        {
            HttpResponseMessage responseMessage = new HttpResponseMessage(HttpStatusCode.InternalServerError);
            var httpMessageHandler = new HttpMessageHandlerMock(responseMessage);
            RedditClient redditCleint = new RedditClient(httpMessageHandler);
            var redditResponse = redditCleint.GetSports().Result.ToList();

            Assert.IsInstanceOfType(redditResponse, typeof(List<SportPost>));
            Assert.IsTrue(redditResponse.Count == 0);
        }
        public void GetSportsRedditResponse_ShouldUse_TheCorrectEndpoint()
        {
            string expectedRequestUri = "http://www.reddit.com/r/sports.json?limit=100";

            HttpResponseMessage responseMessage = new HttpResponseMessage(System.Net.HttpStatusCode.OK);
            responseMessage.Content = new StringContent(RedditClientTest.SportPostsJson);
            responseMessage.Content.Headers.ContentType = new MediaTypeHeaderValue(@"application/json");

            var httpMessageHandler = new HttpMessageHandlerMock(responseMessage);
            RedditClient redditCleint = new RedditClient(httpMessageHandler);
            var redditResponse = redditCleint.GetSportsRedditResponse().Result;

            Assert.AreEqual<string>(expectedRequestUri, redditResponse.RequestMessage.RequestUri.AbsoluteUri);
        }
        public void GetSports_ShouldReturn_ProperlyDeserielizedReditResponse()
        {
            HttpResponseMessage responseMessage = new HttpResponseMessage(System.Net.HttpStatusCode.OK);
            responseMessage.Content = new StringContent(RedditClientTest.SportPostsJson);
            responseMessage.Content.Headers.ContentType = new MediaTypeHeaderValue(@"application/json");

            var httpMessageHandler = new HttpMessageHandlerMock(responseMessage);
            RedditClient redditCleint = new RedditClient(httpMessageHandler);
            var redditResponse = redditCleint.GetSports().Result.ToList();

            var jsonObjectFromRedit = new StringContent(RedditClientTest.SportPostsJson, Encoding.UTF8, new MediaTypeHeaderValue(@"application/json").ToString()).ReadAsAsync<JObject>();
            var serializer = JsonSerializer.Create();
            var expectedResult = serializer
                .Deserialize<ICollection<RedditSportPost>>(jsonObjectFromRedit.Result["data"]["children"].CreateReader())
                .Select(rs => rs.Data)
                .ToList();

            Assert.IsTrue(expectedResult.SequenceEqual(redditResponse, new SportPostComparer()));
        }