mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-05-25 09:19:20 +02:00
Updated Using WireMock.Net.Testcontainers (markdown)
@@ -1 +1,30 @@
|
||||
...
|
||||
# WireMock.Net.Testcontainers
|
||||
WireMock.Net.Testcontainers uses [Testcontainers for .NET](https://dotnet.testcontainers.org/) to spinup a docker container directly from the C# (unittest) code.
|
||||
|
||||
This options requires docker service running locally.
|
||||
|
||||
Both the [Linux](https://hub.docker.com/repository/docker/sheyenrath/wiremock.net) and the [Windows](https://hub.docker.com/repository/docker/sheyenrath/wiremock.net-windows/general) version from WireMock.Net are supported.
|
||||
|
||||
## Usage
|
||||
### Build and Start
|
||||
To build a container and startup this container, use this code:
|
||||
``` C#
|
||||
var container = new WireMockContainerBuilder()
|
||||
.WithAutoRemove(true)
|
||||
.WithCleanUp(true)
|
||||
.Build();
|
||||
|
||||
await container.StartAsync().ConfigureAwait(false);
|
||||
```
|
||||
|
||||
#### Methods
|
||||
The following builder methods are available for the `WireMockContainerBuilder`:
|
||||
|
||||
| Method | Example | What |
|
||||
| - | - | - |
|
||||
| `WithMappings` | `.WithMappings(@"C:\example\\mappings")` | Specifies the path for the (static) mapping json files.
|
||||
| `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).
|
||||
|
||||
## 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.
|
||||
Reference in New Issue
Block a user