public void CreateForeignKeyConstraints() { var orderClassDefinition = Configuration.GetTypeDefinition(typeof(Order)); var customerClassDefintion = Configuration.GetTypeDefinition(typeof(Customer)); _infrastructureStoragePropertyDefintionProviderMock .Expect(mock => mock.GetObjectIDStoragePropertyDefinition()) .Return(_fakeObjectIDStoragePropertyDefinition); _infrastructureStoragePropertyDefintionProviderMock.Replay(); var customerProperty = orderClassDefinition.MyPropertyDefinitions["Remotion.Data.DomainObjects.UnitTests.TestDomain.Order.Customer"]; var expectedComparedColumns = ((IRdbmsStoragePropertyDefinition)customerProperty.StoragePropertyDefinition).GetColumnsForComparison(); _storageNameProviderMock .Expect(mock => mock.GetForeignKeyConstraintName( Arg.Is(orderClassDefinition), Arg <IEnumerable <ColumnDefinition> > .List.Equal(expectedComparedColumns))) .Return("FakeConstraintName"); _storageNameProviderMock .Expect(mock => mock.GetTableName(customerClassDefintion)) .Return(new EntityNameDefinition(null, "FakeTableName")); _storageNameProviderMock.Replay(); var foreignKeyConstraintDefinitions = _factory.CreateForeignKeyConstraints(orderClassDefinition).ToArray(); _infrastructureStoragePropertyDefintionProviderMock.VerifyAllExpectations(); _storageNameProviderMock.VerifyAllExpectations(); //OrderItem and OrderTicket endpoints are virtual and Official endpoint has different storage provider Assert.That(foreignKeyConstraintDefinitions.Length, Is.EqualTo(1)); var foreignKeyConstraint = foreignKeyConstraintDefinitions[0]; Assert.That(foreignKeyConstraint.ReferencedTableName.EntityName, Is.EqualTo("FakeTableName")); Assert.That(foreignKeyConstraint.ReferencedTableName.SchemaName, Is.Null); Assert.That(foreignKeyConstraint.ConstraintName, Is.EqualTo("FakeConstraintName")); Assert.That(foreignKeyConstraint.ReferencingColumns, Is.EqualTo(expectedComparedColumns)); Assert.That(foreignKeyConstraint.ReferencedColumns, Is.EqualTo(_fakeObjectIDStoragePropertyDefinition.GetColumnsForComparison())); }
public void CreateTableDefinition() { _storagePropertyDefinitionResolverMock .Expect(mock => mock.GetStoragePropertiesForHierarchy(_testModel.TableClassDefinition1)) .Return(new[] { _fakeStorageProperty1 }); _storagePropertyDefinitionResolverMock.Replay(); _foreignKeyConstraintDefinitionFactoryMock .Expect(mock => mock.CreateForeignKeyConstraints(_testModel.TableClassDefinition1)) .Return(new[] { _fakeForeignKeyConstraint }); _foreignKeyConstraintDefinitionFactoryMock.Replay(); _storageNameProviderMock .Expect(mock => mock.GetTableName(_testModel.TableClassDefinition1)) .Return(new EntityNameDefinition(null, "FakeTableName")); _storageNameProviderMock .Expect(mock => mock.GetViewName(_testModel.TableClassDefinition1)) .Return(new EntityNameDefinition(null, "FakeViewName")); _storageNameProviderMock .Expect(mock => mock.GetPrimaryKeyConstraintName(_testModel.TableClassDefinition1)) .Return("FakePrimaryKeyName"); _storageNameProviderMock.Replay(); MockStandardProperties(); _infrastructureStoragePropertyDefinitionProviderMock.Replay(); var result = _factory.CreateTableDefinition(_testModel.TableClassDefinition1); _storagePropertyDefinitionResolverMock.VerifyAllExpectations(); _foreignKeyConstraintDefinitionFactoryMock.VerifyAllExpectations(); _infrastructureStoragePropertyDefinitionProviderMock.VerifyAllExpectations(); _storageNameProviderMock.VerifyAllExpectations(); CheckTableDefinition( result, _storageProviderID, "FakeTableName", "FakeViewName", new IRdbmsStoragePropertyDefinition[] { _fakeObjectIDStorageProperty, _fakeTimestampStorageProperty, _fakeStorageProperty1 }, new ITableConstraintDefinition[] { new PrimaryKeyConstraintDefinition( "FakePrimaryKeyName", true, new[] { StoragePropertyDefinitionTestHelper.GetIDColumnDefinition(_fakeObjectIDStorageProperty) }), _fakeForeignKeyConstraint }, new IIndexDefinition[0], new EntityNameDefinition[0]); }