public async Task <IActionResult> Index() { string quoteString = ""; string quoteAuthor = ""; HttpClient client = new HttpClient(); // using external API to generate quotes try { var response = await client.GetStringAsync("https://api.quotable.io/random"); if (string.IsNullOrEmpty(response)) { Debug.WriteLine("Failed to receive response from the Quote API."); } QuoteApiModel quote = Newtonsoft.Json.JsonConvert.DeserializeObject <QuoteApiModel>(response); if (quote != null) { quoteString = quote.Content; quoteAuthor = quote.Author; } } catch (HttpRequestException ex) { throw ex; } ViewData["QuoteString"] = quoteString; ViewData["QuoteAuthor"] = quoteAuthor; return(View()); }
public void correctQuoteApiModelInfo(string author, string content, string expected) { QuoteApiModel quoteApiModel = new QuoteApiModel(); quoteApiModel.Author = author; quoteApiModel.Content = content; Assert.True(quoteApiModel.QuoteApiModelInfo() == expected); }
public void AuthorName() { QuoteApiModel quoteApiModel = new QuoteApiModel(); Assert.True(quoteApiModel.Author == null); }