コード例 #1
0
        private void CheckIndexCreationStatement <DataType>(string columnName)
        {
            SqliteSchema actualIndex = Fixture.ReadIndexSchemaFromDatabase(TableName, columnName);

            Assert.NotNull(actualIndex);

            string statement = actualIndex.CreateStatement.ToLower();

            Assert.False(string.IsNullOrWhiteSpace(statement));

            var attribute = GetAttributeFromProperty <RdbTableIndexAttribute>(columnName, typeof(DataType));

            Assert.NotNull(attribute);
            Assert.Contains(attribute.AdditionalSqlClauses, statement);

            switch (attribute.SortingOrder)
            {
            case ValueSortingOrder.Ascending:
                Assert.Contains("asc", statement);
                break;

            case ValueSortingOrder.Descending:
                Assert.Contains("desc", statement);
                break;
            }
        }
コード例 #2
0
        private void CheckTableCreationStatement <DataType>(string[] columnDefinitions)
        {
            SqliteSchema actualTable = Fixture.ReadActualTableSchemaFromDatabase(TableName);

            Assert.NotNull(actualTable);

            string statement = actualTable.CreateStatement.ToLower();

            Assert.False(string.IsNullOrWhiteSpace(statement));

            foreach (string column in columnDefinitions)
            {
                Assert.Contains(column.ToLower(), statement);
            }
        }
コード例 #3
0
        public SqliteSchema ReadActualTableSchemaFromDatabase(string tableName)
        {
            var databaseObjects = QueryDatabaseObjects(Connection);

            Assert.NotEmpty(databaseObjects);

            SqliteSchema actualTable = (
                from x in databaseObjects
                where x.Type.ToLower() == "table" &&
                x.EntityName.ToLower() == tableName.ToLower()
                select x
                ).FirstOrDefault();

            return(actualTable);
        }
コード例 #4
0
        public SqliteSchema ReadIndexSchemaFromDatabase(string tableName, string columnName)
        {
            var databaseObjects = QueryDatabaseObjects(Connection);

            Assert.NotEmpty(databaseObjects);

            SqliteSchema actualTable = (
                from x in databaseObjects
                where x.Type.ToLower() == "index" &&
                x.TableName.ToLower() == tableName.ToLower()
                // die Reihen mit "sqlite_autoindex_*" weisen keine Anweisung auf
                && (x.CreateStatement ?? "").ToLower().Contains(columnName.ToLower())
                select x
                ).FirstOrDefault();

            return(actualTable);
        }