mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-01-11 22:30:41 +01:00
* WireMock.Net.Aspire * . * xxx * nuget * [CodeFactor] Apply fixes * ut * t * **WireMock.Net.Aspire** * . * t * . * . * . * TESTS * docker utils * Install .NET Aspire workload * 4 * 4! * projects: '**/test/**/*.csproj' * script: 'dotnet workload install aspire' * projects: '**/test/**/*.csproj' * coverage * WithWatchStaticMappings * Admin * typo * port * fix * . * x * ... * wait * readme * x * 2 * async * <Version>0.0.1-preview-03</Version> * ... * fix aspire * admin/pwd * Install .NET Aspire workload * 0.0.1-preview-04 * WaitForHealthAsync * ... * IsHealthyAsync * . * add eps * name: 'Execute Aspire Tests' * name: Install .NET Aspire workload * . * dotnet test * remove duplicate * . * cc * dotnet tool install --global coverlet.console * -* * merge * /d:sonar.pullrequest.provider=github * <Version>0.0.1-preview-05</Version> * // Copyright © WireMock.Net * . --------- Co-authored-by: codefactor-io <support@codefactor.io>
63 lines
1.7 KiB
C#
63 lines
1.7 KiB
C#
namespace AspireApp1.Web;
|
|
|
|
public class WeatherApiClient(HttpClient httpClient)
|
|
{
|
|
public string GetBaseAddress()
|
|
{
|
|
return httpClient.BaseAddress?.ToString() ?? "???";
|
|
}
|
|
|
|
public async Task<WeatherForecast[]> GetWeatherAsync(int maxItems = 10, CancellationToken cancellationToken = default)
|
|
{
|
|
List<WeatherForecast>? forecasts = null;
|
|
|
|
await foreach (var forecast in httpClient.GetFromJsonAsAsyncEnumerable<WeatherForecast>("/weatherforecast", cancellationToken))
|
|
{
|
|
if (forecasts?.Count >= maxItems)
|
|
{
|
|
break;
|
|
}
|
|
if (forecast is not null)
|
|
{
|
|
forecasts ??= [];
|
|
forecasts.Add(forecast);
|
|
}
|
|
}
|
|
|
|
return forecasts?.ToArray() ?? [];
|
|
}
|
|
}
|
|
|
|
public class WeatherApiClient2(HttpClient httpClient)
|
|
{
|
|
public string GetBaseAddress()
|
|
{
|
|
return httpClient.BaseAddress?.ToString() ?? "???";
|
|
}
|
|
|
|
public async Task<WeatherForecast[]> GetWeatherAsync(int maxItems = 10, CancellationToken cancellationToken = default)
|
|
{
|
|
List<WeatherForecast>? forecasts = null;
|
|
|
|
await foreach (var forecast in httpClient.GetFromJsonAsAsyncEnumerable<WeatherForecast>("/weatherforecast2", cancellationToken))
|
|
{
|
|
if (forecasts?.Count >= maxItems)
|
|
{
|
|
break;
|
|
}
|
|
if (forecast is not null)
|
|
{
|
|
forecasts ??= [];
|
|
forecasts.Add(forecast);
|
|
}
|
|
}
|
|
|
|
return forecasts?.ToArray() ?? [];
|
|
}
|
|
}
|
|
|
|
public record WeatherForecast(DateOnly Date, int TemperatureC, string? Summary)
|
|
{
|
|
public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
|
|
}
|