Updated Response Templating (markdown)

Stef Heyenrath
2018-12-02 15:26:49 +01:00
parent 850f8a9ce8
commit b9b9c18a68

@@ -44,7 +44,7 @@ All of the standard helpers (template functions) provided by the C# Handlebars i
It's possible to return random data using the `Random` Handlebars function.
#### Random Text
Example: to generate a random string between 8 and 20 characters, use this code in C#:
**Example**: to generate a random string between 8 and 20 characters, use this code in C#:
```csharp
var server = FluentMockServer.Start();
server
@@ -58,7 +58,24 @@ server
);
```
**Example**: to generate a random string using a Regex pattern, use this code in C#:
```csharp
var server = FluentMockServer.Start();
server
.Given(Request.Create().WithPath("/random-regex").UsingGet())
.RespondWith(Response.Create()
.WithHeader("Content-Type", "application/json")
.WithBodyAsJson(
Text = "{{Xeger \"[1-9][0-9]{3}[A-Z]{2}\"}",
)
.WithTransformer()
);
```
#### Random (all supported randomizers)
You can use the powerful Regular Expression string generator based on [Fare - Finite Automata and Regular Expressions](https://github.com/moodmosaic/Fare).
- Text Regex Pattern: `"{{Xeger Pattern=\"[1-9][0-9]{3}[A-Z]{2}"}}"`
Besides a random text string, it's also possible to generate this random data:
- Integer: `"{{Random Type=\"Integer\" Min=100 Max=999}}"`
- Guid: `"{{Random Type=\"Guid\"}}"`
@@ -67,7 +84,7 @@ Besides a random text string, it's also possible to generate this random data:
- First Name: `"{{Random Type=\"FirstName\" Male=false Female=true}}"`
- Email Address: `"{{Random Type=\"EmailAddress\"}}"`
- Text Words: `"{{Random Type=\"TextWords\" Min=10 Max=20}}"`
- Text Pattern: `"{{Random Type=\"TextPattern\" Pattern=\"\\xLLnn_**ss\\x\"}}"`
- Text Regex Pattern: `"{{Random Type=\"TextRegex\" Pattern=\"[1-9][0-9]{3}[A-Z]{2}"}}"`
- Text Lorum Ipsum: `"{{Random Type=\"TextIpsum\" Paragraphs=2}}"`
- String List: `"{{Random Type=\"StringList\" Values=[\"a\", \"b\", \"c\"]}}"`
- IPv4 Address: `"{{Random Type=\"IPv4Address\"}}"`