public void GetCreateElement_WithAllOptionsOn() { var entityNameDefinition = new EntityNameDefinition(null, "TableName"); var indexDefinition = new SqlSecondaryXmlIndexDefinition( "Index1", _xmlColumn, "PrimaryIndexName", SqlSecondaryXmlIndexKind.Path, true, 12, true, true, true, true, true, 2); var result = _factory.GetCreateElement(indexDefinition, entityNameDefinition); var expectedResult = "CREATE XML INDEX [Index1]\r\n" + " ON [dbo].[TableName] ([XmlColumn])\r\n" + " USING XML INDEX [PrimaryIndexName]\r\n" + " FOR Path\r\n" + " WITH (PAD_INDEX = ON, FILLFACTOR = 12, SORT_IN_TEMPDB = ON, STATISTICS_NORECOMPUTE = ON, DROP_EXISTING = ON, ALLOW_ROW_LOCKS = ON, " + "ALLOW_PAGE_LOCKS = ON, MAXDOP = 2)"; Assert.That(result, Is.TypeOf(typeof(ScriptStatement))); Assert.That(((ScriptStatement)result).Statement, Is.EqualTo(expectedResult)); }
public void Equals_True_WithNullSchema() { var one = new EntityNameDefinition(null, "entity"); var two = new EntityNameDefinition(null, "entity"); Assert.That(one, Is.EqualTo(two)); }
public void Equals_True() { var one = new EntityNameDefinition("schema", "entity"); var two = new EntityNameDefinition("schema", "entity"); Assert.That(one, Is.EqualTo(two)); }
public void GetHashCode_EqualObjects() { var one = new EntityNameDefinition("schema", "entity"); var two = new EntityNameDefinition("schema", "entity"); Assert.That(one.GetHashCode(), Is.EqualTo(two.GetHashCode())); }
public void Equals_False_DifferentEntityName() { var one = new EntityNameDefinition("schema", "entity1"); var two = new EntityNameDefinition("schema", "entity2"); Assert.That(one, Is.Not.EqualTo(two)); }
public void GetCreateElement_WithAllOptionsOff() { var entityNameDefinition = new EntityNameDefinition(null, "TableName"); var indexDefinition = new SqlIndexDefinition( "Index1", new[] { _column1, _column2 }, new[] { _includedColumn1 }, false, false, false, false, false, 0, false, false, false, false, false, 0); var result = _factory.GetCreateElement(indexDefinition, entityNameDefinition); var expectedResult = "CREATE NONCLUSTERED INDEX [Index1]\r\n" + " ON [dbo].[TableName] ([IndexColumn1] DESC, [IndexColumn2] ASC)\r\n" + " INCLUDE ([IncludedColumn1])\r\n" + " WITH (IGNORE_DUP_KEY = OFF, ONLINE = OFF, PAD_INDEX = OFF, FILLFACTOR = 0, SORT_IN_TEMPDB = OFF, STATISTICS_NORECOMPUTE = OFF, " + "DROP_EXISTING = OFF, ALLOW_ROW_LOCKS = OFF, ALLOW_PAGE_LOCKS = OFF, MAXDOP = 0)"; Assert.That(((ScriptStatement)result).Statement, Is.EqualTo(expectedResult)); }
public override void SetUp() { base.SetUp(); _factoryStub = MockRepository.GenerateStub <IForeignKeyConstraintScriptElementFactory>(); _builder = new ForeignKeyConstraintScriptBuilder(_factoryStub, new SqlCommentScriptElementFactory()); _tableName = new EntityNameDefinition(null, "Table"); _constraint1 = new ForeignKeyConstraintDefinition("FK1", _tableName, new ColumnDefinition[0], new ColumnDefinition[0]); _constraint2 = new ForeignKeyConstraintDefinition("FK2", _tableName, new ColumnDefinition[0], new ColumnDefinition[0]); _constraint3 = new ForeignKeyConstraintDefinition("FK3", _tableName, new ColumnDefinition[0], new ColumnDefinition[0]); _tableDefinition1 = TableDefinitionObjectMother.Create( SchemaGenerationFirstStorageProviderDefinition, _tableName, null, new[] { _constraint1 }); _tableDefinition2 = TableDefinitionObjectMother.Create( SchemaGenerationFirstStorageProviderDefinition, _tableName, null, new[] { _constraint2, _constraint3 }); _fakeElement1 = MockRepository.GenerateStub <IScriptElement>(); _fakeElement2 = MockRepository.GenerateStub <IScriptElement>(); _fakeElement3 = MockRepository.GenerateStub <IScriptElement>(); }
public void Initialization() { var definition = new EntityNameDefinition("schema", "entity"); Assert.That(definition.SchemaName, Is.EqualTo("schema")); Assert.That(definition.EntityName, Is.EqualTo("entity")); }
public void Initialization_NullSchemaName() { var definition = new EntityNameDefinition(null, "entity"); Assert.That(definition.SchemaName, Is.Null); Assert.That(definition.EntityName, Is.EqualTo("entity")); }
private string GetFullyQualifiedEntityName(EntityNameDefinition entityNameDefinition) { ArgumentUtility.CheckNotNull("entityNameDefinition", entityNameDefinition); return(entityNameDefinition.SchemaName != null ? entityNameDefinition.SchemaName + "." + entityNameDefinition.EntityName : entityNameDefinition.EntityName); }
private void AddIndexes(IEnumerable <IIndexDefinition> indexes, EntityNameDefinition ownerName) { foreach (var index in indexes) { _createScriptElements.AddElement(_indexScriptElementFactory.GetCreateElement(index, ownerName)); _dropScriptElements.AddElement(_indexScriptElementFactory.GetDropElement(index, ownerName)); } }
public IScriptElement GetDropElement(IIndexDefinition indexDefinition, EntityNameDefinition ownerName) { ArgumentUtility.CheckNotNull("indexDefinition", indexDefinition); var visitor = new IndexDefinitionVisitor(this, ownerName); indexDefinition.Accept(visitor); return(_dropScriptElement); }
public static TableDefinition Create( StorageProviderDefinition storageProviderDefinition, EntityNameDefinition tableName, EntityNameDefinition viewName) { return(Create( storageProviderDefinition, tableName, viewName, ObjectIDStoragePropertyDefinitionObjectMother.ObjectIDProperty, SimpleStoragePropertyDefinitionObjectMother.TimestampProperty)); }
public static FilterViewDefinition Create( StorageProviderDefinition storageProviderDefinition, EntityNameDefinition viewName, IRdbmsStorageEntityDefinition baseEntity) { return(Create( storageProviderDefinition, viewName, baseEntity, new[] { "ClassID1" }, ObjectIDStoragePropertyDefinitionObjectMother.ObjectIDProperty, SimpleStoragePropertyDefinitionObjectMother.TimestampProperty, new IRdbmsStoragePropertyDefinition[0])); }
public static UnionViewDefinition Create( StorageProviderDefinition storageProviderDefinition, EntityNameDefinition viewName, params IRdbmsStorageEntityDefinition[] unionedEntities) { ArgumentUtility.CheckNotNullOrEmpty("unionedEntities", unionedEntities); return(Create( storageProviderDefinition, viewName, unionedEntities, ObjectIDStoragePropertyDefinitionObjectMother.ObjectIDProperty, SimpleStoragePropertyDefinitionObjectMother.TimestampProperty, new IRdbmsStoragePropertyDefinition[0])); }
public virtual IScriptElement GetDropElement(T indexDefinition, EntityNameDefinition ownerName) { ArgumentUtility.CheckNotNull("indexDefinition", indexDefinition); ArgumentUtility.CheckNotNull("ownerName", ownerName); return(new ScriptStatement( string.Format( "IF EXISTS (SELECT * FROM sys.objects so JOIN sysindexes si ON so.[object_id] = si.[id] " + "WHERE so.[name] = '{0}' AND schema_name (so.schema_id)='{1}' AND si.[name] = '{2}')\r\n" + " DROP INDEX [{2}] ON [{1}].[{0}]", ownerName.EntityName, ownerName.SchemaName ?? DefaultSchema, indexDefinition.IndexName))); }
public override void SetUp() { base.SetUp(); _tableViewElementFactoryStub = MockRepository.GenerateStub <ISynonymScriptElementFactory <TableDefinition> >(); _unionViewElementFactoryStub = MockRepository.GenerateStub <ISynonymScriptElementFactory <UnionViewDefinition> >(); _filterViewElementFactoryStub = MockRepository.GenerateStub <ISynonymScriptElementFactory <FilterViewDefinition> >(); _emptyViewElementFactoryStub = MockRepository.GenerateStub <ISynonymScriptElementFactory <EmptyViewDefinition> >(); _builder = new SynonymScriptBuilder( _tableViewElementFactoryStub, _unionViewElementFactoryStub, _filterViewElementFactoryStub, _emptyViewElementFactoryStub, new SqlCommentScriptElementFactory()); _synonym1 = new EntityNameDefinition(null, "Synonym1"); _synonym2 = new EntityNameDefinition(null, "Synonym2"); _synonym3 = new EntityNameDefinition(null, "Synonym3"); _tableDefinition1 = TableDefinitionObjectMother.CreateWithSynonyms( SchemaGenerationFirstStorageProviderDefinition, new[] { _synonym1 }); _tableDefinition2 = TableDefinitionObjectMother.CreateWithSynonyms( SchemaGenerationFirstStorageProviderDefinition, new[] { _synonym2, _synonym3 }); _unionViewDefinition1 = UnionViewDefinitionObjectMother.CreateWithSynonyms( SchemaGenerationFirstStorageProviderDefinition, new[] { _synonym1 }); _unionViewDefinition2 = UnionViewDefinitionObjectMother.CreateWithSynonyms( SchemaGenerationFirstStorageProviderDefinition, new[] { _synonym2, _synonym3 }); _filterViewDefinition1 = FilterViewDefinitionObjectMother.CreateWithSynonyms( SchemaGenerationFirstStorageProviderDefinition, new[] { _synonym1 }); _filterViewDefinition2 = FilterViewDefinitionObjectMother.CreateWithSynonyms( SchemaGenerationFirstStorageProviderDefinition, new[] { _synonym2, _synonym3 }); _emptyViewDefinition1 = EmptyViewDefinitionObjectMother.CreateWithSynonyms( SchemaGenerationFirstStorageProviderDefinition, new[] { _synonym1 }); _emptyViewDefinition2 = EmptyViewDefinitionObjectMother.CreateWithSynonyms( SchemaGenerationFirstStorageProviderDefinition, new[] { _synonym2, _synonym3 }); _fakeElement1 = MockRepository.GenerateStub <IScriptElement>(); _fakeElement2 = MockRepository.GenerateStub <IScriptElement>(); _fakeElement3 = MockRepository.GenerateStub <IScriptElement>(); }
public override void SetUp() { base.SetUp(); _factory = new SqlForeignKeyConstraintScriptElementFactory(); _column1 = ColumnDefinitionObjectMother.CreateColumn("Column1"); _column2 = ColumnDefinitionObjectMother.CreateColumn("Column2"); _table1 = new EntityNameDefinition(null, "TableName1"); _table2 = new EntityNameDefinition("SchemaName", "TableName2"); _constraint1 = new ForeignKeyConstraintDefinition("FK1", _table1, new[] { _column1 }, new[] { _column2 }); _constraint2 = new ForeignKeyConstraintDefinition("FK2", _table2, new[] { _column1, _column2 }, new[] { _column2, _column1 }); }
public static EmptyViewDefinition Create( StorageProviderDefinition storageProviderDefinition, EntityNameDefinition viewName, ObjectIDStoragePropertyDefinition objectIDProperty, IRdbmsStoragePropertyDefinition timestampProperty, IEnumerable <IRdbmsStoragePropertyDefinition> dataProperties) { return(new EmptyViewDefinition( storageProviderDefinition, viewName, objectIDProperty, timestampProperty, dataProperties, new EntityNameDefinition[0])); }
public static TableDefinition Create( StorageProviderDefinition storageProviderDefinition, EntityNameDefinition tableName, EntityNameDefinition viewName, IEnumerable <ITableConstraintDefinition> constraints) { return(Create( storageProviderDefinition, tableName, viewName, ObjectIDStoragePropertyDefinitionObjectMother.ObjectIDProperty, SimpleStoragePropertyDefinitionObjectMother.TimestampProperty, new IRdbmsStoragePropertyDefinition[0], constraints)); }
public void GetCreateElement_WithIncludedColumnsAndSomeOptions() { var entityNameDefinition = new EntityNameDefinition(null, "TableName"); var indexDefinition = new SqlIndexDefinition( "Index1", new[] { _column1, _column2 }, new[] { _includedColumn1 }, false, false, true, true); var result = _factory.GetCreateElement(indexDefinition, entityNameDefinition); var expectedResult = "CREATE NONCLUSTERED INDEX [Index1]\r\n" + " ON [dbo].[TableName] ([IndexColumn1] DESC, [IndexColumn2] ASC)\r\n" + " INCLUDE ([IncludedColumn1])\r\n" + " WITH (IGNORE_DUP_KEY = ON, ONLINE = ON)"; Assert.That(((ScriptStatement)result).Statement, Is.EqualTo(expectedResult)); }
public override void SetUp() { base.SetUp(); _factory = new SqlIndexDefinitionScriptElementFactory(); _column1 = new SqlIndexedColumnDefinition(ColumnDefinitionObjectMother.CreateColumn("IndexColumn1"), IndexOrder.Desc); _column2 = new SqlIndexedColumnDefinition(ColumnDefinitionObjectMother.CreateColumn("IndexColumn2"), IndexOrder.Asc); _includedColumn1 = ColumnDefinitionObjectMother.CreateColumn("IncludedColumn1"); _includedColumn2 = ColumnDefinitionObjectMother.CreateColumn("IncludedColumn2"); _customSchemaNameDefinition = new EntityNameDefinition("SchemaName", "TableName1"); _indexDefinitionWithCustomSchema = new SqlIndexDefinition("Index1", new[] { _column1 }); _defaultSchemaNameDefinition = new EntityNameDefinition(null, "TableName2"); _indexDefinitionWithDefaultSchema = new SqlIndexDefinition("Index2", new[] { _column2 }); }
public static TableDefinition Create( StorageProviderDefinition storageProviderDefinition, EntityNameDefinition tableName, EntityNameDefinition viewName, ObjectIDStoragePropertyDefinition objectIDPropertyDefinition, SimpleStoragePropertyDefinition timestampPropertyDefinition, params IRdbmsStoragePropertyDefinition[] dataPropertyDefinitions) { return(Create( storageProviderDefinition, tableName, viewName, objectIDPropertyDefinition, timestampPropertyDefinition, dataPropertyDefinitions, new ITableConstraintDefinition[0])); }
public TestableRdbmsStorageEntityDefinitionBase( StorageProviderDefinition storageProviderDefinition, EntityNameDefinition viewName, ObjectIDStoragePropertyDefinition idProperty, IRdbmsStoragePropertyDefinition timestampProperty, IEnumerable <IRdbmsStoragePropertyDefinition> dataProperties, IEnumerable <IIndexDefinition> indexes, IEnumerable <EntityNameDefinition> synonyms) : base( storageProviderDefinition, viewName, idProperty, timestampProperty, dataProperties, indexes, synonyms) { }
public static UnionViewDefinition Create( StorageProviderDefinition storageProviderDefinition, EntityNameDefinition viewName, IEnumerable <IRdbmsStorageEntityDefinition> unionedEntities, ObjectIDStoragePropertyDefinition objectIDProperty, SimpleStoragePropertyDefinition timestampProperty, params IRdbmsStoragePropertyDefinition[] dataProperties) { return(new UnionViewDefinition( storageProviderDefinition, viewName, unionedEntities, objectIDProperty, timestampProperty, dataProperties, new IIndexDefinition[0], new EntityNameDefinition[0])); }