Skip to content

Commit

Permalink
docs
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonCropp committed Aug 12, 2020
1 parent 1fcb504 commit a559f9e
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 25 deletions.
2 changes: 1 addition & 1 deletion docs/build-server.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,5 @@ if (BuildServerDetector.Detected)
});
}
```
<sup><a href='/src/Verify.Tests/Snippets/Snippets.cs#L84-L98' title='File snippet `derivetestdirectory` was extracted from'>snippet source</a> | <a href='#snippet-derivetestdirectory' title='Navigate to start of snippet `derivetestdirectory`'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/Snippets/Snippets.cs#L83-L97' title='File snippet `derivetestdirectory` was extracted from'>snippet source</a> | <a href='#snippet-derivetestdirectory' title='Navigate to start of snippet `derivetestdirectory`'>anchor</a></sup>
<!-- endsnippet -->
6 changes: 3 additions & 3 deletions docs/clipboard.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ The clipboard behavior can be disable using the following:
var settings = new VerifySettings();
settings.DisableClipboard();
```
<sup><a href='/src/Verify.Tests/Snippets/Snippets.cs#L36-L41' title='File snippet `disableclipboard` was extracted from'>snippet source</a> | <a href='#snippet-disableclipboard' title='Navigate to start of snippet `disableclipboard`'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/Snippets/Snippets.cs#L38-L43' title='File snippet `disableclipboard` was extracted from'>snippet source</a> | <a href='#snippet-disableclipboard' title='Navigate to start of snippet `disableclipboard`'>anchor</a></sup>
<!-- endsnippet -->


Expand All @@ -77,7 +77,7 @@ settings.DisableClipboard();
```cs
VerifierSettings.DisableClipboard();
```
<sup><a href='/src/Verify.Tests/Snippets/Snippets.cs#L75-L79' title='File snippet `disableclipboardglobal` was extracted from'>snippet source</a> | <a href='#snippet-disableclipboardglobal' title='Navigate to start of snippet `disableclipboardglobal`'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/Snippets/Snippets.cs#L74-L78' title='File snippet `disableclipboardglobal` was extracted from'>snippet source</a> | <a href='#snippet-disableclipboardglobal' title='Navigate to start of snippet `disableclipboardglobal`'>anchor</a></sup>
<!-- endsnippet -->

