public static CommandRunner RetrieveOrBuildCommandRunner(this ISpecContext context, ISqlDialect dialect) { var connectionString = context.ConnectionString(); if (connectionString.IsEmpty()) { throw new InvalidOperationException($"No connection string is known. Use {nameof(ISpecContext)}.{nameof(SpecContextExtensions.ConnectionString)}(connection string) in your system bootstrapping"); } return(context.State.RetrieveOrAdd(() => new CommandRunner(connectionString, dialect))); }
public static CommandRunner RetrieveOrBuildCommandRunner(this ISpecContext context, ISqlDialect dialect) { var connectionString = context.ConnectionString(); if (connectionString.IsEmpty()) { throw new InvalidOperationException($"No connection string is known. Use {nameof(ISpecContext)}.{nameof(SpecContextExtensions.ConnectionString)}(connection string) in your system bootstrapping"); } var commandRunner = context.State.TryRetrieve <CommandRunner>(); if (commandRunner == default(CommandRunner) || commandRunner.IsConnectionDisposed) { commandRunner = new CommandRunner(connectionString, dialect); context.State.Store(commandRunner); } return(commandRunner); }
public void BeforeEach(ISpecContext context) { context.ConnectionString(_connectionString); }
public override void BeforeEach(SimpleExecutionContext execution, ISpecContext context) { context.ConnectionString(ConnectionString); }