internal static void CreateTables(SQLiteConnection connection) { VariablesTable.CreateTable(connection); TypeModel.CreateTable(connection); CollectionsTable.CreateTable(connection); }
public void Setup() { _connection = new SQLiteConnection("Data Source=:memory:"); _connection.Open(); TypeModel.CreateTable(_connection); }
public void TestCreateTable() { using (var connection = new SQLiteConnection("Data Source=:memory:")) { connection.Open(); TypeModel.DoesTypeTableExist(connection).Should().BeFalse(); TypeModel.CreateTable(connection); TypeModel.DoesTypeTableExist(connection).Should().BeTrue(); } }
public void TestMissingCollectionsTable() { using (var connection = new SQLiteConnection("Data Source=:memory:")) { connection.Open(); VariablesTable.CreateTable(connection); TypeModel.CreateTable(connection); new Action(() => Database.Open(connection, null, new Type[0], false)) .Should().Throw <IncompatibleDatabaseSchemaException>() .WithMessage("The database is missing the 'isabel_collections' table. The table may have been deleted or this may not even be an IsabelDb file. Are you sure the path is correct?"); } }
private static TypeModel Roundtrip(TypeModel model, IEnumerable <Type> availableTypes) { var connection = new SQLiteConnection("Data Source=:memory:"); connection.Open(); TypeModel.CreateTable(connection); model.Write(connection); var typeRegistry = new TypeResolver(availableTypes); var otherModel = TypeModel.Read(connection, typeRegistry); otherModel.Add(TypeModel.Create(availableTypes)); EnsureReferencialIntegrity(otherModel); return(otherModel); }
public void TestOldDatabaseSchema() { using (var connection = new SQLiteConnection("Data Source=:memory:")) { connection.Open(); VariablesTable.CreateTable(connection); TypeModel.CreateTable(connection); CollectionsTable.CreateTable(connection); using (var command = connection.CreateCommand()) { command.CommandText = string.Format("INSERT OR REPLACE INTO {0} (key, value) VALUES (@key, @value)", VariablesTable.TableName); command.Parameters.AddWithValue("@key", VariablesTable.IsabelSchemaVersionKey); command.Parameters.AddWithValue("@value", 0); command.ExecuteNonQuery(); } new Action(() => Database.Open(connection, null, new Type[0], false)) .Should().Throw <IncompatibleDatabaseSchemaException>() .WithMessage("The database was created with an earlier version of IsabelDb (Schema version: 0) and its schema is incompatible to this version."); } }