Skip to content

Commit ef20601

Browse files
committed
docs: update Mockaco documentation with template creation details and example
1 parent e739cc7 commit ef20601

File tree

1 file changed

+28
-1
lines changed

1 file changed

+28
-1
lines changed

docs/modules/mockaco.md

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,31 @@
22

33
[Mockaco](https://natenho.github.io/Mockaco/) is a HTTP-based API mock server for .NET Core applications. It's designed to be simple, lightweight, and easy to use for testing and development purposes.
44

5+
## Prerequisites
6+
7+
Before using Mockaco, you need to create mock templates (JSON files) that define the API endpoints and their responses. These templates should be placed in a folder that will be mounted to the container.
8+
9+
Create a template file (e.g., `ping-pong.json`) in your templates folder:
10+
11+
```json title="./templates/ping-pong.json"
12+
{
13+
"request": {
14+
"method": "GET",
15+
"route": "ping"
16+
},
17+
"response": {
18+
"status": "OK",
19+
"body": {
20+
"response": "pong"
21+
}
22+
}
23+
}
24+
```
25+
26+
For more information about creating templates, see the [official Mockaco documentation](https://natenho.github.io/Mockaco/docs/quick-start/create-mock).
27+
28+
## Installation
29+
530
Add the following dependency to your project file:
631

732
```shell title="NuGet"
@@ -10,12 +35,14 @@ dotnet add package Testcontainers.Mockaco
1035

1136
You can start a Mockaco container instance from any .NET application. This example uses xUnit.net's `IAsyncLifetime` interface to manage the lifecycle of the container. The container is started in the `InitializeAsync` method before the test method runs, ensuring that the environment is ready for testing. After the test completes, the container is removed in the `DisposeAsync` method.
1237

38+
**Note:** The `WithTemplatesPath()` method specifies the local folder containing your JSON template files, which will be mounted to the container's `/app/Mocks` directory.
39+
1340
=== "Test class"
1441
```csharp
1542
public sealed class MockacoContainerTest : IAsyncLifetime
1643
{
1744
private readonly MockacoContainer _mockacoContainer = new MockacoBuilder()
18-
.WithTemplatesPath("./templates")
45+
.WithTemplatesPath("./templates") // Local folder with JSON templates
1946
.Build();
2047

2148
public async ValueTask InitializeAsync()

0 commit comments

Comments
 (0)