If clipboard is disabled for all tests, it can be re-enabled at the test level:
Expand All @@ -88,7 +88,7 @@ If clipboard is disabled for all tests, it can be re-enabled at the test level:
var settings = new VerifySettings();
settings.EnableClipboard();
```
<sup><a href='/src/Verify.Tests/Snippets/Snippets.cs#L65-L70' title='File snippet `enableclipboard` was extracted from'>snippet source</a> | <a href='#snippet-enableclipboard' title='Navigate to start of snippet `enableclipboard`'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/Snippets/Snippets.cs#L64-L69' title='File snippet `enableclipboard` was extracted from'>snippet source</a> | <a href='#snippet-enableclipboard' title='Navigate to start of snippet `enableclipboard`'>anchor</a></sup>
<!-- endsnippet -->


Expand Down
14 changes: 11 additions & 3 deletions docs/mdsource/serializer-settings.source.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,19 @@ snippet: DontIgnoreFalse
snippet: ChangeDefaultsPerVerification


## Changing settings globally
## Changing Json.NET settings

To change the serialization settings for all verifications use `Global.ApplyExtraSettings()`:
Extra Json.NET settings can be made:

snippet: ExtraSettings

### Globally

snippet: ExtraSettingsGlobal


### Instance

snippet: ExtraSettingsInstance


## Scoped settings
Expand Down
39 changes: 28 additions & 11 deletions docs/serializer-settings.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ Serialization settings can be customized at three levels:
* [Dates are scrubbed](#dates-are-scrubbed)
* [Default Booleans are ignored](#default-booleans-are-ignored)
* [Change defaults at the verification level](#change-defaults-at-the-verification-level)
* [Changing settings globally](#changing-settings-globally)
* [Changing Json.NET settings](#changing-jsonnet-settings)
* [Globally](#globally)
* [Instance](#instance)
* [Scoped settings](#scoped-settings)
* [Ignoring a type](#ignoring-a-type)
* [Ignoring a instance](#ignoring-a-instance)
Expand Down Expand Up @@ -244,12 +246,30 @@ await Verifier.Verify(target, settings);
<!-- endsnippet -->


## Changing settings globally
## Changing Json.NET settings

To change the serialization settings for all verifications use `Global.ApplyExtraSettings()`:
Extra Json.NET settings can be made:

<!-- snippet: ExtraSettings -->
<a id='snippet-extrasettings'></a>

### Globally

<!-- snippet: ExtraSettingsGlobal -->
<a id='snippet-extrasettingsglobal'></a>
```cs
VerifierSettings.AddExtraSettings(_ =>
{
_.DateFormatHandling = DateFormatHandling.MicrosoftDateFormat;
_.TypeNameHandling = TypeNameHandling.All;
});
```
<sup><a href='/src/Verify.Tests/Snippets/Snippets.cs#L122-L130' title='File snippet `extrasettingsglobal` was extracted from'>snippet source</a> | <a href='#snippet-extrasettingsglobal' title='Navigate to start of snippet `extrasettingsglobal`'>anchor</a></sup>
<!-- endsnippet -->


### Instance

<!-- snippet: ExtraSettingsInstance -->
<a id='snippet-extrasettingsinstance'></a>
```cs
var settings = new VerifySettings();
settings.AddExtraSettings(_ =>
Expand All @@ -258,7 +278,7 @@ settings.AddExtraSettings(_ =>
_.TypeNameHandling = TypeNameHandling.All;
});
```
<sup><a href='/src/Verify.Tests/Snippets/Snippets.cs#L123-L132' title='File snippet `extrasettings` was extracted from'>snippet source</a> | <a href='#snippet-extrasettings' title='Navigate to start of snippet `extrasettings`'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/Snippets/Snippets.cs#L132-L141' title='File snippet `extrasettingsinstance` was extracted from'>snippet source</a> | <a href='#snippet-extrasettingsinstance' title='Navigate to start of snippet `extrasettingsinstance`'>anchor</a></sup>
<!-- endsnippet -->


Expand Down Expand Up @@ -703,10 +723,7 @@ Extra types can be added to this mapping:
<a id='snippet-treatasstring'></a>
```cs
VerifierSettings.TreatAsString<ClassWithToString>(
(target, settings) =>
{
return target.Property;
});
(target, settings) => { return target.Property; });
```
<sup><a href='/src/Verify.Tests/Snippets/Snippets.cs#L46-L54' title='File snippet `treatasstring` was extracted from'>snippet source</a> | <a href='#snippet-treatasstring' title='Navigate to start of snippet `treatasstring`'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/Snippets/Snippets.cs#L48-L53' title='File snippet `treatasstring` was extracted from'>snippet source</a> | <a href='#snippet-treatasstring' title='Navigate to start of snippet `treatasstring`'>anchor</a></sup>
<!-- endsnippet -->
4 changes: 2 additions & 2 deletions docs/verify-options.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ This can be done using `AutoVerify()`:
var settings = new VerifySettings();
settings.AutoVerify();
```
<sup><a href='/src/Verify.Tests/Snippets/Snippets.cs#L103-L108' title='File snippet `autoverify` was extracted from'>snippet source</a> | <a href='#snippet-autoverify' title='Navigate to start of snippet `autoverify`'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/Snippets/Snippets.cs#L102-L107' title='File snippet `autoverify` was extracted from'>snippet source</a> | <a href='#snippet-autoverify' title='Navigate to start of snippet `autoverify`'>anchor</a></sup>
<!-- endsnippet -->

Note that auto accepted changes in `.verified.` files remain visible in source control tooling.
Expand Down Expand Up @@ -57,5 +57,5 @@ public async Task OnHandlersSample()
await Verifier.Verify("value", settings);
}
```
<sup><a href='/src/Verify.Tests/Snippets/Snippets.cs#L12-L32' title='File snippet `onhandlers` was extracted from'>snippet source</a> | <a href='#snippet-onhandlers' title='Navigate to start of snippet `onhandlers`'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/Snippets/Snippets.cs#L12-L34' title='File snippet `onhandlers` was extracted from'>snippet source</a> | <a href='#snippet-onhandlers' title='Navigate to start of snippet `onhandlers`'>anchor</a></sup>
<!-- endsnippet -->
19 changes: 14 additions & 5 deletions src/Verify.Tests/Snippets/Snippets.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
public class Snippets
{
#region OnHandlers

public async Task OnHandlersSample()
{
var settings = new VerifySettings();
Expand All @@ -29,6 +30,7 @@ public async Task OnHandlersSample()
});
await Verifier.Verify("value", settings);
}

#endregion

void DisableClipboard()
Expand All @@ -46,10 +48,7 @@ void TreatAsString()
#region TreatAsString

VerifierSettings.TreatAsString<ClassWithToString>(
(target, settings) =>
{
return target.Property;
});
(target, settings) => { return target.Property; });

#endregion
}
Expand Down Expand Up @@ -120,7 +119,17 @@ void DisableDiff()

void ApplyExtraSettingsSample()
{
#region ExtraSettings
#region ExtraSettingsGlobal

VerifierSettings.AddExtraSettings(_ =>
{
_.DateFormatHandling = DateFormatHandling.MicrosoftDateFormat;
_.TypeNameHandling = TypeNameHandling.All;
});

#endregion

#region ExtraSettingsInstance

var settings = new VerifySettings();
settings.AddExtraSettings(_ =>
Expand Down

0 comments on commit a559f9e

Please sign in to comment.