示例#1
0
        internal static void CreateTables(SQLiteConnection connection)
        {
            VariablesTable.CreateTable(connection);

            TypeModel.CreateTable(connection);
            CollectionsTable.CreateTable(connection);
        }
示例#2
0
        public void Setup()
        {
            _connection = new SQLiteConnection("Data Source=:memory:");
            _connection.Open();

            TypeModel.CreateTable(_connection);
        }
示例#3
0
 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();
     }
 }
示例#4
0
        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?");
            }
        }
示例#5
0
        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);
        }
示例#6
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.");
            }
        }