Exemplo n.º 1
0
        public void CheckDatabaseSchema_NotValidDatabases_Test(string localPathToDb, string exMessage)
        {
            var target = Path.Combine(Environment.CurrentDirectory, localPathToDb);

            var exceptionThrows = false;

            try
            {
                SQLiteHelper.CheckDatabaseSchema(target, DatabaseType.DefaulDatabase);
            }
            catch (InvalidDatabaseSchemaException ex)
            {
                exceptionThrows = true;
                Assert.IsTrue(ex.Message.Contains(exMessage));
            }
            Assert.IsTrue(exceptionThrows);
        }
Exemplo n.º 2
0
        private static bool CheckDatabaseSchema(string dataBasePath, DatabaseType databaseType)
        {
            try
            {
                SQLiteHelper.CheckDatabaseSchema(dataBasePath, databaseType);
            }
            catch (InvalidDatabaseSchemaException ex)
            {
                MessageBox.Show(
                    string.Format("The selected database ({0}) has incorrect schema:", Path.GetFileName(dataBasePath)) +
                    Environment.NewLine + Environment.NewLine +
                    ex.Message, "Incorrect schema", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(false);
            }

            return(true);
        }
Exemplo n.º 3
0
        public void CheckDatabaseSchema_ValidDatabases_Test(DatabaseType databaseType)
        {
            var target = Path.GetTempFileName();

            _tempFiles.Add(target);

            switch (databaseType)
            {
            case DatabaseType.DefaulDatabase:
                SQLiteHelper.CreateSQLiteDatabase(target);
                break;

            case DatabaseType.MetadataCacheDatabase:
                SQLiteHelper.CreateMetadataCacheDb(target);
                break;
            }

            Assert.DoesNotThrow(() => SQLiteHelper.CheckDatabaseSchema(target, databaseType));
        }