Skip to content

Settings

Simon Laing edited this page Nov 6, 2020 · 3 revisions

Settings can be defined per Database scope or globally. The settings that are available are described below.

To provide settings per Database, pass an instance of the Settings object to the MockConnection constructor.

To define global settings, update the properties on the Settings.Default instance.

Settings

ResetDapperCachePerCommand

After every DB command reset the dapper cache of commands. This allows for some commands to be more accurately verified when there are very similar input or type parameters

SqlParametersBuilder

A type that can support building the params (parameters) type in a different way. By default an anonymous object will be dynamically built and then passed to the verifiable method.

SqlTextComparer

A comparer that allows for flexible SQL comparison. This, by default, ignores white space at the start and end of each line. Replace this to vary the comparison on SQL text.

IdentityComparer

This type provides comparison of the Dapper command Identity type. Replace this comparer if you want to vary the comparison method.

Unresolved

Where dapper parameters cannot be resolved, these settings will be used to fill in the blanks.

PreferCommandDefinitions

Reverse engineering dapper calls from command invocations can result in ambiguous dapper method calls, where one can be for an overload which takes a CommandDefinition and one which doesn't. This setting allows control over which overload should be preferred.

By default CommandDefinition overloads are unfavoured.