Exemplo n.º 1
0
        public async Task <IEnumerable <ArticleView> > GetItemsAsync(string section)
        {
            var response = await client.GetAsync(ArticleUrlBuilder.GetSectionUrl(section));

            if (!response.IsSuccessStatusCode)
            {
                throw new Exception(
                          $"Error was occured during connection to server. Code: {(int) response.StatusCode}. Reason: {response.ReasonPhrase}");
            }

            var content = await response.Content.ReadAsStringAsync();

            var results = JsonConvert.DeserializeObject <dynamic>(content).results;

            return(mapper.Map <IEnumerable <ArticleView> >(results));
        }
        public void GetSectionUrl_Valid_ReturnUrl()
        {
            var url = ArticleUrlBuilder.GetSectionUrl("section");

            Assert.AreEqual(url, "https://baseurl/section.json?api-key=key");
        }