Class SqlOptions
Configures how ProtoTest owns and isolates a database connection during a test.
public sealed class SqlOptions : IProtoConfigurableOptions
- Inheritance
-
SqlOptions
- Implements
- Inherited Members
- Extension Methods
Fields
ConfigurationSectionName
public const string ConfigurationSectionName = "ProtoTest:Sql"
Field Value
Properties
AddressKeys
The configuration keys that can provide the connection. When at least one is declared and none
is provided - no configured value and no registered infrastructure piece declares it - the SQL
capability is absent and the integration is inert until a key exists: the connection is not
opened during setup, and SqlSession(ProtoExecutionContext)
and its siblings throw naming the keys and the
[RequiresCapability(ProtoCapabilityKinds.Store)] gate. Empty by default: the capability
stays unconditional and the factory owns the address.
public SqlAddressKeys AddressKeys { get; }
Property Value
Remarks
Declare the keys in the AddSql callback, for example
sql => sql.AddressKeys.Add("ConnectionStrings:Orders"). The set is a code API and is
never bound from configuration, because the capability decision is made when the host is built,
before options bind. AddEntityFrameworkCore declares its store capability over the same
keys when it is called after AddSql.
Isolation
Gets or sets the isolation applied to each test. Defaults to Transaction.
public SqlIsolation Isolation { get; set; }
Property Value
SharedWith
Gets the applications declared as using the test's connection.
public IReadOnlyCollection<string> SharedWith { get; }
Property Value
SharedWithApplications
Gets or sets the applications declared as sharing the test's connection, for configuration
binding (ProtoTest:Sql:SharedWithApplications). Prefer ShareConnectionWith(params string[]).
public List<string> SharedWithApplications { get; set; }
Property Value
Methods
ShareConnectionWith(params string[])
Declares that an application uses the connection ProtoTest owns, so Transaction rolls back the application's writes too. When the host registers applications, every one of them must be declared for the transaction strategy to run.
public SqlOptions ShareConnectionWith(params string[] applicationNames)
Parameters
applicationNamesstring[]
Returns
SharesConnectionWith(string)
Returns whether an application was declared as sharing the test's connection.
public bool SharesConnectionWith(string applicationName)
Parameters
applicationNamestring