Updated Using WireMock.Net.Testcontainers (markdown)

Stef Heyenrath
2023-06-06 22:38:24 +02:00
parent a5c47b80bd
commit 60c3e3c0a5
+13
@@ -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.