public void ParseResponseTest() { var response = new HttpResponseMessage(); response.StatusCode = System.Net.HttpStatusCode.OK; response.Content = new StringContent(ReviewsResponse); var link = new GoodreadsApiReviews(); var result = link.ParseResponse(response); Assert.AreEqual(4.3, result.Reviews.AverageRating, 0.001); Assert.IsTrue(result.Reviews.ReviewsHtml.Contains("iframe")); }
public void CreateRequestTest() { var search = new GoodreadsApiReviews() { ApiKey = "123", BaseUrl = "https://abc.invalid/show.xml", BookID = 1001 }; var request = search.CreateRequest(); var uri = request.RequestUri; Assert.AreEqual(HttpMethod.Get, request.Method); Assert.AreEqual("https", uri.Scheme); Assert.AreEqual("abc.invalid", uri.Host); Assert.AreEqual("/show.xml", uri.AbsolutePath); var query = request.RequestUri.Query; Assert.IsTrue(query.Contains("id=1001")); Assert.IsTrue(query.Contains("key=123")); }