Skip to content

Commit 26e7751

Browse files
committed
docs
1 parent 3db4561 commit 26e7751

File tree

8 files changed

+167
-149
lines changed

8 files changed

+167
-149
lines changed

docs/encoding.md

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
<!--
2+
GENERATED FILE - DO NOT EDIT
3+
This file was generated by [MarkdownSnippets](https://github.com/SimonCropp/MarkdownSnippets).
4+
Source File: /docs/mdsource/encoding.source.md
5+
To change this file edit the source file and then run MarkdownSnippets.
6+
-->
7+
8+
# Encoding
9+
10+
## UseUtf8NoBom
11+
12+
The default encoding for snapshot files uses UTF-8 with byte order marks (BOM) enable. To disable UTF-8 BOMs, call `VerifierSettings.UseUtf8NoBom`.
13+
14+
<!-- snippet: UseUtf8NoBom -->
15+
<a id='snippet-UseUtf8NoBom'></a>
16+
```cs
17+
public static class ModuleInitializer
18+
{
19+
[ModuleInitializer]
20+
public static void Init() =>
21+
VerifierSettings.UseUtf8NoBom();
22+
}
23+
```
24+
<sup><a href='/src/ModuleInitDocs/UseUtf8NoBom.cs#L3-L12' title='Snippet source file'>snippet source</a> | <a href='#snippet-UseUtf8NoBom' title='Start of snippet'>anchor</a></sup>
25+
<!-- endSnippet -->
26+
27+
28+
## UseEncoding
29+
30+
To override the encoding used for snapshot files, replacing the default UTF-8 encoding, call `VerifierSettings.UseEncoding` providing a `System.Text.Encoding` instance.
31+
32+
<!-- snippet: UseEncoding -->
33+
<a id='snippet-UseEncoding'></a>
34+
```cs
35+
public static class ModuleInitializer
36+
{
37+
[ModuleInitializer]
38+
public static void Init()
39+
{
40+
var encoding = new UnicodeEncoding(
41+
bigEndian: false,
42+
byteOrderMark: true,
43+
throwOnInvalidBytes: true);
44+
VerifierSettings.UseEncoding(encoding);
45+
}
46+
}
47+
```
48+
<sup><a href='/src/ModuleInitDocs/UseEncoding.cs#L3-L18' title='Snippet source file'>snippet source</a> | <a href='#snippet-UseEncoding' title='Start of snippet'>anchor</a></sup>
49+
<!-- endSnippet -->

docs/jsonappender.md

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
<!--
2+
GENERATED FILE - DO NOT EDIT
3+
This file was generated by [MarkdownSnippets](https://github.com/SimonCropp/MarkdownSnippets).
4+
Source File: /docs/mdsource/jsonappender.source.md
5+
To change this file edit the source file and then run MarkdownSnippets.
6+
-->
7+
8+
# JsonAppender
9+
10+
A JsonAppender allows extra content (key value pairs) to be optionally appended to the output being verified. JsonAppenders can use the current context to determine what should be appended or if anything should be appended.
11+
12+
Register a JsonAppender:
13+
14+
<!-- snippet: RegisterJsonAppender -->
15+
<a id='snippet-RegisterJsonAppender'></a>
16+
```cs
17+
VerifierSettings.RegisterJsonAppender(
18+
context =>
19+
{
20+
if (ShouldInclude(context))
21+
{
22+
return new ToAppend("theData", "theValue");
23+
}
24+
25+
return null;
26+
});
27+
```
28+
<sup><a href='/src/Verify.Tests/Converters/JsonAppenderTests.cs#L7-L18' title='Snippet source file'>snippet source</a> | <a href='#snippet-RegisterJsonAppender' title='Start of snippet'>anchor</a></sup>
29+
<!-- endSnippet -->
30+
31+
When when content is verified:
32+
33+
<!-- snippet: JsonAppender -->
34+
<a id='snippet-JsonAppender'></a>
35+
```cs
36+
[Fact]
37+
public Task WithJsonAppender() =>
38+
Verify("TheValue");
39+
```
40+
<sup><a href='/src/Verify.Tests/Converters/JsonAppenderTests.cs#L30-L36' title='Snippet source file'>snippet source</a> | <a href='#snippet-JsonAppender' title='Start of snippet'>anchor</a></sup>
41+
<!-- endSnippet -->
42+
43+
The content from RegisterJsonAppender will be included in the output:
44+
45+
<!-- snippet: JsonAppenderTests.WithJsonAppender.verified.txt -->
46+
<a id='snippet-JsonAppenderTests.WithJsonAppender.verified.txt'></a>
47+
```txt
48+
{
49+
target: TheValue,
50+
theData: theValue
51+
}
52+
```
53+
<sup><a href='/src/Verify.Tests/Converters/JsonAppenderTests.WithJsonAppender.verified.txt#L1-L4' title='Snippet source file'>snippet source</a> | <a href='#snippet-JsonAppenderTests.WithJsonAppender.verified.txt' title='Start of snippet'>anchor</a></sup>
54+
<!-- endSnippet -->
55+
56+
If the target is a stream or binary file:
57+
58+
<!-- snippet: JsonAppenderStream -->
59+
<a id='snippet-JsonAppenderStream'></a>
60+
```cs
61+
[Fact]
62+
public Task Stream() =>
63+
Verify(IoHelpers.OpenRead("sample.txt"));
64+
```
65+
<sup><a href='/src/Verify.Tests/Converters/JsonAppenderTests.cs#L64-L70' title='Snippet source file'>snippet source</a> | <a href='#snippet-JsonAppenderStream' title='Start of snippet'>anchor</a></sup>
66+
<!-- endSnippet -->
67+
68+
Then the appended content will be added to the `.verified.txt` file:
69+
70+
<!-- snippet: JsonAppenderTests.Stream#00.verified.txt -->
71+
<a id='snippet-JsonAppenderTests.Stream#00.verified.txt'></a>
72+
```txt
73+
{
74+
target: null,
75+
theData: theValue
76+
}
77+
```
78+
<sup><a href='/src/Verify.Tests/Converters/JsonAppenderTests.Stream#00.verified.txt#L1-L4' title='Snippet source file'>snippet source</a> | <a href='#snippet-JsonAppenderTests.Stream#00.verified.txt' title='Start of snippet'>anchor</a></sup>
79+
<!-- endSnippet -->
80+
81+
See [Converters](/docs/converter.md) for more information on `*.00.verified.txt` files.
82+
83+
Examples of extensions using JsonAppenders are [Recorders in Verify.SqlServer](https://github.com/VerifyTests/Verify.SqlServer#recording) and [Recorders in Verify.EntityFramework](https://github.com/VerifyTests/Verify.EntityFramework#recording).

docs/mdsource/doc-index.include.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
* [Members that throw](/docs/members-throw.md)
1414
* [Ordering](/docs/ordering.md)
1515
* [Encoding](/docs/encoding.md)
16+
* [JsonAppender](/docs/jsonappender.md)
1617
* [File naming](/docs/naming.md)
1718
* [AppendFile](/docs/append-file.md)
1819
* [Parameterised tests](/docs/parameterised.md)
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# JsonAppender
2+
3+
A JsonAppender allows extra content (key value pairs) to be optionally appended to the output being verified. JsonAppenders can use the current context to determine what should be appended or if anything should be appended.
4+
5+
Register a JsonAppender:
6+
7+
snippet: RegisterJsonAppender
8+
9+
When when content is verified:
10+
11+
snippet: JsonAppender
12+
13+
The content from RegisterJsonAppender will be included in the output:
14+
15+
snippet: JsonAppenderTests.WithJsonAppender.verified.txt
16+
17+
If the target is a stream or binary file:
18+
19+
snippet: JsonAppenderStream
20+
21+
Then the appended content will be added to the `.verified.txt` file:
22+
23+
snippet: JsonAppenderTests.Stream#00.verified.txt
24+
25+
See [Converters](/docs/converter.md) for more information on `*.00.verified.txt` files.
26+
27+
Examples of extensions using JsonAppenders are [Recorders in Verify.SqlServer](https://github.com/VerifyTests/Verify.SqlServer#recording) and [Recorders in Verify.EntityFramework](https://github.com/VerifyTests/Verify.EntityFramework#recording).

docs/mdsource/serializer-settings.source.md

Lines changed: 1 addition & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -286,35 +286,6 @@ The value of a member can be mutated before serialization:
286286
snippet: MemberConverter
287287

288288

289-
## JsonAppender
290-
291-
A JsonAppender allows extra content (key value pairs) to be optionally appended to the output being verified. JsonAppenders can use the current context to determine what should be appended or if anything should be appended.
292-
293-
Register a JsonAppender:
294-
295-
snippet: RegisterJsonAppender
296-
297-
When when content is verified:
298-
299-
snippet: JsonAppender
300-
301-
The content from RegisterJsonAppender will be included in the output:
302-
303-
snippet: JsonAppenderTests.WithJsonAppender.verified.txt
304-
305-
If the target is a stream or binary file:
306-
307-
snippet: JsonAppenderStream
308-
309-
Then the appended content will be added to the `.verified.txt` file:
310-
311-
snippet: JsonAppenderTests.Stream#00.verified.txt
312-
313-
See [Converters](/docs/converter.md) for more information on `*.00.verified.txt` files.
314-
315-
Examples of extensions using JsonAppenders are [Recorders in Verify.SqlServer](https://github.com/VerifyTests/Verify.SqlServer#recording) and [Recorders in Verify.EntityFramework](https://github.com/VerifyTests/Verify.EntityFramework#recording).
316-
317-
318289
## See also
319290

320291
* [Obsolete members](/docs/obsolete-members.md)
@@ -324,3 +295,4 @@ Examples of extensions using JsonAppenders are [Recorders in Verify.SqlServer](h
324295
* [Members that throw](/docs/members-throw.md)
325296
* [Ordering](/docs/ordering.md)
326297
* [Encoding](/docs/encoding.md)
298+
* [JsonAppender](/docs/jsonappender.md)

docs/readme.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ To change this file edit the source file and then run MarkdownSnippets.
2121
* [Scrubbing](/docs/scrubbers.md)
2222
* [Members that throw](/docs/members-throw.md)
2323
* [Ordering](/docs/ordering.md)
24+
* [Encoding](/docs/encoding.md)
25+
* [JsonAppender](/docs/jsonappender.md)
2426
* [File naming](/docs/naming.md)
2527
* [AppendFile](/docs/append-file.md)
2628
* [Parameterised tests](/docs/parameterised.md)

docs/serializer-settings.md

Lines changed: 2 additions & 120 deletions
Original file line numberDiff line numberDiff line change
@@ -112,48 +112,6 @@ The resulting file will be:
112112
<!-- endSnippet -->
113113

114114

115-
## UseUtf8NoBom
116-
117-
The default encoding for snapshot files uses UTF-8 with byte order marks (BOM) enable. To disable UTF-8 BOMs, call `VerifierSettings.UseUtf8NoBom`.
118-
119-
<!-- snippet: UseUtf8NoBom -->
120-
<a id='snippet-UseUtf8NoBom'></a>
121-
```cs
122-
public static class ModuleInitializer
123-
{
124-
[ModuleInitializer]
125-
public static void Init() =>
126-
VerifierSettings.UseUtf8NoBom();
127-
}
128-
```
129-
<sup><a href='/src/ModuleInitDocs/UseUtf8NoBom.cs#L3-L12' title='Snippet source file'>snippet source</a> | <a href='#snippet-UseUtf8NoBom' title='Start of snippet'>anchor</a></sup>
130-
<!-- endSnippet -->
131-
132-
133-
## UseEncoding
134-
135-
To override the encoding used for snapshot files, replacing the default UTF-8 encoding, call `VerifierSettings.UseEncoding` providing a `System.Text.Encoding` instance.
136-
137-
<!-- snippet: UseEncoding -->
138-
<a id='snippet-UseEncoding'></a>
139-
```cs
140-
public static class ModuleInitializer
141-
{
142-
[ModuleInitializer]
143-
public static void Init()
144-
{
145-
var encoding = new UnicodeEncoding(
146-
bigEndian: false,
147-
byteOrderMark: true,
148-
throwOnInvalidBytes: true);
149-
VerifierSettings.UseEncoding(encoding);
150-
}
151-
}
152-
```
153-
<sup><a href='/src/ModuleInitDocs/UseEncoding.cs#L3-L18' title='Snippet source file'>snippet source</a> | <a href='#snippet-UseEncoding' title='Start of snippet'>anchor</a></sup>
154-
<!-- endSnippet -->
155-
156-
157115
## Default settings
158116

159117
Verify uses [Argon](https://github.com/SimonCropp/Argon) for serialization.
@@ -1309,84 +1267,6 @@ public Task MemberConverterByExpression()
13091267
<!-- endSnippet -->
13101268

13111269

1312-
## JsonAppender
1313-
1314-
A JsonAppender allows extra content (key value pairs) to be optionally appended to the output being verified. JsonAppenders can use the current context to determine what should be appended or if anything should be appended.
1315-
1316-
Register a JsonAppender:
1317-
1318-
<!-- snippet: RegisterJsonAppender -->
1319-
<a id='snippet-RegisterJsonAppender'></a>
1320-
```cs
1321-
VerifierSettings.RegisterJsonAppender(
1322-
context =>
1323-
{
1324-
if (ShouldInclude(context))
1325-
{
1326-
return new ToAppend("theData", "theValue");
1327-
}
1328-
1329-
return null;
1330-
});
1331-
```
1332-
<sup><a href='/src/Verify.Tests/Converters/JsonAppenderTests.cs#L7-L18' title='Snippet source file'>snippet source</a> | <a href='#snippet-RegisterJsonAppender' title='Start of snippet'>anchor</a></sup>
1333-
<!-- endSnippet -->
1334-
1335-
When when content is verified:
1336-
1337-
<!-- snippet: JsonAppender -->
1338-
<a id='snippet-JsonAppender'></a>
1339-
```cs
1340-
[Fact]
1341-
public Task WithJsonAppender() =>
1342-
Verify("TheValue");
1343-
```
1344-
<sup><a href='/src/Verify.Tests/Converters/JsonAppenderTests.cs#L30-L36' title='Snippet source file'>snippet source</a> | <a href='#snippet-JsonAppender' title='Start of snippet'>anchor</a></sup>
1345-
<!-- endSnippet -->
1346-
1347-
The content from RegisterJsonAppender will be included in the output:
1348-
1349-
<!-- snippet: JsonAppenderTests.WithJsonAppender.verified.txt -->
1350-
<a id='snippet-JsonAppenderTests.WithJsonAppender.verified.txt'></a>
1351-
```txt
1352-
{
1353-
target: TheValue,
1354-
theData: theValue
1355-
}
1356-
```
1357-
<sup><a href='/src/Verify.Tests/Converters/JsonAppenderTests.WithJsonAppender.verified.txt#L1-L4' title='Snippet source file'>snippet source</a> | <a href='#snippet-JsonAppenderTests.WithJsonAppender.verified.txt' title='Start of snippet'>anchor</a></sup>
1358-
<!-- endSnippet -->
1359-
1360-
If the target is a stream or binary file:
1361-
1362-
<!-- snippet: JsonAppenderStream -->
1363-
<a id='snippet-JsonAppenderStream'></a>
1364-
```cs
1365-
[Fact]
1366-
public Task Stream() =>
1367-
Verify(IoHelpers.OpenRead("sample.txt"));
1368-
```
1369-
<sup><a href='/src/Verify.Tests/Converters/JsonAppenderTests.cs#L64-L70' title='Snippet source file'>snippet source</a> | <a href='#snippet-JsonAppenderStream' title='Start of snippet'>anchor</a></sup>
1370-
<!-- endSnippet -->
1371-
1372-
Then the appended content will be added to the `.verified.txt` file:
1373-
1374-
<!-- snippet: JsonAppenderTests.Stream#00.verified.txt -->
1375-
<a id='snippet-JsonAppenderTests.Stream#00.verified.txt'></a>
1376-
```txt
1377-
{
1378-
target: null,
1379-
theData: theValue
1380-
}
1381-
```
1382-
<sup><a href='/src/Verify.Tests/Converters/JsonAppenderTests.Stream#00.verified.txt#L1-L4' title='Snippet source file'>snippet source</a> | <a href='#snippet-JsonAppenderTests.Stream#00.verified.txt' title='Start of snippet'>anchor</a></sup>
1383-
<!-- endSnippet -->
1384-
1385-
See [Converters](/docs/converter.md) for more information on `*.00.verified.txt` files.
1386-
1387-
Examples of extensions using JsonAppenders are [Recorders in Verify.SqlServer](https://github.com/VerifyTests/Verify.SqlServer#recording) and [Recorders in Verify.EntityFramework](https://github.com/VerifyTests/Verify.EntityFramework#recording).
1388-
1389-
13901270
## See also
13911271

13921272
* [Obsolete members](/docs/obsolete-members.md)
@@ -1395,3 +1275,5 @@ Examples of extensions using JsonAppenders are [Recorders in Verify.SqlServer](h
13951275
* [Scrubbing](/docs/scrubbers.md)
13961276
* [Members that throw](/docs/members-throw.md)
13971277
* [Ordering](/docs/ordering.md)
1278+
* [Encoding](/docs/encoding.md)
1279+
* [JsonAppender](/docs/jsonappender.md)

readme.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -999,6 +999,8 @@ information sources and warn about particular gotchas:
999999
* [Scrubbing](/docs/scrubbers.md)
10001000
* [Members that throw](/docs/members-throw.md)
10011001
* [Ordering](/docs/ordering.md)
1002+
* [Encoding](/docs/encoding.md)
1003+
* [JsonAppender](/docs/jsonappender.md)
10021004
* [File naming](/docs/naming.md)
10031005
* [AppendFile](/docs/append-file.md)
10041006
* [Parameterised tests](/docs/parameterised.md)

0 commit comments

Comments
 (0)