private IDbConnection ReturnConnectionFromCache(IConnectionCache cache) { if (cache.HasNoConnection) { cache.SetConnection(new SQLiteConnection(_connectionString)); } if (cache.GetConnection().State == ConnectionState.Closed) cache.GetConnection().Open(); return cache.GetConnection(); }
private IDbConnection ReturnConnectionFromCache(IConnectionCache cache) { if (cache.HasNoConnection) { cache.SetConnection(new SQLiteConnection(_connectionString)); } if (cache.GetConnection().State == ConnectionState.Closed) { cache.GetConnection().Open(); } return(cache.GetConnection()); }
public void UseAConnectionCacheToGetTheConnectionIfHasConnection() { Isolate.WhenCalled(() => _cache.HasNoConnection).WillReturn(false); Assert.AreEqual(_connection, _config.GetConnection()); Isolate.Verify.WasCalledWithAnyArguments(() => _cache.GetConnection()); }
public void Init() { _cache = Isolate.Fake.Instance <IConnectionCache>(); _connection = Isolate.Fake.Instance <IDbConnection>(); Isolate.WhenCalled(() => _cache.SetConnection(_connection)).IgnoreCall(); Isolate.WhenCalled(() => _cache.GetConnection()).WillReturn(_connection); InitCache(); _config = new SqLiteConfig(); }
public void Init() { _cache = Isolate.Fake.Instance<IConnectionCache>(); _connection = Isolate.Fake.Instance<IDbConnection>(); Isolate.WhenCalled(() => _cache.SetConnection(_connection)).IgnoreCall(); Isolate.WhenCalled(() => _cache.GetConnection()).WillReturn(_connection); InitCache(); _config = new SqLiteConfig(); }
public void SetANewConnectionWhenConnectionCacheIsEmptyAndInMemoryDatabase() { Isolate.CleanUp(); _cache = Isolate.Fake.Instance <IConnectionCache>(); _connection = Isolate.Fake.Instance <IDbConnection>(); Isolate.WhenCalled(() => _cache.HasNoConnection).WillReturn(true); Isolate.WhenCalled(() => _cache.GetConnection()).WillReturn(_connection); Isolate.WhenCalled(() => _cache.SetConnection(_connection)).IgnoreCall(); Isolate.WhenCalled(() => _connection.ConnectionString).WillReturn(SqLiteConfig.InMemoryDbConnectionString); InitCache(); _config = new SqLiteConfig(); _config.GetConnection(); Isolate.Verify.WasCalledWithAnyArguments(() => _cache.SetConnection(_connection)); }
private static IDbConnection GetConnectionFromSessionState(IConnectionCache cache) { return cache.GetConnection(); }
public void SetANewConnectionWhenConnectionCacheIsEmptyAndInMemoryDatabase() { Isolate.CleanUp(); _cache = Isolate.Fake.Instance<IConnectionCache>(); _connection = Isolate.Fake.Instance<IDbConnection>(); Isolate.WhenCalled(() => _cache.HasNoConnection).WillReturn(true); Isolate.WhenCalled(() => _cache.GetConnection()).WillReturn(_connection); Isolate.WhenCalled(() => _cache.SetConnection(_connection)).IgnoreCall(); Isolate.WhenCalled(() => _connection.ConnectionString).WillReturn(SqLiteConfig.InMemoryDbConnectionString); InitCache(); _config = new SqLiteConfig(); _config.GetConnection(); Isolate.Verify.WasCalledWithAnyArguments(() => _cache.SetConnection(_connection)); }
public void UseTheHttpSessionCollectionToRetrieveAConnection() { _cache.GetConnection(); Isolate.Verify.WasCalledWithAnyArguments(() => _session[HttpSessionStateCache.ConnectionSetting]); }
private static IDbConnection GetConnectionFromSessionState(IConnectionCache cache) { return(cache.GetConnection()); }