public void SetUp() { _storageProviderDefinition = new UnitTestStorageProviderStubDefinition("SPID"); _objectIDProperty = ObjectIDStoragePropertyDefinitionObjectMother.ObjectIDProperty; _timestampProperty = SimpleStoragePropertyDefinitionObjectMother.TimestampProperty; _property1 = SimpleStoragePropertyDefinitionObjectMother.CreateStorageProperty("Column1"); _property2 = SimpleStoragePropertyDefinitionObjectMother.CreateStorageProperty("Column2"); _property3 = SimpleStoragePropertyDefinitionObjectMother.CreateStorageProperty("Column3"); _constraints = new[] { new PrimaryKeyConstraintDefinition("PK_Table", true, new[] { ColumnDefinitionObjectMother.IDColumn }) }; _indexes = new[] { MockRepository.GenerateStub <IIndexDefinition>() }; _synonyms = new[] { new EntityNameDefinition(null, "Test") }; _tableDefinition = new TableDefinition( _storageProviderDefinition, new EntityNameDefinition("TableSchema", "TableTest"), new EntityNameDefinition("Schema", "Test"), _objectIDProperty, _timestampProperty, new[] { _property1, _property2, _property3 }, _constraints, _indexes, _synonyms); }
public void SetUp() { _storageProviderID = "DefaultStorageProvider"; _storageProviderDefinition = new UnitTestStorageProviderStubDefinition(_storageProviderID); _infrastructureStoragePropertyDefinitionProviderMock = MockRepository.GenerateStrictMock <IInfrastructureStoragePropertyDefinitionProvider>(); _storagePropertyDefinitionResolverMock = MockRepository.GenerateStrictMock <IStoragePropertyDefinitionResolver>(); _storageNameProviderMock = MockRepository.GenerateStrictMock <IStorageNameProvider>(); _foreignKeyConstraintDefinitionFactoryMock = MockRepository.GenerateStrictMock <IForeignKeyConstraintDefinitionFactory>(); _factory = new RdbmsStorageEntityDefinitionFactory( _infrastructureStoragePropertyDefinitionProviderMock, _foreignKeyConstraintDefinitionFactoryMock, _storagePropertyDefinitionResolverMock, _storageNameProviderMock, _storageProviderDefinition); _testModel = new RdbmsPersistenceModelLoaderTestHelper(); _fakeObjectIDStorageProperty = ObjectIDStoragePropertyDefinitionObjectMother.ObjectIDProperty; _fakeStorageProperty1 = SimpleStoragePropertyDefinitionObjectMother.CreateStorageProperty("Test1"); _fakeTimestampStorageProperty = SimpleStoragePropertyDefinitionObjectMother.TimestampProperty; _fakeForeignKeyConstraint = new ForeignKeyConstraintDefinition( "FakeForeignKeyConstraint", new EntityNameDefinition(null, "Test"), new[] { StoragePropertyDefinitionTestHelper.GetIDColumnDefinition(_fakeObjectIDStorageProperty) }, new[] { _fakeStorageProperty1.ColumnDefinition }); }
public void SetUp() { _storageProviderDefinition = new UnitTestStorageProviderStubDefinition("SPID"); _timestampProperty = SimpleStoragePropertyDefinitionObjectMother.TimestampProperty; _objectIDProperty = ObjectIDStoragePropertyDefinitionObjectMother.ObjectIDProperty; _property1 = SimpleStoragePropertyDefinitionObjectMother.CreateStorageProperty("Column1"); _property2 = SimpleStoragePropertyDefinitionObjectMother.CreateStorageProperty("Column2"); _property3 = SimpleStoragePropertyDefinitionObjectMother.CreateStorageProperty("Column3"); _synonyms = new[] { new EntityNameDefinition(null, "Test") }; _baseEntityDefinition = TableDefinitionObjectMother.Create(_storageProviderDefinition); _indexes = new[] { MockRepository.GenerateStub <IIndexDefinition>() }; _filterViewDefinition = new FilterViewDefinition( _storageProviderDefinition, new EntityNameDefinition("Schema", "Test"), _baseEntityDefinition, new[] { "ClassId1", "ClassId2" }, _objectIDProperty, _timestampProperty, new[] { _property1, _property2, _property3 }, _indexes, _synonyms); }
public override void SetUp() { base.SetUp(); _dbCommandBuilderFactoryStrictMock = MockRepository.GenerateStrictMock <IDbCommandBuilderFactory>(); _objectReaderFactoryStrictMock = MockRepository.GenerateStrictMock <IObjectReaderFactory>(); _dataStoragePropertyDefinitionFactoryStrictMock = MockRepository.GenerateStrictMock <IDataStoragePropertyDefinitionFactory> (); _factory = new QueryCommandFactory( _objectReaderFactoryStrictMock, _dbCommandBuilderFactoryStrictMock, _dataStoragePropertyDefinitionFactoryStrictMock); _dataContainerReader1Stub = MockRepository.GenerateStub <IObjectReader <DataContainer> >(); _resultRowReaderStub = MockRepository.GenerateStub <IObjectReader <IQueryResultRow> >(); _queryParameter1 = new QueryParameter("first", DomainObjectIDs.Order1); _queryParameter2 = new QueryParameter("second", DomainObjectIDs.Order3.Value); _queryParameter3 = new QueryParameter("third", DomainObjectIDs.Official1); var collection = new QueryParameterCollection { _queryParameter1, _queryParameter2, _queryParameter3 }; _queryStub = MockRepository.GenerateStub <IQuery>(); _queryStub.Stub(stub => stub.Statement).Return("statement"); _queryStub.Stub(stub => stub.Parameters).Return(new QueryParameterCollection(collection, true)); _property1 = ObjectIDStoragePropertyDefinitionObjectMother.Create("Test"); _property2 = SimpleStoragePropertyDefinitionObjectMother.CreateStorageProperty(); _property3 = SerializedObjectIDStoragePropertyDefinitionObjectMother.Create("Test"); }
public void CreateForeignKeyConstraint() { var referencedColumnDefinition = ColumnDefinitionObjectMother.CreateColumn("c2"); var referencedValuePropertyStub = MockRepository.GenerateStub <IRdbmsStoragePropertyDefinition> (); referencedValuePropertyStub.Stub(stub => stub.GetColumnsForComparison()).Return(new[] { referencedColumnDefinition }); var referencedObjectIDProperty = new ObjectIDStoragePropertyDefinition( referencedValuePropertyStub, SimpleStoragePropertyDefinitionObjectMother.ClassIDProperty); _valuePropertyStub.Stub(stub => stub.GetColumnsForComparison()).Return(new[] { _valueColumnDefinition }); var result = _objectIDStoragePropertyDefinition.CreateForeignKeyConstraint( cols => { Assert.That(cols, Is.EqualTo(new[] { _valueColumnDefinition })); return("fkname"); }, new EntityNameDefinition("entityschema", "entityname"), referencedObjectIDProperty); Assert.That(result.ConstraintName, Is.EqualTo("fkname")); Assert.That(result.ReferencedTableName, Is.EqualTo(new EntityNameDefinition("entityschema", "entityname"))); Assert.That(result.ReferencingColumns, Is.EqualTo(new[] { _valueColumnDefinition })); Assert.That(result.ReferencedColumns, Is.EqualTo(new[] { referencedColumnDefinition })); }
public InfrastructureStoragePropertyDefinitionProvider( IStorageTypeInformationProvider storageTypeInformationProvider, IStorageNameProvider storageNameProvider) { ArgumentUtility.CheckNotNull("storageTypeInformationProvider", storageTypeInformationProvider); ArgumentUtility.CheckNotNull("storageNameProvider", storageNameProvider); _idColumnDefinition = new ColumnDefinition( storageNameProvider.GetIDColumnName(), storageTypeInformationProvider.GetStorageTypeForID(false), true); _classIDColumnDefinition = new ColumnDefinition( storageNameProvider.GetClassIDColumnName(), storageTypeInformationProvider.GetStorageTypeForClassID(false), false); _timestampColumnDefinition = new ColumnDefinition( storageNameProvider.GetTimestampColumnName(), storageTypeInformationProvider.GetStorageTypeForTimestamp(false), false); _objectIDStoragePropertyDefinition = new ObjectIDStoragePropertyDefinition( new SimpleStoragePropertyDefinition(typeof(object), _idColumnDefinition), new SimpleStoragePropertyDefinition(typeof(string), _classIDColumnDefinition)); _timestampStoragePropertyDefinition = new SimpleStoragePropertyDefinition(typeof(object), _timestampColumnDefinition); }
public override void SetUp() { base.SetUp(); _fakeObjectIDStoragePropertyDefinition = ObjectIDStoragePropertyDefinitionObjectMother.ObjectIDProperty; _storageNameProviderMock = MockRepository.GenerateStrictMock <IStorageNameProvider>(); _persistenceModelProvider = new RdbmsPersistenceModelProvider(); _infrastructureStoragePropertyDefintionProviderMock = MockRepository.GenerateStrictMock <IInfrastructureStoragePropertyDefinitionProvider>(); _factory = new ForeignKeyConstraintDefinitionFactory( _storageNameProviderMock, _persistenceModelProvider, _infrastructureStoragePropertyDefintionProviderMock); }
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, ObjectIDStoragePropertyDefinition objectIDPropertyDefinition, SimpleStoragePropertyDefinition timestampPropertyDefinition, params IRdbmsStoragePropertyDefinition[] dataPropertyDefinitions) { return(Create( storageProviderDefinition, tableName, viewName, objectIDPropertyDefinition, timestampPropertyDefinition, dataPropertyDefinitions, new ITableConstraintDefinition[0])); }
public override void SetUp() { base.SetUp(); _factory = new SqlTableScriptElementFactory(); var column1 = new ColumnDefinition("Column1", StorageTypeInformationObjectMother.CreateVarchar100StorageTypeInformation(false), false); var column2 = new ColumnDefinition("Column2", StorageTypeInformationObjectMother.CreateBitStorageTypeInformation(true), false); var property1 = new SimpleStoragePropertyDefinition(typeof(string), column1); var property2 = new SimpleStoragePropertyDefinition(typeof(bool), column2); var idColumn = new ColumnDefinition("ID", StorageTypeInformationObjectMother.CreateUniqueIdentifierStorageTypeInformation(false), true); var classIDColumn = new ColumnDefinition("ClassID", StorageTypeInformationObjectMother.CreateVarchar100StorageTypeInformation(true), false); var objectIDProperty = new ObjectIDStoragePropertyDefinition( new SimpleStoragePropertyDefinition(typeof(object), idColumn), new SimpleStoragePropertyDefinition(typeof(string), classIDColumn)); var timestampColumn = new ColumnDefinition("Timestamp", StorageTypeInformationObjectMother.CreateDateTimeStorageTypeInformation(true), false); var timestampProperty = new SimpleStoragePropertyDefinition(typeof(object), timestampColumn); _tableDefinitionWithoutPrimaryKeyConstraint = TableDefinitionObjectMother.Create( SchemaGenerationFirstStorageProviderDefinition, new EntityNameDefinition("SchemaName", "EntityName"), null, objectIDProperty, timestampProperty, property1); _tableDefinitionWithClusteredPrimaryKeyConstraint = TableDefinitionObjectMother.Create( SchemaGenerationFirstStorageProviderDefinition, new EntityNameDefinition("SchemaName", "EntityName"), null, objectIDProperty, timestampProperty, new[] { property1, property2 }, new ITableConstraintDefinition[] { new PrimaryKeyConstraintDefinition("PKName", true, new[] { column1 }) }); _tableDefinitionWithNonClusteredPrimaryKeyConstraint = TableDefinitionObjectMother.Create( SchemaGenerationFirstStorageProviderDefinition, new EntityNameDefinition(null, "EntityName"), null, objectIDProperty, timestampProperty, new[] { property1, property2 }, new ITableConstraintDefinition[] { new PrimaryKeyConstraintDefinition("PKName", false, new[] { column1, column2 }) }); }
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 override void SetUp() { base.SetUp(); _valueColumnDefinition = ColumnDefinitionObjectMother.CreateColumn("Column1"); _classIDColumnDefinition = ColumnDefinitionObjectMother.CreateColumn("Column2"); _valuePropertyStub = MockRepository.GenerateStub <IRdbmsStoragePropertyDefinition>(); _classIDPropertyStub = MockRepository.GenerateStub <IRdbmsStoragePropertyDefinition>(); _objectIDStoragePropertyDefinition = new ObjectIDStoragePropertyDefinition(_valuePropertyStub, _classIDPropertyStub); _columnValueProviderStub = MockRepository.GenerateStub <IColumnValueProvider> (); _dbCommandStub = MockRepository.GenerateStub <IDbCommand>(); _dbDataParameter1Stub = MockRepository.GenerateStub <IDbDataParameter>(); _dbDataParameter2Stub = MockRepository.GenerateStub <IDbDataParameter> (); _dbCommandStub.Stub(stub => stub.CreateParameter()).Return(_dbDataParameter1Stub).Repeat.Once(); _dbCommandStub.Stub(stub => stub.CreateParameter()).Return(_dbDataParameter2Stub).Repeat.Once(); }
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])); }
public void SetUp() { _storageProviderDefinition = new UnitTestStorageProviderStubDefinition("SPID"); _timestampProperty = SimpleStoragePropertyDefinitionObjectMother.TimestampProperty; _objectIDProperty = ObjectIDStoragePropertyDefinitionObjectMother.ObjectIDProperty; _property1 = SimpleStoragePropertyDefinitionObjectMother.CreateStorageProperty("Column1"); _property2 = SimpleStoragePropertyDefinitionObjectMother.CreateStorageProperty("Column2"); _property3 = SimpleStoragePropertyDefinitionObjectMother.CreateStorageProperty("Column3"); _synonyms = new[] { new EntityNameDefinition("Schema", "Test") }; _emptyViewDefinition = new EmptyViewDefinition( _storageProviderDefinition, new EntityNameDefinition("Schema", "Test"), _objectIDProperty, _timestampProperty, new[] { _property1, _property2, _property3 }, _synonyms); }
public static FilterViewDefinition Create( StorageProviderDefinition storageProviderDefinition, EntityNameDefinition viewName, IRdbmsStorageEntityDefinition baseEntity, IEnumerable <string> classIDs, ObjectIDStoragePropertyDefinition objectIDProperty, SimpleStoragePropertyDefinition timestampProperty, IEnumerable <IRdbmsStoragePropertyDefinition> dataProperties) { return(new FilterViewDefinition( storageProviderDefinition, viewName, baseEntity, classIDs, objectIDProperty, timestampProperty, dataProperties, new IIndexDefinition[0], new EntityNameDefinition[0])); }
public static TableDefinition Create( StorageProviderDefinition storageProviderDefinition, EntityNameDefinition tableName, EntityNameDefinition viewName, ObjectIDStoragePropertyDefinition objectIDPropertyDefinition, SimpleStoragePropertyDefinition timestampPropertyDefinition, IEnumerable <IRdbmsStoragePropertyDefinition> dataPropertyDefinitions, IEnumerable <ITableConstraintDefinition> tableConstraintDefinitions) { return(new TableDefinition( storageProviderDefinition, tableName, viewName, objectIDPropertyDefinition, timestampPropertyDefinition, dataPropertyDefinitions, tableConstraintDefinitions, new IIndexDefinition[0], new EntityNameDefinition[0])); }
public override void SetUp() { base.SetUp(); _storageProviderDefinitionFinder = new StorageGroupBasedStorageProviderDefinitionFinder(DomainObjectsConfiguration.Current.Storage); _storageProviderDefinition = (RdbmsProviderDefinition)_storageProviderDefinitionFinder.GetStorageProviderDefinition( storageGroupTypeOrNull: null, errorMessageContext: "SetUp"); var factory = _storageProviderDefinition.Factory; _rdbmsPersistenceModelLoader = (RdbmsPersistenceModelLoader)factory.CreatePersistenceModelLoader(_storageProviderDefinition, _storageProviderDefinitionFinder); _testModel = new RdbmsPersistenceModelLoaderTestHelper(); var infrastructureStoragePropertyDefinitionProvider = ((RdbmsStorageEntityDefinitionFactory)_rdbmsPersistenceModelLoader.EntityDefinitionFactory).InfrastructureStoragePropertyDefinitionProvider; _infrastructureObjectIDStoragePropertyDefinition = infrastructureStoragePropertyDefinitionProvider.GetObjectIDStoragePropertyDefinition(); _infrastructureIDStoragePropertyDefinition = (SimpleStoragePropertyDefinition)_infrastructureObjectIDStoragePropertyDefinition.ValueProperty; _infrastructureClassIDStoragePropertyDefinition = (SimpleStoragePropertyDefinition)_infrastructureObjectIDStoragePropertyDefinition.ClassIDProperty; _infrastructureTimestampStoragePropertyDefinition = (SimpleStoragePropertyDefinition)infrastructureStoragePropertyDefinitionProvider.GetTimestampStoragePropertyDefinition(); _fakeBaseBaseStoragePropertyDefinition = SimpleStoragePropertyDefinitionObjectMother.CreateStorageProperty("BaseBaseProperty"); _fakeBaseStoragePropertyDefinition = SimpleStoragePropertyDefinitionObjectMother.CreateStorageProperty("BaseProperty"); _fakeTableStoragePropertyDefinition1 = SimpleStoragePropertyDefinitionObjectMother.CreateStorageProperty("TableProperty1"); _fakeTableStoragePropertyDefinition2 = SimpleStoragePropertyDefinitionObjectMother.CreateStorageProperty("TableProperty2"); _fakeDerivedStoragePropertyDefinition1 = SimpleStoragePropertyDefinitionObjectMother.CreateStorageProperty("DerivedProperty1"); _fakeDerivedStoragePropertyDefinition2 = SimpleStoragePropertyDefinitionObjectMother.CreateStorageProperty("DerivedProperty2"); _fakeDerivedDerivedStoragePropertyDefinition = SimpleStoragePropertyDefinitionObjectMother.CreateStorageProperty("DerivedDerivedProperty"); _testModel.BaseBasePropertyDefinition.SetStorageProperty(_fakeBaseBaseStoragePropertyDefinition); _testModel.BasePropertyDefinition.SetStorageProperty(_fakeBaseStoragePropertyDefinition); _testModel.TablePropertyDefinition1.SetStorageProperty(_fakeTableStoragePropertyDefinition1); _testModel.TablePropertyDefinition2.SetStorageProperty(_fakeTableStoragePropertyDefinition2); _testModel.DerivedPropertyDefinition1.SetStorageProperty(_fakeDerivedStoragePropertyDefinition1); _testModel.DerivedPropertyDefinition2.SetStorageProperty(_fakeDerivedStoragePropertyDefinition2); _testModel.DerivedDerivedPropertyDefinition.SetStorageProperty(_fakeDerivedDerivedStoragePropertyDefinition); }
public void UnifyWithEquivalentProperties_CombinesProperties() { var valueProperty1Mock = MockRepository.GenerateStrictMock <IRdbmsStoragePropertyDefinition>(); var classIDProperty1Mock = MockRepository.GenerateStrictMock <IRdbmsStoragePropertyDefinition> (); var property1 = new ObjectIDStoragePropertyDefinition(valueProperty1Mock, classIDProperty1Mock); var valueProperty2Stub = MockRepository.GenerateStub <IRdbmsStoragePropertyDefinition> (); var classIDProperty2Stub = MockRepository.GenerateStub <IRdbmsStoragePropertyDefinition> (); var property2 = new ObjectIDStoragePropertyDefinition(valueProperty2Stub, classIDProperty2Stub); var valueProperty3Stub = MockRepository.GenerateStub <IRdbmsStoragePropertyDefinition> (); var classIDProperty3Stub = MockRepository.GenerateStub <IRdbmsStoragePropertyDefinition> (); var property3 = new ObjectIDStoragePropertyDefinition(valueProperty3Stub, classIDProperty3Stub); var fakeUnifiedValueProperty = MockRepository.GenerateStub <IRdbmsStoragePropertyDefinition>(); valueProperty1Mock .Expect( mock => mock.UnifyWithEquivalentProperties( Arg <IEnumerable <IRdbmsStoragePropertyDefinition> > .List.Equal(new[] { valueProperty2Stub, valueProperty3Stub }))) .Return(fakeUnifiedValueProperty); var fakeUnifiedClassIDProperty = MockRepository.GenerateStub <IRdbmsStoragePropertyDefinition> (); classIDProperty1Mock .Expect( mock => mock.UnifyWithEquivalentProperties( Arg <IEnumerable <IRdbmsStoragePropertyDefinition> > .List.Equal(new[] { classIDProperty2Stub, classIDProperty3Stub }))) .Return(fakeUnifiedClassIDProperty); var result = property1.UnifyWithEquivalentProperties(new[] { property2, property3 }); fakeUnifiedValueProperty.VerifyAllExpectations(); fakeUnifiedClassIDProperty.VerifyAllExpectations(); Assert.That(result, Is.TypeOf <ObjectIDStoragePropertyDefinition>()); Assert.That(((ObjectIDStoragePropertyDefinition)result).ValueProperty, Is.SameAs(fakeUnifiedValueProperty)); Assert.That(((ObjectIDStoragePropertyDefinition)result).ClassIDProperty, Is.SameAs(fakeUnifiedClassIDProperty)); }
public override void SetUp() { base.SetUp(); _rdbmsPersistenceModelProviderStub = MockRepository.GenerateStub <IRdbmsPersistenceModelProvider>(); _entityDefinitionStub = MockRepository.GenerateStub <IRdbmsStorageEntityDefinition>(); _storageTypeInformationProviderStub = MockRepository.GenerateStub <IStorageTypeInformationProvider>(); _dataContainerValidatorStub = MockRepository.GenerateStub <IDataContainerValidator>(); _objectIDProperty = ObjectIDStoragePropertyDefinitionObjectMother.ObjectIDProperty; _timestampProperty = SimpleStoragePropertyDefinitionObjectMother.TimestampProperty; _entityDefinitionStub.Stub(stub => stub.ObjectIDProperty).Return(_objectIDProperty); _entityDefinitionStub.Stub(stub => stub.TimestampProperty).Return(_timestampProperty); _column1 = ColumnDefinitionObjectMother.CreateColumn("Column1"); _column2 = ColumnDefinitionObjectMother.CreateColumn("Column2"); _infrastructureStoragePropertyDefinitionProviderStub = MockRepository.GenerateStrictMock <IInfrastructureStoragePropertyDefinitionProvider> (); _factory = new ObjectReaderFactory( _rdbmsPersistenceModelProviderStub, _infrastructureStoragePropertyDefinitionProviderStub, _storageTypeInformationProviderStub, _dataContainerValidatorStub); }
public static ColumnDefinition GetClassIDColumnDefinition(ObjectIDStoragePropertyDefinition objectIDStoragePropertyDefinition) { return(((SimpleStoragePropertyDefinition)objectIDStoragePropertyDefinition.ClassIDProperty).ColumnDefinition); }