Esempio n. 1
0
        public void LoadExtension_works_when_closed()
        {
            using (var connection = new SqliteConnection("Data Source=:memory:"))
            {
                connection.Open();

                var loadExtensionOmitted = connection.ExecuteScalar <long>(
                    "SELECT COUNT(*) FROM pragma_compile_options WHERE compile_options = 'OMIT_LOAD_EXTENSION';");
                if (loadExtensionOmitted != 0L)
                {
                    return;
                }

                connection.Close();
                connection.EnableExtensions(false);
                connection.Open();

                var ex = Assert.Throws <SqliteException>(
                    () => connection.ExecuteNonQuery("SELECT load_extension('unknown');"));
                var extensionsDisabledError = ex.Message;

                connection.Close();

                connection.LoadExtension("unknown");

                ex = Assert.Throws <SqliteException>(() => connection.Open());

                Assert.NotEqual(extensionsDisabledError, ex.Message);
            }
        }
Esempio n. 2
0
 private SqliteConnection Open(string connectionString)
 {
     var connection = new SqliteConnection(connectionString);
     connection.Open();
     connection.EnableExtensions();
     connection.LoadExtension(_spatialiteExtensionName);
     return connection;
 }
Esempio n. 3
0
        public void LoadExtension_works()
        {
            using (var connection = new SqliteConnection("Data Source=:memory:"))
            {
                connection.EnableExtensions(false);
                connection.Open();

                var ex = Assert.Throws <SqliteException>(
                    () => connection.ExecuteNonQuery("SELECT load_extension('unknown');"));
                var extensionsDisabledError = ex.Message;

                ex = Assert.Throws <SqliteException>(() => connection.LoadExtension("unknown"));

                Assert.NotEqual(extensionsDisabledError, ex.Message);
            }
        }