public void ResolveIDPropertyViaForeignKey_WithFullObjectID_ResolvesToCompound() { var propertyDefinition = CreatePropertyDefinitionAndAssociateWithClass(_classDefinition, "Customer", "Customer"); var objectIDStorageProperty = ObjectIDStoragePropertyDefinitionObjectMother.Create( "CustomerID", "CustomerClassID", StorageTypeInformationObjectMother.CreateUniqueIdentifierStorageTypeInformation(), StorageTypeInformationObjectMother.CreateVarchar100StorageTypeInformation()); var foreignKeyEndPointDefinition = new RelationEndPointDefinition(propertyDefinition, false); _rdbmsPersistenceModelProviderStub .Stub(stub => stub.GetStoragePropertyDefinition(foreignKeyEndPointDefinition.PropertyDefinition)) .Return(objectIDStorageProperty); var originatingEntity = CreateEntityDefinition(typeof(Order), "o"); var result = _storageSpecificExpressionResolver.ResolveIDPropertyViaForeignKey(originatingEntity, foreignKeyEndPointDefinition); var expected = Expression.New( MemberInfoFromExpressionUtility.GetConstructor(() => new ObjectID("classID", "value")), new[] { new NamedExpression("ClassID", originatingEntity.GetColumn(typeof(string), "CustomerClassID", false)), new NamedExpression("Value", Expression.Convert(originatingEntity.GetColumn(typeof(Guid), "CustomerID", false), typeof(object))) }, new[] { typeof(ObjectID).GetProperty("ClassID"), typeof(ObjectID).GetProperty("Value") }); SqlExpressionTreeComparer.CheckAreEqualTrees(expected, result); }
public override void SetUp() { base.SetUp(); _storageTypeInformationProviderStub = MockRepository.GenerateStub <IStorageTypeInformationProvider> (); _idStorageTypeInformation = StorageTypeInformationObjectMother.CreateStorageTypeInformation(); _storageTypeInformationProviderStub .Stub(stub => stub.GetStorageTypeForID(false)) .Return(_idStorageTypeInformation); _classIDStorageTypeInformation = StorageTypeInformationObjectMother.CreateStorageTypeInformation(); _storageTypeInformationProviderStub .Stub(stub => stub.GetStorageTypeForClassID(false)) .Return(_classIDStorageTypeInformation); _timestampStorageTypeInformation = StorageTypeInformationObjectMother.CreateStorageTypeInformation(); _storageTypeInformationProviderStub .Stub(stub => stub.GetStorageTypeForTimestamp(false)) .Return(_timestampStorageTypeInformation); _storageNameProviderStub = MockRepository.GenerateStub <IStorageNameProvider>(); _storageNameProviderStub.Stub(stub => stub.GetIDColumnName()).Return("ID"); _storageNameProviderStub.Stub(stub => stub.GetClassIDColumnName()).Return("ClassID"); _storageNameProviderStub.Stub(stub => stub.GetTimestampColumnName()).Return("Timestamp"); _infrastructureStoragePropertyDefinitionProvider = new InfrastructureStoragePropertyDefinitionProvider(_storageTypeInformationProviderStub, _storageNameProviderStub); }
public void UnifyWithEquivalentProperties_ThrowsForDifferentPrimaryKeyFlag() { var storageTypeInformation = StorageTypeInformationObjectMother.CreateStorageTypeInformation(); var property1 = new SimpleStoragePropertyDefinition(typeof(int), ColumnDefinitionObjectMother.CreateColumn("Col", storageTypeInformation, true)); var property2 = new SimpleStoragePropertyDefinition(typeof(int), ColumnDefinitionObjectMother.CreateColumn("Col", storageTypeInformation, false)); Assert.That( () => property1.UnifyWithEquivalentProperties(new[] { property2 }), Throws.ArgumentException.With.Message.EqualTo( "Only equivalent properties can be combined, but this property has primary key flag 'True', and the given property has " + "primary key flag 'False'.\r\nParameter name: equivalentProperties")); }
public override void SetUp() { base.SetUp(); _storageNameProviderMock = MockRepository.GenerateStrictMock <IStorageNameProvider>(); _storageProviderDefinitionFinderStub = MockRepository.GenerateStub <IStorageProviderDefinitionFinder>(); _storageTypeInformationProviderStrictMock = MockRepository.GenerateStrictMock <IStorageTypeInformationProvider> (); _factory = new RelationStoragePropertyDefinitionFactory(TestDomainStorageProviderDefinition, false, _storageNameProviderMock, _storageTypeInformationProviderStrictMock, _storageProviderDefinitionFinderStub); _fakeStorageTypeInformation1 = StorageTypeInformationObjectMother.CreateStorageTypeInformation(); _fakeStorageTypeInformation2 = StorageTypeInformationObjectMother.CreateStorageTypeInformation(); }
public void SetUp() { _storageTypeInformationProviderMock = MockRepository.GenerateStrictMock <IStorageTypeInformationProvider> (); _storageNameProviderStub = MockRepository.GenerateStub <IStorageNameProvider>(); _factory = new ValueStoragePropertyDefinitionFactory(_storageTypeInformationProviderMock, _storageNameProviderStub); _someClassDefinition = ClassDefinitionObjectMother.CreateClassDefinition(); _someClassDefinitionWithoutBaseClass = ClassDefinitionObjectMother.CreateClassDefinition(); _someClassDefinitionWithBaseClass = ClassDefinitionObjectMother.CreateClassDefinition(id: "some", baseClass: _someClassDefinitionWithoutBaseClass); _someClassDefinitionWithBaseBaseClass = ClassDefinitionObjectMother.CreateClassDefinition(id: "some", baseClass: _someClassDefinitionWithBaseClass); _fakeStorageTypeInformation1 = StorageTypeInformationObjectMother.CreateStorageTypeInformation(); _fakeStorageTypeInformation2 = StorageTypeInformationObjectMother.CreateStorageTypeInformation(); }
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 void SetUp() { var storageTypeInformation = StorageTypeInformationObjectMother.CreateStorageTypeInformation(); _columnDefinition1 = ColumnDefinitionObjectMother.CreateColumn(storageTypeInformation: storageTypeInformation); _columnDefinition2 = ColumnDefinitionObjectMother.CreateColumn(storageTypeInformation: storageTypeInformation); _columnDefinition3 = ColumnDefinitionObjectMother.CreateColumn(storageTypeInformation: storageTypeInformation); _property1Stub = MockRepository.GenerateStub <IRdbmsStoragePropertyDefinition>(); _property2Stub = MockRepository.GenerateStub <IRdbmsStoragePropertyDefinition>(); _property3Stub = MockRepository.GenerateStub <IRdbmsStoragePropertyDefinition>(); _yearProperty = new CompoundStoragePropertyDefinition.NestedPropertyInfo(_property1Stub, o => ((DateTime)o).Year); _monthProperty = new CompoundStoragePropertyDefinition.NestedPropertyInfo(_property2Stub, o => ((DateTime)o).Month); _dayProperty = new CompoundStoragePropertyDefinition.NestedPropertyInfo(_property3Stub, o => ((DateTime)o).Day); _compoundStoragePropertyDefinition = new CompoundStoragePropertyDefinition( typeof(DateTime), new[] { _yearProperty, _monthProperty, _dayProperty }, objects => new DateTime((int)objects[0], (int)objects[1], (int)objects[2])); }
public void SetUp() { _columnDefinition = ColumnDefinitionObjectMother.CreateColumn("Column", StorageTypeInformationObjectMother.CreateVarchar100StorageTypeInformation()); _objectValue1 = "<Test1"; _objectValue2 = 689; _objectValue3 = true; _specification = new SqlXmlSetComparedColumnSpecification(_columnDefinition, new[] { _objectValue1, _objectValue2, _objectValue3 }); _statement = new StringBuilder(); _parametersCollectionMock = MockRepository.GenerateStrictMock <IDataParameterCollection> (); _commandStub = MockRepository.GenerateStub <IDbCommand> (); _commandStub.Stub(stub => stub.Parameters).Return(_parametersCollectionMock); _parameterStub = MockRepository.GenerateStub <IDbDataParameter>(); _commandStub.Stub(stub => stub.CreateParameter()).Return(_parameterStub); _sqlDialectStub = MockRepository.GenerateStub <ISqlDialect> (); _sqlDialectStub.Stub(stub => stub.StatementDelimiter).Return("delimiter"); }
private static SimpleStoragePropertyDefinition CreateStorageProperyDefinitionWithNameAndNullability(string columnName, bool isStorageTypeNullable) { return(SimpleStoragePropertyDefinitionObjectMother.CreateStorageProperty( columnName, storageTypeInformation: StorageTypeInformationObjectMother.CreateStorageTypeInformation(isStorageTypeNullable: isStorageTypeNullable))); }
public override void SetUp() { base.SetUp(); _factory = new SqlEmptyViewScriptElementFactory(); var property1 = SimpleStoragePropertyDefinitionObjectMother.CreateStorageProperty("Column1", StorageTypeInformationObjectMother.CreateVarchar100StorageTypeInformation()); var property2 = SimpleStoragePropertyDefinitionObjectMother.CreateStorageProperty("Column2", StorageTypeInformationObjectMother.CreateVarchar100StorageTypeInformation()); _emptyViewDefinitionWithCustomSchema = EmptyViewDefinitionObjectMother.Create( SchemaGenerationFirstStorageProviderDefinition, new EntityNameDefinition("SchemaName", "EmptyView1"), ObjectIDStoragePropertyDefinitionObjectMother.ObjectIDProperty, SimpleStoragePropertyDefinitionObjectMother.TimestampProperty, new[] { property1 }); _emptyViewDefinitionWithDefaultSchema = EmptyViewDefinitionObjectMother.Create( SchemaGenerationFirstStorageProviderDefinition, new EntityNameDefinition(null, "EmptyView2"), ObjectIDStoragePropertyDefinitionObjectMother.ObjectIDProperty, SimpleStoragePropertyDefinitionObjectMother.TimestampProperty, new[] { property1, property2 }); }
public void SetUp() { _storageTypeInformation = StorageTypeInformationObjectMother.CreateStorageTypeInformation(); _columnDefinition = new ColumnDefinition("Name", _storageTypeInformation, true); }
private static StorageTypeInformation CreateDefinedStorageTypeInformation(bool isStorageTypeNullable = false) { return(StorageTypeInformationObjectMother.CreateStorageTypeInformation(isStorageTypeNullable: isStorageTypeNullable)); }