public void Upsert_OnSameManagerInstanceWhenClassHasOneNewMember_ColumnIsNotAddedToIndexesTable()
        {
            var hashForColumn = SisoDbEnvironment.MemberNameGenerator.Generate("IndexableMember2");
            var manager = new SqlDbSchemaManager(_sqlDb.ConnectionInfo);
            manager.UpsertStructureSet(_structureSchema);
            DbHelper.DropColumns(_indexesTableName, hashForColumn);

            manager.UpsertStructureSet(_structureSchema);

            var columnExists = DbHelper.ColumnsExist(_indexesTableName, hashForColumn);
            Assert.IsFalse(columnExists);
        }
        public void DropStructureSet_WhenTablesExists_AllTablesAreDropped()
        {
            var manager = new SqlDbSchemaManager(_sqlDb.ConnectionInfo);
            manager.UpsertStructureSet(_structureSchema);

            manager.DropStructureSet(_structureSchema);

            var structureTableExists = DbHelper.TableExists(_structureTableName);
            var indexesTableExists = DbHelper.TableExists(_indexesTableName);

            Assert.IsFalse(structureTableExists);
            Assert.IsFalse(indexesTableExists);
        }
        public void Upsert_OnNewManagerInstanceWhenDbHasOneObsoleteMember_ColumnIsDroppedFromIndexesTable()
        {
            var manager = new SqlDbSchemaManager(_sqlDb.ConnectionInfo);
            manager.UpsertStructureSet(_structureSchema);

            var hashForObsoleteColumn = SisoDbEnvironment.MemberNameGenerator.Generate("ExtraColumn");
            var obsoleteColumnDefinition = string.Format("[{0}] [int] sparse null", hashForObsoleteColumn);
            DbHelper.AddColumns(_indexesTableName, obsoleteColumnDefinition);

            var manager2 = new SqlDbSchemaManager(_sqlDb.ConnectionInfo);
            manager2.UpsertStructureSet(_structureSchema);

            var columnExists = DbHelper.ColumnsExist(_indexesTableName, hashForObsoleteColumn);
            Assert.IsFalse(columnExists);
        }
        public void Upsert_WhenNoSetExists_TablesAreCreated()
        {
            var manager = new SqlDbSchemaManager(_sqlDb.ConnectionInfo);
            manager.UpsertStructureSet(_structureSchema);

            var structureTableExists = DbHelper.TableExists(_structureTableName);
            var indexesTableExists = DbHelper.TableExists(_indexesTableName);

            Assert.IsTrue(structureTableExists);
            Assert.IsTrue(indexesTableExists);
        }
 private void CreateStructureSet()
 {
     var manager = new SqlDbSchemaManager(_sqlDb.ConnectionInfo);
     manager.UpsertStructureSet(_structureSchema);
 }