Skip to content

Commit e4c1450

Browse files
committed
docs
1 parent 8b01714 commit e4c1450

11 files changed

+205
-145
lines changed

docs/autoverify.md

+129
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
<!--
2+
GENERATED FILE - DO NOT EDIT
3+
This file was generated by [MarkdownSnippets](https://github.com/SimonCropp/MarkdownSnippets).
4+
Source File: /docs/mdsource/autoverify.source.md
5+
To change this file edit the source file and then run MarkdownSnippets.
6+
-->
7+
8+
# AutoVerify
9+
10+
In some scenarios it makes sense to auto-accept any changes as part of a given test run. For example:
11+
12+
* Keeping a text representation of a Database schema in a `.verified.sql` file (see [Verify.SqlServer](https://github.com/VerifyTests/Verify.SqlServer)).
13+
14+
Note that auto accepted changes in `.verified.` files remain visible in source control tooling.
15+
16+
This can be done using `AutoVerify()`:
17+
18+
19+
### Instance
20+
21+
<!-- snippet: AutoVerify -->
22+
<a id='snippet-AutoVerify'></a>
23+
```cs
24+
var settings = new VerifySettings();
25+
settings.AutoVerify();
26+
```
27+
<sup><a href='/src/Verify.Tests/Snippets/Snippets.cs#L59-L64' title='Snippet source file'>snippet source</a> | <a href='#snippet-AutoVerify' title='Start of snippet'>anchor</a></sup>
28+
<!-- endSnippet -->
29+
30+
31+
### Fluent
32+
33+
<!-- snippet: AutoVerifyFluent -->
34+
<a id='snippet-AutoVerifyFluent'></a>
35+
```cs
36+
[Fact]
37+
public Task AutoVerifyFluent() =>
38+
Verify("Value")
39+
.AutoVerify();
40+
```
41+
<sup><a href='/src/Verify.Tests/Snippets/Snippets.cs#L79-L86' title='Snippet source file'>snippet source</a> | <a href='#snippet-AutoVerifyFluent' title='Start of snippet'>anchor</a></sup>
42+
<!-- endSnippet -->
43+
44+
45+
### Globally
46+
47+
<!-- snippet: StaticAutoVerify -->
48+
<a id='snippet-StaticAutoVerify'></a>
49+
```cs
50+
public static class ModuleInitializer
51+
{
52+
[ModuleInitializer]
53+
public static void Init() =>
54+
VerifierSettings.AutoVerify();
55+
}
56+
```
57+
<sup><a href='/src/ModuleInitDocs/AutoVerify.cs#L3-L12' title='Snippet source file'>snippet source</a> | <a href='#snippet-StaticAutoVerify' title='Start of snippet'>anchor</a></sup>
58+
<!-- endSnippet -->
59+
60+
61+
### With a delegate
62+
63+
AutoVerify supports passing a delegate to control what subset of files to AutoVerify based on file path.
64+
65+
66+
### Instance
67+
68+
<!-- snippet: AutoVerifyDelegate -->
69+
<a id='snippet-AutoVerifyDelegate'></a>
70+
```cs
71+
var settings = new VerifySettings();
72+
settings.AutoVerify(
73+
verifiedFile =>
74+
Path.GetExtension(verifiedFile) == "png");
75+
```
76+
<sup><a href='/src/Verify.Tests/Snippets/Snippets.cs#L69-L76' title='Snippet source file'>snippet source</a> | <a href='#snippet-AutoVerifyDelegate' title='Start of snippet'>anchor</a></sup>
77+
<!-- endSnippet -->
78+
79+
80+
### Fluent
81+
82+
<!-- snippet: AutoVerifyFluentDelegate -->
83+
<a id='snippet-AutoVerifyFluentDelegate'></a>
84+
```cs
85+
[Fact]
86+
public Task AutoVerifyFluentDelegate() =>
87+
Verify("Value")
88+
.AutoVerify(
89+
verifiedFile =>
90+
Path.GetExtension(verifiedFile) == "png");
91+
```
92+
<sup><a href='/src/Verify.Tests/Snippets/Snippets.cs#L107-L116' title='Snippet source file'>snippet source</a> | <a href='#snippet-AutoVerifyFluentDelegate' title='Start of snippet'>anchor</a></sup>
93+
<!-- endSnippet -->
94+
95+
96+
### Globally
97+
98+
<!-- snippet: StaticAutoVerifyDelegate -->
99+
<a id='snippet-StaticAutoVerifyDelegate'></a>
100+
```cs
101+
public static class ModuleInitializer
102+
{
103+
[ModuleInitializer]
104+
public static void Init() =>
105+
VerifierSettings.AutoVerify(
106+
(typeName, methodName, verifiedFile) =>
107+
Path.GetExtension(verifiedFile) == "png");
108+
}
109+
```
110+
<sup><a href='/src/ModuleInitDocs/AutoVerifyDelegate.cs#L4-L15' title='Snippet source file'>snippet source</a> | <a href='#snippet-StaticAutoVerifyDelegate' title='Start of snippet'>anchor</a></sup>
111+
<!-- endSnippet -->
112+
113+
114+
## AutoVerify on the build server
115+
116+
By default the same AutoVerify behavior applies both to local test runs and on the build server. To opt out of AutoVerify on the build server use `includeBuildServer: false`:
117+
118+
<!-- snippet: AutoVerifyIncludeBuildServer -->
119+
<a id='snippet-AutoVerifyIncludeBuildServer'></a>
120+
```cs
121+
[Fact]
122+
public Task AutoVerifyIncludeBuildServer() =>
123+
Verify("Value")
124+
.AutoVerify(includeBuildServer: false);
125+
```
126+
<sup><a href='/src/Verify.Tests/Snippets/Snippets.cs#L89-L96' title='Snippet source file'>snippet source</a> | <a href='#snippet-AutoVerifyIncludeBuildServer' title='Start of snippet'>anchor</a></sup>
127+
<!-- endSnippet -->
128+
129+
This can be helpful when the requirement is to minimize the friction of accepting frequent local changes, but once checked in to source control then changes to any verified file should fail a test

docs/mdsource/autoverify.source.md

+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# AutoVerify
2+
3+
In some scenarios it makes sense to auto-accept any changes as part of a given test run. For example:
4+
5+
* Keeping a text representation of a Database schema in a `.verified.sql` file (see [Verify.SqlServer](https://github.com/VerifyTests/Verify.SqlServer)).
6+
7+
Note that auto accepted changes in `.verified.` files remain visible in source control tooling.
8+
9+
This can be done using `AutoVerify()`:
10+
11+
12+
### Instance
13+
14+
snippet: AutoVerify
15+
16+
17+
### Fluent
18+
19+
snippet: AutoVerifyFluent
20+
21+
22+
### Globally
23+
24+
snippet: StaticAutoVerify
25+
26+
27+
### With a delegate
28+
29+
AutoVerify supports passing a delegate to control what subset of files to AutoVerify based on file path.
30+
31+
32+
### Instance
33+
34+
snippet: AutoVerifyDelegate
35+
36+
37+
### Fluent
38+
39+
snippet: AutoVerifyFluentDelegate
40+
41+
42+
### Globally
43+
44+
snippet: StaticAutoVerifyDelegate
45+
46+
47+
## AutoVerify on the build server
48+
49+
By default the same AutoVerify behavior applies both to local test runs and on the build server. To opt out of AutoVerify on the build server use `includeBuildServer: false`:
50+
51+
snippet: AutoVerifyIncludeBuildServer
52+
53+
This can be helpful when the requirement is to minimize the friction of accepting frequent local changes, but once checked in to source control then changes to any verified file should fail a test

docs/mdsource/doc-index.include.md

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
* [Clipboard](/docs/clipboard.md)
22
* [Compared to assertions](/docs/compared-to-assertion.md)
33
* [Verify options](/docs/verify-options.md)
4+
* [AutoVerify](/docs/autoverify.md)
45
* [VerifyDirectory](/docs/verify-directory.md)
56
* [VerifyZip](/docs/verify-zip.md)
67
* [VerifyFile](/docs/verify-file.md)

docs/mdsource/verify-options.source.md

+1-39
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,6 @@
11
# Verify Options
22

33

4-
## AutoVerify
5-
6-
In some scenarios it makes sense to auto-accept any changes as part of a given test run. For example:
7-
8-
* Keeping a text representation of a Database schema in a `.verified.sql` file (see [Verify.SqlServer](https://github.com/VerifyTests/Verify.SqlServer)).
9-
10-
Note that auto accepted changes in `.verified.` files remain visible in source control tooling.
11-
12-
This can be done using `AutoVerify()`:
13-
14-
15-
### Instance
16-
17-
snippet: AutoVerify
18-
19-
Or with a delegate:
20-
21-
snippet: AutoVerifyDelegate
22-
23-
24-
### Fluent
25-
26-
snippet: AutoVerifyFluent
27-
28-
Or with a delegate:
29-
30-
snippet: AutoVerifyFluentDelegate
31-
32-
33-
### Globally
34-
35-
snippet: StaticAutoVerify
36-
37-
Or with a delegate:
38-
39-
snippet: StaticAutoVerifyDelegate
40-
41-
424
## OnHandlers
435

446
* `OnVerify` takes two actions that are called before and after each verification.
@@ -48,7 +10,7 @@ snippet: StaticAutoVerifyDelegate
4810

4911
### AutoVerify
5012

51-
OnHandlers are called before AutoVerify logic being applied. So for example in the case of `OnVerifyMismatch`, both the received and verified file will exist at the point `OnVerifyMismatch` is called. Immediately after received will be used to overwrite verified.
13+
OnHandlers are called before [AutoVerify](autoverify.md) logic being applied. So for example in the case of `OnVerifyMismatch`, both the received and verified file will exist at the point `OnVerifyMismatch` is called. Immediately after received will be used to overwrite verified.
5214

5315

5416
### Globally

docs/readme.md

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ To change this file edit the source file and then run MarkdownSnippets.
1010
* [Clipboard](/docs/clipboard.md)<!-- include: doc-index. path: /docs/mdsource/doc-index.include.md -->
1111
* [Compared to assertions](/docs/compared-to-assertion.md)
1212
* [Verify options](/docs/verify-options.md)
13+
* [AutoVerify](/docs/autoverify.md)
1314
* [VerifyDirectory](/docs/verify-directory.md)
1415
* [VerifyZip](/docs/verify-zip.md)
1516
* [VerifyFile](/docs/verify-file.md)

docs/serializer-settings.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ Extra Json.NET settings can be made:
221221
VerifierSettings.AddExtraSettings(
222222
_ => _.TypeNameHandling = TypeNameHandling.All);
223223
```
224-
<sup><a href='/src/Verify.Tests/Snippets/Snippets.cs#L120-L125' title='Snippet source file'>snippet source</a> | <a href='#snippet-ExtraSettingsGlobal' title='Start of snippet'>anchor</a></sup>
224+
<sup><a href='/src/Verify.Tests/Snippets/Snippets.cs#L130-L135' title='Snippet source file'>snippet source</a> | <a href='#snippet-ExtraSettingsGlobal' title='Start of snippet'>anchor</a></sup>
225225
<!-- endSnippet -->
226226

227227

@@ -234,7 +234,7 @@ var settings = new VerifySettings();
234234
settings.AddExtraSettings(
235235
_ => _.TypeNameHandling = TypeNameHandling.All);
236236
```
237-
<sup><a href='/src/Verify.Tests/Snippets/Snippets.cs#L127-L133' title='Snippet source file'>snippet source</a> | <a href='#snippet-ExtraSettingsInstance' title='Start of snippet'>anchor</a></sup>
237+
<sup><a href='/src/Verify.Tests/Snippets/Snippets.cs#L137-L143' title='Snippet source file'>snippet source</a> | <a href='#snippet-ExtraSettingsInstance' title='Start of snippet'>anchor</a></sup>
238238
<!-- endSnippet -->
239239

240240

@@ -252,7 +252,7 @@ class CompanyConverter :
252252
writer.WriteMember(company, company.Name, "Name");
253253
}
254254
```
255-
<sup><a href='/src/Verify.Tests/Snippets/Snippets.cs#L143-L152' title='Snippet source file'>snippet source</a> | <a href='#snippet-CompanyConverter' title='Start of snippet'>anchor</a></sup>
255+
<sup><a href='/src/Verify.Tests/Snippets/Snippets.cs#L153-L162' title='Snippet source file'>snippet source</a> | <a href='#snippet-CompanyConverter' title='Start of snippet'>anchor</a></sup>
256256
<!-- endSnippet -->
257257

258258
<!-- snippet: JsonConverter -->
@@ -261,7 +261,7 @@ class CompanyConverter :
261261
VerifierSettings.AddExtraSettings(
262262
_ => _.Converters.Add(new CompanyConverter()));
263263
```
264-
<sup><a href='/src/Verify.Tests/Snippets/Snippets.cs#L137-L140' title='Snippet source file'>snippet source</a> | <a href='#snippet-JsonConverter' title='Start of snippet'>anchor</a></sup>
264+
<sup><a href='/src/Verify.Tests/Snippets/Snippets.cs#L147-L150' title='Snippet source file'>snippet source</a> | <a href='#snippet-JsonConverter' title='Start of snippet'>anchor</a></sup>
265265
<!-- endSnippet -->
266266

267267

docs/type-to-string-mapping.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ The default TreatAsString behavior can be overridden:
305305
VerifierSettings.TreatAsString<DateTime>(
306306
(target, settings) => target.ToString("D"));
307307
```
308-
<sup><a href='/src/Verify.Tests/Snippets/Snippets.cs#L90-L93' title='Snippet source file'>snippet source</a> | <a href='#snippet-OverrideTreatAsStringDefaults' title='Start of snippet'>anchor</a></sup>
308+
<sup><a href='/src/Verify.Tests/Snippets/Snippets.cs#L100-L103' title='Snippet source file'>snippet source</a> | <a href='#snippet-OverrideTreatAsStringDefaults' title='Start of snippet'>anchor</a></sup>
309309
<!-- endSnippet -->
310310

311311

0 commit comments

Comments
 (0)