Files
WireMock.Net-wiremock/examples-Aspire/AspireApp1.AppHost/WeatherForecastApiMock.cs
Stef Heyenrath 2a19b4491f WireMock.Net.Testcontainers: implement watching the static mapping folder for changes (#1189)
* WireMock.Net.Testcontainers: implement watching the static mapping files + folder for changes

* ReloadStaticMappings

* fix

* .

* .

* .

* .

* .

* .

* .

* CopyAsync

* <VersionPrefix>1.6.7-preview-02</VersionPrefix>

* <VersionPrefix>1.6.7-preview-03</VersionPrefix>
2024-12-15 11:31:25 +01:00

36 lines
1.3 KiB
C#

using WireMock.Client.Builders;
namespace AspireApp1.AppHost;
internal class WeatherForecastApiMock
{
public static async Task BuildAsync(AdminApiMappingBuilder builder, CancellationToken cancellationToken)
{
var summaries = new[]
{
"Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
};
builder.Given(b => b
.WithRequest(request => request
.UsingGet()
.WithPath("/weatherforecast2")
)
.WithResponse(response => response
.WithHeaders(h => h.Add("Content-Type", "application/json"))
.WithBodyAsJson(() => Enumerable.Range(1, 5).Select(index =>
new WeatherForecast
(
DateOnly.FromDateTime(DateTime.Now.AddDays(index)),
Random.Shared.Next(-20, 55),
"WireMock.Net 2 : " + summaries[Random.Shared.Next(summaries.Length)]
))
.ToArray())
)
);
await builder.BuildAndPostAsync(cancellationToken);
}
}
internal record WeatherForecast(DateOnly Date, int TemperatureC, string? Summary);