Beispiel #1
0
        public RecipePersistenceService(IMvxSqliteConnectionFactory connectionFactory,
                                        ICultureProvider cultureProvider,
                                        IReferenceBookService referenceBook,
                                        DatabaseSettings settings)
        {
            if (connectionFactory == null)
            {
                throw new ArgumentNullException(nameof(connectionFactory));
            }
            if (cultureProvider == null)
            {
                throw new ArgumentNullException(nameof(cultureProvider));
            }
            if (settings == null)
            {
                throw new ArgumentNullException(nameof(settings));
            }
            if (referenceBook == null)
            {
                throw new ArgumentNullException(nameof(referenceBook));
            }
            _referenceBook = referenceBook;
            var config = new SqLiteConfig(settings.DatabaseName, serializer: new JsonBlobSerializer());

            _connection  = connectionFactory.GetConnectionWithLock(config);
            _queryParser = new QueryParser(cultureProvider);
        }
        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));
        }
        public void RecreateDatabase()
        {
            Connection?.Close();
            var name = ConnectionFactory.GetPlattformDatabasePath(DatabaseName);

            File.Delete(name);
            using (var updater = new UpdateService(ConnectionFactory, new ConsoleTrace(), DatabaseSettings))
            {
                updater.UpdateToLatestVersion();
            }
            var config = new SqLiteConfig(DatabaseName, serializer: new JsonBlobSerializer());

            Connection = ConnectionFactory.GetConnection(config);
        }
        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));
        }
Beispiel #6
0
        public UpdateService(IMvxSqliteConnectionFactory factory, IMvxTrace trace, DatabaseSettings settings)
        {
            if (factory == null)
            {
                throw new ArgumentNullException(nameof(factory));
            }
            if (trace == null)
            {
                throw new ArgumentNullException(nameof(trace));
            }
            if (settings == null)
            {
                throw new ArgumentNullException(nameof(settings));
            }
            var config = new SqLiteConfig(settings.DatabaseName, serializer: new JsonBlobSerializer());

            _connection = factory.GetConnectionWithLock(config);
            _updater    = new Updater(typeof(DatabaseSchemaInitialUpdate).GetTypeInfo().Assembly, _connection, trace);
        }
Beispiel #7
0
        public SearchService(IMvxSqliteConnectionFactory connectionFactory, ICultureProvider cultureProvider, DatabaseSettings settings)
        {
            if (connectionFactory == null)
            {
                throw new ArgumentNullException(nameof(connectionFactory));
            }
            if (cultureProvider == null)
            {
                throw new ArgumentNullException(nameof(cultureProvider));
            }
            if (settings == null)
            {
                throw new ArgumentNullException(nameof(settings));
            }
            _cultureProvider = cultureProvider;
            _parser          = new QueryParser(cultureProvider);
            var config = new SqLiteConfig(settings.DatabaseName, serializer: new JsonBlobSerializer());

            _connection = connectionFactory.GetConnectionWithLock(config);
        }
Beispiel #8
0
 public void CreateNewSqlLiteConfig()
 {
     var config = new SqLiteConfig();
 }