示例#1
0
        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)));
        }
示例#2
0
        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);
        }
示例#3
0
 public void BeforeEach(ISpecContext context)
 {
     context.ConnectionString(_connectionString);
 }
示例#4
0
 public override void BeforeEach(SimpleExecutionContext execution, ISpecContext context)
 {
     context.ConnectionString(ConnectionString);
 }