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));
        }
        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 RemoveTheConnectionCacheFromObjectFactoryAfterReturningAConnection()
 {
     _config.GetConnection();
     Assert.IsNull(ObjectFactory.TryGetInstance <IConnectionCache>());
 }