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 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();
        }
Exemplo n.º 3
0
        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 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 NotSetANewConnectionWhenConnectionCacheIsEmptyAndNotInMemoryDatabase()
        {
            InitCache();
            var conn = Isolate.Fake.Instance <SQLiteConnection>();

            Isolate.Swap.NextInstance <SQLiteConnection>().With(conn);

            _config = new SqLiteConfig("Not an in memory connection string");
            _config.GetConnection();
            Isolate.Verify.WasNotCalled(() => _cache.SetConnection(_connection));
        }
Exemplo n.º 6
0
        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 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 UseTheHttpSessionCollectionToStoreAConnection()
 {
     _cache.SetConnection(_connection);
     Isolate.Verify.WasCalledWithExactArguments(() => _session[HttpSessionStateCache.ConnectionSetting] = _connection);
 }