Hello world!
\n", "Greetings", content); + } + + [Fact] + public async Task Renders_AsyncComponent() + { + // Arrange & Act + var expectedHtml = @" +This component demonstrates fetching data from the server.
+ +Weather data for 01/15/2019
+| Date | +Temp. (C) | +Temp. (F) | +Summary | +
|---|---|---|---|
| 06/05/2018 | +1 | +33 | +Freezing | +
| 07/05/2018 | +14 | +57 | +Bracing | +
| 08/05/2018 | +-13 | +9 | +Freezing | +
| 09/05/2018 | +-16 | +4 | +Balmy | +
| 10/05/2018 | +2 | +29 | +Chilly | +
Hello Steve!
", content); + } + + [Fact] + public async Task CanRender_AsyncComponent() + { + // Arrange + var helper = CreateHelper(); + var writer = new StringWriter(); + var expectedContent = @"| Date | +Summary | +F | +C | +
|---|---|---|---|
| 06/05/2018 | +Freezing | +33 | +33 | +
| 07/05/2018 | +Bracing | +57 | +57 | +
| 08/05/2018 | +Freezing | +9 | +9 | +
| 09/05/2018 | +Balmy | +4 | +4 | +
| 10/05/2018 | +Chilly | +29 | +29 | +
This component demonstrates fetching data from the server.
+ +@if (forecasts == null) +{ +Loading...
+} +else +{ +Weather data for @(StartDate.ToString("MM/dd/yyyy"))
+| Date | +Temp. (C) | +Temp. (F) | +Summary | +
|---|---|---|---|
| @forecast.DateFormatted | +@forecast.TemperatureC | +@forecast.TemperatureF | +@forecast.Summary | +
Hello world!
\ No newline at end of file diff --git a/src/Mvc/test/WebSites/BasicWebSite/Services/WeatherForecastService.cs b/src/Mvc/test/WebSites/BasicWebSite/Services/WeatherForecastService.cs new file mode 100644 index 0000000000..5491c579ec --- /dev/null +++ b/src/Mvc/test/WebSites/BasicWebSite/Services/WeatherForecastService.cs @@ -0,0 +1,45 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using System.Net.Http; +using System.Threading.Tasks; +using Newtonsoft.Json; +using Newtonsoft.Json.Serialization; + +namespace BasicWebSite.Services +{ + public class WeatherForecastService + { + private readonly HttpClient _httpClient; + + public WeatherForecastService(HttpClient httpClient) + { + _httpClient = httpClient; + } + + public async Task