mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-05-25 09:19:20 +02:00
Updated Using WireMock.Net.Testcontainers (markdown)
@@ -26,5 +26,18 @@ The following builder methods are available for the `WireMockContainerBuilder`:
|
|||||||
| `WithWatchStaticMappings` | `.WithWatchStaticMappings(true)` | Watch the static mapping files + folder for changes when running.
|
| `WithWatchStaticMappings` | `.WithWatchStaticMappings(true)` | Watch the static mapping files + folder for changes when running.
|
||||||
| `WithAdminUserNameAndPassword` | `.WithAdminUserNameAndPassword("x", "y")` | Set the admin username. and password for the container (basic authentication).
|
| `WithAdminUserNameAndPassword` | `.WithAdminUserNameAndPassword("x", "y")` | Set the admin username. and password for the container (basic authentication).
|
||||||
|
|
||||||
|
### Create a Admin Client
|
||||||
|
Use the following code to get a [RestEase Admin Client](https://github.com/WireMock-Net/WireMock.Net/wiki/Admin-API-Reference#client-api) for this running container instance.
|
||||||
|
``` c#
|
||||||
|
var restEaseApiClient = container.CreateWireMockAdminClient();
|
||||||
|
```
|
||||||
|
|
||||||
|
### Create a HTTP Client
|
||||||
|
Use the following code to get a HTTP Client for this running container instance to call WireMock.Net
|
||||||
|
``` c#
|
||||||
|
var client = container.CreateClient();
|
||||||
|
var result = await client.GetStringAsync("/test123");
|
||||||
|
```
|
||||||
|
|
||||||
## Usage in Unit Test
|
## Usage in Unit Test
|
||||||
Follow the tutorial [here](https://github.com/testcontainers/testcontainers-dotnet/blob/develop/examples/WeatherForecast/tests/WeatherForecast.Tests/WeatherForecastTest.cs) and make sure to use WireMock.Net container instead of the container used in that example.
|
Follow the tutorial [here](https://github.com/testcontainers/testcontainers-dotnet/blob/develop/examples/WeatherForecast/tests/WeatherForecast.Tests/WeatherForecastTest.cs) and make sure to use WireMock.Net container instead of the container used in that example.
|
||||||
Reference in New Issue
Block a user