mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-01-11 13:00:33 +01:00
152 lines
16 KiB
Markdown
152 lines
16 KiB
Markdown
#  WireMock.Net
|
|
A C# .NET version based on [mock4net](https://github.com/alexvictoor/mock4net) which mimics functionality from the original Java based WireMock.
|
|
|
|
---
|
|
|
|
### :books: Full documentation can now be found at [wiremock.org](https://wiremock.org/dotnet)
|
|
|
|
---
|
|
|
|
## :star: Key Features
|
|
* HTTP response stubbing, matchable on URL/Path, headers, cookies and body content patterns
|
|
* Library can be used in unit tests and integration tests
|
|
* Runs as a standalone process, as windows service, as Azure/IIS or as docker
|
|
* Configurable via a fluent C# .NET API, JSON files and JSON over HTTP
|
|
* Record/playback of stubs (proxying)
|
|
* Per-request conditional proxying
|
|
* Stateful behaviour simulation
|
|
* Response templating / transformation using Handlebars and extensions
|
|
* Can be used locally or in CI/CD scenarios
|
|
* Can be used for Aspire Distributed Application testing
|
|
|
|
## :memo: Blogs
|
|
- [mstack.nl : Generate C# Code from Mapping(s)](https://mstack.nl/blog/20230201-wiremock.net-tocode)
|
|
- [mstack.nl : Chaos Engineering with Fault Injections](https://mstack.nl/blogs/wiremock-net-chaos-engineering-with-fault-injections)
|
|
- [mstack.nl : gRPC / ProtoBuf Support](https://mstack.nl/blogs/wiremock-net-grpc)
|
|
- [mstack.nl : Build and test your own .NET Aspire component](https://mstack.nl/blogs/wiremock-net-aspire-component/)
|
|
|
|
## :computer: Project Info
|
|
| | |
|
|
| --- | --- |
|
|
| ***Project*** | |
|
|
| **Chat** | [](https://slack.wiremock.org/) [](https://gitter.im/wiremock_dotnet/Lobby) |
|
|
| **Issues** | [](https://github.com/wiremock/WireMock.Net/issues) |
|
|
| | |
|
|
| ***Quality*** | |
|
|
| **Build Azure** | [](https://stef.visualstudio.com/WireMock.Net/_build/latest?definitionId=61) |
|
|
| **Quality** | [](https://sonarcloud.io/project/issues?id=WireMock-Net_WireMock.Net) [](https://www.codefactor.io/repository/github/wiremock/wiremock.net) |
|
|
| **Sonar Bugs** | [](https://sonarcloud.io/project/issues?id=WireMock-Net_WireMock.Net&resolved=false&types=BUG) [](https://sonarcloud.io/project/issues?id=WireMock-Net_WireMock.Net&resolved=false&types=CODE_SMELL) |
|
|
| **Coverage** | [](https://sonarcloud.io/component_measures?id=WireMock-Net_WireMock.Net&metric=coverage) [](https://codecov.io/gh/wiremock/WireMock.Net)|
|
|
| **TIOBE** | [TIOBE Quality Indicator](https://ticsdemo.tiobe.com/tiobeweb/DEMO/TqiDashboard.html#axes=Project(WireMock.Net),Sub()&metric=tqi)
|
|
|
|
### :package: NuGet packages
|
|
|
|
| | Official | Preview [:information_source:](https://wiremock.org/dotnet/MyGet-preview-versions) |
|
|
| - | - | - |
|
|
| **WireMock.Net** | [](https://www.nuget.org/packages/WireMock.Net) | [](https://www.myget.org/feed/wiremock-net/package/nuget/WireMock.Net)
|
|
| **WireMock.Net.Minimal** 🔺| [](https://www.nuget.org/packages/WireMock.Net.Minimal) | [](https://www.myget.org/feed/wiremock-net/package/nuget/WireMock.Net.Minimal)
|
|
| **WireMock.Net.StandAlone** | [](https://www.nuget.org/packages/WireMock.Net.StandAlone) | [](https://www.myget.org/feed/wiremock-net/package/nuget/WireMock.Net.StandAlone)
|
|
| **WireMock.Net.Testcontainers** | [](https://www.nuget.org/packages/WireMock.Net.Testcontainers) | [](https://www.myget.org/feed/wiremock-net/package/nuget/WireMock.Net.Testcontainers)
|
|
| **WireMock.Net.Aspire** | [](https://www.nuget.org/packages/WireMock.Net.Aspire) | [](https://www.myget.org/feed/wiremock-net/package/nuget/WireMock.Net.Aspire)
|
|
| **WireMock.Net.AspNetCore.Middleware** | [](https://www.nuget.org/packages/WireMock.Net.AspNetCore.Middleware) | [](https://www.myget.org/feed/wiremock-net/package/nuget/WireMock.Net.AspNetCore.Middleware)
|
|
| | | |
|
|
| **WireMock.Net.AwesomeAssertions** | [](https://www.nuget.org/packages/WireMock.Net.AwesomeAssertions) | [](https://www.myget.org/feed/wiremock-net/package/nuget/WireMock.Net.AwesomeAssertions)
|
|
| **WireMock.Net.FluentAssertions** | [](https://www.nuget.org/packages/WireMock.Net.FluentAssertions) | [](https://www.myget.org/feed/wiremock-net/package/nuget/WireMock.Net.FluentAssertions)
|
|
| **WireMock.Net.xUnit** | [](https://www.nuget.org/packages/WireMock.Net.xUnit) | [](https://www.myget.org/feed/wiremock-net/package/nuget/WireMock.Net.xUnit)
|
|
| **WireMock.Net.xUnit.v3** | [](https://www.nuget.org/packages/WireMock.Net.xUnit.v3) | [](https://www.myget.org/feed/wiremock-net/package/nuget/WireMock.Net.xUnit.v3)
|
|
| **WireMock.Net.TUnit** | [](https://www.nuget.org/packages/WireMock.Net.TUnit) | [](https://www.myget.org/feed/wiremock-net/package/nuget/WireMock.Net.TUnit)
|
|
| **WireMock.Net.NUnit** | [](https://www.nuget.org/packages/WireMock.Net.NUnit) | [](https://www.myget.org/feed/wiremock-net/package/nuget/WireMock.Net.NUnit)
|
|
| | | |
|
|
| **WireMock.Net.Extensions.Routing** | [](https://www.nuget.org/packages/WireMock.Net.Extensions.Routing) | [](https://www.myget.org/feed/wiremock-net/package/nuget/WireMock.Net.Extensions.Routing)
|
|
| **WireMock.Net.Matchers.CSharpCode** | [](https://www.nuget.org/packages/WireMock.Net.Matchers.CSharpCode) | [](https://www.myget.org/feed/wiremock-net/package/nuget/WireMock.Net.Matchers.CSharpCode)
|
|
| **WireMock.Net.OpenApiParser** | [](https://www.nuget.org/packages/WireMock.Net.OpenApiParser) | [](https://www.myget.org/feed/wiremock-net/package/nuget/WireMock.Net.OpenApiParser)
|
|
| **WireMock.Net.MimePart** | [](https://www.nuget.org/packages/WireMock.Net.MimePart) | [](https://www.myget.org/feed/wiremock-net/package/nuget/WireMock.Net.MimePart)
|
|
| **WireMock.Net.GraphQL** | [](https://www.nuget.org/packages/WireMock.Net.GraphQL) | [](https://www.myget.org/feed/wiremock-net/package/nuget/WireMock.Net.GraphQL)
|
|
| **WireMock.Net.ProtoBuf** | [](https://www.nuget.org/packages/WireMock.Net.ProtoBuf) | [](https://www.myget.org/feed/wiremock-net/package/nuget/WireMock.Net.ProtoBuf)
|
|
| | | |
|
|
| **WireMock.Net.RestClient** | [](https://www.nuget.org/packages/WireMock.Net.RestClient) | [](https://www.myget.org/feed/wiremock-net/package/nuget/WireMock.Net.RestClient)
|
|
| **WireMock.Org.RestClient** | [](https://www.nuget.org/packages/WireMock.Org.RestClient) | [](https://www.myget.org/feed/wiremock-net/package/nuget/WireMock.Org.RestClient)
|
|
|
|
<br />
|
|
|
|
🔺 **WireMock.Net.Minimal** does not include *WireMock.Net.MimePart*, *WireMock.Net.GraphQL* and *WireMock.Net.ProtoBuf*.
|
|
|
|
---
|
|
|
|
## :exclamation: Breaking changes
|
|
|
|
### 1.7.0
|
|
A breaking change is introduced which is related to System.Linq.Dynamic.Core DynamicLinq ([CVE](https://github.com/zzzprojects/System.Linq.Dynamic.Core/issues/867)).
|
|
- The `LinqMatcher` is not allowed.
|
|
- The [Handlebars.Net.Helpers.DynamicLinq](https://www.nuget.org/packages/Handlebars.Net.Helpers.DynamicLinq) package is not included anymore.
|
|
|
|
|
|
### 1.8.0
|
|
Some breaking changes are introduced in this version:
|
|
|
|
#### Handlebars.Net `File`-helper
|
|
By default, the internal Handlebars.Net `File`-helper is not allowed anymore because of potential security issues.
|
|
To still enable this feature, you need to set the `AllowedCustomHandlebarHelpers` property to `File` in the `HandlebarsSettings` property in `WireMockServerSettings`.
|
|
|
|
#### Handlebars.Net `Environment`-helper
|
|
By default, the Handlebars.Net `Environment`-helper is not automatically allowed anymore because of potential security issues.
|
|
To still enable this feature, you need to add the `Environment` category to the `AllowedHandlebarsHelpers` list-property in the `HandlebarsSettings` property in `WireMockServerSettings`.
|
|
|
|
---
|
|
|
|
## :memo: Development
|
|
For the supported frameworks and build information, see [this](https://wiremock.org/dotnet/development-information) page.
|
|
|
|
## :star: Stubbing
|
|
A core feature of WireMock.Net is the ability to return predefined HTTP responses for requests matching criteria.
|
|
See [Stubbing](https://wiremock.org/dotnet/stubbing).
|
|
|
|
## :star: Request Matching
|
|
WireMock.Net support advanced request-matching logic, see [Request Matching](https://wiremock.org/dotnet/request-matching).
|
|
|
|
## :star: Response Templating
|
|
The response which is returned WireMock.Net can be changed using templating. This is described here [Response Templating](https://wiremock.org/dotnet/response-templating).
|
|
|
|
## :star: Admin API Reference
|
|
The WireMock admin API provides functionality to define the mappings via a http interface see [Admin API Reference](https://wiremock.org/dotnet/admin-api-reference).
|
|
|
|
## :star: Using
|
|
WireMock.Net can be used in several ways:
|
|
|
|
### UnitTesting
|
|
You can use your favorite test framework and use WireMock within your tests, see
|
|
[UnitTesting](https://wiremock.org/dotnet/using-wiremock-in-unittests).
|
|
|
|
### Unit/Integration Testing using Testcontainers.DotNet
|
|
See [WireMock.Net.Testcontainers](https://wiremock.org/dotnet/using-wiremock-net-testcontainers/) on how to build a WireMock.Net Docker container which can be used in Unit/Integration testing.
|
|
|
|
### Unit/Integration Testing using an an Aspire Distributed Application
|
|
See [WireMock.Net.Aspire](https://wiremock.org/dotnet/using-wiremock-net-Aspire) on how to use WireMock.Net as an Aspire Hosted application to do Unit/Integration testing.
|
|
|
|
### As a dotnet tool
|
|
It's simple to install WireMock.Net as (global) dotnet tool, see [dotnet tool](https://wiremock.org/dotnet/wiremock-as-dotnet-tool).
|
|
|
|
### As standalone process / console application
|
|
This is quite straight forward to launch a mock server within a console application, see [Standalone Process](https://wiremock.org/dotnet/wiremock-as-a-standalone-process).
|
|
|
|
### As a Windows Service
|
|
You can also run WireMock.Net as a Windows Service, follow this [Windows Service](https://wiremock.org/dotnet/wiremock-as-a-windows-service).
|
|
|
|
### As a Web Job in Azure or application in IIS
|
|
See this link [WireMock-as-a-(Azure)-Web-App](https://wiremock.org/dotnet/wiremock-as-a-azure-web-app/)
|
|
|
|
### In a docker container
|
|
There is also a Linux and Windows-Nano container available at [hub.docker.com](https://hub.docker.com/r/sheyenrath).
|
|
For more details see also [Docker](https://github.com/wiremock/WireMock.Net-docker).
|
|
|
|
### HTTPS / SSL
|
|
More details on using HTTPS (SSL) can be found here [HTTPS](https://wiremock.org/dotnet/using-https-ssl/)
|
|
|
|
## :books: Documentation
|
|
For more info, see also this documentation page: [What is WireMock.Net](https://wiremock.org/dotnet/what-is-wiremock-net/).
|
|
|
|
---
|
|
|
|
## Powered by
|
|
[](https://jb.gg/OpenSource)
|