Exemple #1
0
        public void Build_DatabaseExists_ConnectsOnly()
        {
            const string connection = "connection";

            A.CallTo(() => _fileExplorer.CheckFileExists(connection)).Returns(true);
            A.CallTo(() => _sqLiteDatabaseFactory.Create(connection, _connectionWrapperFactory)).Returns(_sqLiteDatabase);

            _databaseBuilder.Build(connection);

            A.CallTo(() => _sqLiteDatabaseFactory.Create(connection, _connectionWrapperFactory)).MustHaveHappened();
            A.CallTo(() => _fileExplorer.CreateNewDatabase(connection)).MustNotHaveHappened();
        }
Exemple #2
0
        public ISqLiteDatabase Build(string connection)
        {
            ISqLiteDatabase sqliteDatabase;

            if (!_fileExplorer.CheckFileExists(connection))
            {
                _fileExplorer.CreateNewDatabase(connection);
                sqliteDatabase = _sqLiteDatabaseFactory.Create(connection, _sqLiteConnectionWrapperFactory);
                sqliteDatabase.ExecuteNonQuery(_databaseTableCreationQueries.CreateEntitiesTable);
                sqliteDatabase.ExecuteNonQuery(_databaseTableCreationQueries.CreatePredicatesTable);
                sqliteDatabase.ExecuteNonQuery(_databaseTableCreationQueries.CreatePredicatesTrigger);
                sqliteDatabase.ExecuteNonQuery(_databaseTableCreationQueries.PopulateDefaultEntities);
                sqliteDatabase.ExecuteNonQuery(_databaseTableCreationQueries.PopulateDefaultPredicates);
            }
            else
            {
                sqliteDatabase = _sqLiteDatabaseFactory.Create(connection, _sqLiteConnectionWrapperFactory);
            }
            return(sqliteDatabase);
        }