Example #1
0
        public void TestMissingTypeModelTable()
        {
            using (var connection = new SQLiteConnection("Data Source=:memory:"))
            {
                connection.Open();

                VariablesTable.CreateTable(connection);
                CollectionsTable.CreateTable(connection);

                new Action(() => Database.Open(connection, null, new Type[0], false))
                .Should().Throw <IncompatibleDatabaseSchemaException>()
                .WithMessage("The database is missing the 'isabel_types' table. The table may have been deleted or this may not even be an IsabelDb file. Are you sure the path is correct?");
            }
        }
Example #2
0
        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.");
            }
        }