public void CreatePropertyDefinitions() { var classDefinition = ClassDefinitionObjectMother.CreateClassDefinition(classType: typeof(Order), baseClass: null); var propertyInfo1 = PropertyInfoAdapter.Create(typeof(Order).GetProperty("OrderNumber")); var propertyInfo2 = PropertyInfoAdapter.Create(typeof(Order).GetProperty("DeliveryDate")); var fakePropertyDefinition1 = PropertyDefinitionObjectMother.CreateForFakePropertyInfo(classDefinition, "P1"); var fakePropertyDefinition2 = PropertyDefinitionObjectMother.CreateForFakePropertyInfo(classDefinition, "P2"); _mappingObjectFactoryMock .Expect(mock => mock.CreatePropertyDefinition(classDefinition, propertyInfo1)) .Return(fakePropertyDefinition1); _mappingObjectFactoryMock .Expect(mock => mock.CreatePropertyDefinition(classDefinition, propertyInfo2)) .Return(fakePropertyDefinition2); _mappingObjectFactoryMock.Replay(); var result = _factory.CreatePropertyDefinitions(classDefinition, new[] { propertyInfo1, propertyInfo2 }); _mappingObjectFactoryMock.VerifyAllExpectations(); Assert.That(result.Count, Is.EqualTo(2)); Assert.That(result[0], Is.SameAs(fakePropertyDefinition1)); Assert.That(result[1], Is.SameAs(fakePropertyDefinition2)); }
public void PersistenceModelIsLoaded() { var classDefinition = ClassDefinitionObjectMother.CreateClassDefinition(classType: typeof(Order), baseClass: null); classDefinition.SetRelationEndPointDefinitions(new RelationEndPointDefinitionCollection()); classDefinition.SetPropertyDefinitions(new PropertyDefinitionCollection()); classDefinition.SetDerivedClasses(new ClassDefinition[0]); StubMockMappingLoader(new[] { classDefinition }, new RelationDefinition[0]); var persistenceModelLoaderMock = MockRepository.GenerateStrictMock <IPersistenceModelLoader>(); persistenceModelLoaderMock .Expect(mock => mock.ApplyPersistenceModelToHierarchy(classDefinition)) .WhenCalled(mi => classDefinition.SetStorageEntity(TableDefinitionObjectMother.Create(TestDomainStorageProviderDefinition))); persistenceModelLoaderMock .Expect(mock => mock.CreatePersistenceMappingValidator(classDefinition)) .Return(new PersistenceMappingValidator()); persistenceModelLoaderMock.Replay(); _mockRepository.ReplayAll(); new MappingConfiguration(_mockMappingLoader, persistenceModelLoaderMock); persistenceModelLoaderMock.VerifyAllExpectations(); }
public void GetMetadata_OppositeClassDefinition_IsDeclaringTypeOfOppositeProperty_NotReturnTypeOfThisProperty() { var originatingClass = ClassDefinitionObjectMother.CreateClassDefinitionWithMixins(typeof(Class1)); originatingClass.SetPropertyDefinitions(new PropertyDefinitionCollection()); originatingClass.SetRelationEndPointDefinitions(new RelationEndPointDefinitionCollection()); var originatingProperty = EnsurePropertyDefinitionExisitsOnClassDefinition(originatingClass, typeof(Class1), "RelationProperty"); var classDeclaringOppositeProperty = ClassDefinitionObjectMother.CreateClassDefinitionWithMixins(typeof(BaseClass2)); classDeclaringOppositeProperty.SetPropertyDefinitions(new PropertyDefinitionCollection()); classDeclaringOppositeProperty.SetRelationEndPointDefinitions(new RelationEndPointDefinitionCollection()); var oppositeProperty = EnsurePropertyDefinitionExisitsOnClassDefinition(classDeclaringOppositeProperty, typeof(BaseClass2), "RelationPropertyOnBaseClass"); var derivedOfClassDeclaringOppositeProperty = ClassDefinitionObjectMother.CreateClassDefinition(classType: typeof(DerivedClass2), baseClass: classDeclaringOppositeProperty); derivedOfClassDeclaringOppositeProperty.SetPropertyDefinitions(new PropertyDefinitionCollection()); derivedOfClassDeclaringOppositeProperty.SetRelationEndPointDefinitions(new RelationEndPointDefinitionCollection()); // This tests the scenario that the relation property's return type is a subclass of the opposite property's declaring type Assert.That(originatingProperty.PropertyType, Is.Not.SameAs(classDeclaringOppositeProperty.ClassType)); Assert.That(originatingProperty.PropertyType.BaseType, Is.SameAs(classDeclaringOppositeProperty.ClassType)); var classDefinitions = new[] { originatingClass, classDeclaringOppositeProperty, derivedOfClassDeclaringOppositeProperty } .ToDictionary(cd => cd.ClassType); var relationReflector = CreateRelationReflector(originatingClass, originatingProperty); var result = relationReflector.GetMetadata(classDefinitions); Assert.That(result.EndPointDefinitions[0].PropertyInfo, Is.SameAs(originatingProperty)); Assert.That(result.EndPointDefinitions[0].ClassDefinition, Is.SameAs(originatingClass)); Assert.That(result.EndPointDefinitions[1].PropertyInfo, Is.SameAs(oppositeProperty)); Assert.That(result.EndPointDefinitions[1].ClassDefinition, Is.SameAs(classDeclaringOppositeProperty)); }
public void CreateRelationEndPointDefinitionCollection() { var classDefinition = ClassDefinitionObjectMother.CreateClassDefinition(classType: typeof(OrderTicket)); var propertyDefinition = PropertyDefinitionObjectMother.CreateForFakePropertyInfo_ObjectID(classDefinition); classDefinition.SetPropertyDefinitions(new PropertyDefinitionCollection(new[] { propertyDefinition }, true)); var fakeRelationEndPoint = new RelationEndPointDefinition(propertyDefinition, false); var expectedPropertyInfo = PropertyInfoAdapter.Create(typeof(OrderTicket).GetProperty("Order")); _mappingObjectFactoryMock .Expect( mock => mock.CreateRelationEndPointDefinition( Arg.Is(classDefinition), Arg.Is(PropertyInfoAdapter.Create(expectedPropertyInfo.PropertyInfo)))) .Return(fakeRelationEndPoint); _mappingObjectFactoryMock.Replay(); var result = _factory.CreateRelationEndPointDefinitionCollection(classDefinition); _mappingObjectFactoryMock.VerifyAllExpectations(); _memberInformationNameResolverMock.VerifyAllExpectations(); Assert.That(result.Count, Is.EqualTo(1)); Assert.That(result[0], Is.SameAs(fakeRelationEndPoint)); }
public ClassDefinition[] GetClassDefinitions() { var classDefinition = ClassDefinitionObjectMother.CreateClassDefinition("Fake", typeof(Company)); classDefinition.SetPropertyDefinitions(new PropertyDefinitionCollection()); classDefinition.SetDerivedClasses(new ClassDefinition[0]); return(new[] { classDefinition }); }
public void CreatePropertyDefinition() { var classDefinition = ClassDefinitionObjectMother.CreateClassDefinition(classType: typeof(Order), baseClass: null); var propertyInfo = PropertyInfoAdapter.Create(typeof(Order).GetProperty("OrderItems")); var result = _factory.CreatePropertyDefinition(classDefinition, propertyInfo); Assert.That(result, Is.Not.Null); Assert.That(result.PropertyInfo, Is.SameAs(propertyInfo)); }
public override void SetUp() { base.SetUp(); _classDefinition = ClassDefinitionObjectMother.CreateClassDefinition(); _propertyInformationStub = MockRepository.GenerateStub <IPropertyInformation>(); _propertyInformationStub.Stub(stub => stub.Name).Return("Test"); _propertyInformationStub.Stub(stub => stub.DeclaringType).Return(TypeAdapter.Create(typeof(Order))); _propertyInformationStub.Stub(stub => stub.GetOriginalDeclaringType()).Return(TypeAdapter.Create(typeof(Order))); }
public void CreateRelationEndPointDefinition() { var classDefinition = ClassDefinitionObjectMother.CreateClassDefinition(classType: typeof(Order), baseClass: null); var propertyInfo = PropertyInfoAdapter.Create(typeof(Order).GetProperty("OrderItems")); var result = _factory.CreateRelationEndPointDefinition(classDefinition, propertyInfo); Assert.That(result, Is.TypeOf(typeof(VirtualRelationEndPointDefinition))); Assert.That(((VirtualRelationEndPointDefinition)result).PropertyInfo, Is.SameAs(propertyInfo)); }
public void CreatePropertyDefinitionCollection() { var classDefinition = ClassDefinitionObjectMother.CreateClassDefinition(classType: typeof(Order), baseClass: null); var propertyInfo1 = PropertyInfoAdapter.Create(typeof(Order).GetProperty("OrderNumber")); var propertyInfo2 = PropertyInfoAdapter.Create(typeof(Order).GetProperty("DeliveryDate")); var result = _factory.CreatePropertyDefinitionCollection(classDefinition, new[] { propertyInfo1, propertyInfo2 }); Assert.That(result.Count, Is.EqualTo(2)); Assert.That(result[0].PropertyInfo, Is.SameAs(propertyInfo1)); Assert.That(result[1].PropertyInfo, Is.SameAs(propertyInfo2)); }
private static ClassDefinition CreateFileSystemItemDefinition_WithEmptyMembers_AndWithDerivedClasses() { var fileSystemItemClassDefinition = ClassDefinitionObjectMother.CreateClassDefinition("FileSystemItem", typeof(FileSystemItem)); var fileClassDefinition = ClassDefinitionObjectMother.CreateClassDefinition_WithEmptyMembers_AndDerivedClasses("File", typeof(File), fileSystemItemClassDefinition); var folderClassDefinition = ClassDefinitionObjectMother.CreateClassDefinition_WithEmptyMembers_AndDerivedClasses("Folder", typeof(Folder), fileSystemItemClassDefinition); fileSystemItemClassDefinition.SetDerivedClasses(new [] { fileClassDefinition, folderClassDefinition }); fileSystemItemClassDefinition.SetPropertyDefinitions(new PropertyDefinitionCollection()); fileSystemItemClassDefinition.SetRelationEndPointDefinitions(new RelationEndPointDefinitionCollection()); return(fileSystemItemClassDefinition); }
public void Initialize() { var classDefinition = ClassDefinitionObjectMother.CreateClassDefinition(classType: typeof(Order)); var propertyDefinition = PropertyDefinitionObjectMother.CreateForFakePropertyInfo_ObjectID(classDefinition); classDefinition.SetPropertyDefinitions(new PropertyDefinitionCollection { propertyDefinition }); var endPoint = new RelationEndPointDefinition(propertyDefinition, true); Assert.That(endPoint.PropertyInfo, Is.SameAs(propertyDefinition.PropertyInfo)); }
public void CreateForAllPropertyDefinitions_ClassDefinitionWithoutBaseClassDefinition_MakeCollectionReadOnlyIsTrue() { var classDefinition = ClassDefinitionObjectMother.CreateClassDefinition(); var propertyDefinition = PropertyDefinitionObjectMother.CreateForFakePropertyInfo(classDefinition); classDefinition.SetPropertyDefinitions(new PropertyDefinitionCollection(new[] { propertyDefinition }, false)); var propertyDefinitions = PropertyDefinitionCollection.CreateForAllProperties(classDefinition, true); Assert.That(propertyDefinitions.Count, Is.EqualTo(1)); Assert.That(propertyDefinitions.IsReadOnly, Is.True); Assert.That(propertyDefinitions[0], Is.SameAs(propertyDefinition)); }
public void CreateRelationEndPointDefinitionCollection() { var classDefinition = ClassDefinitionObjectMother.CreateClassDefinition(classType: typeof(OrderTicket), baseClass: null); var propertyDefinition = PropertyDefinitionObjectMother.CreateForRealPropertyInfo(classDefinition, typeof(OrderTicket), "Order"); classDefinition.SetPropertyDefinitions(new PropertyDefinitionCollection(new[] { propertyDefinition }, true)); var result = _factory.CreateRelationEndPointDefinitionCollection(classDefinition); Assert.That(result.Count, Is.EqualTo(1)); Assert.That( ((RelationEndPointDefinition)result[0]).PropertyName, Is.EqualTo("Remotion.Data.DomainObjects.UnitTests.Mapping.TestDomain.Integration.OrderTicket.Order")); }
public void PropertyDefinitionsAreValidated() { var classDefinition = ClassDefinitionObjectMother.CreateClassDefinition(classType: typeof(DerivedValidationDomainObjectClass)); var propertyDefinition = PropertyDefinitionObjectMother.CreateForRealPropertyInfo( classDefinition, typeof(DerivedValidationDomainObjectClass), "PropertyWithStorageClassNone"); classDefinition.SetPropertyDefinitions(new PropertyDefinitionCollection(new[] { propertyDefinition }, true)); StubMockMappingLoaderWithValidation(new[] { classDefinition }, new RelationDefinition[0]); _mockRepository.ReplayAll(); new MappingConfiguration( _mockMappingLoader, new PersistenceModelLoader(new StorageGroupBasedStorageProviderDefinitionFinder(DomainObjectsConfiguration.Current.Storage))); }
public void PersistenceModelIsLoaded_NoStorageEntityIsAppliedToTheRootClass() { var classDefinition = ClassDefinitionObjectMother.CreateClassDefinition("Order", typeof(Order)); classDefinition.SetPropertyDefinitions(new PropertyDefinitionCollection()); Assert.That(classDefinition.StorageEntityDefinition, Is.Null); var persistenceModelStub = MockRepository.GenerateStub <IPersistenceModelLoader>(); StubMockMappingLoader(new[] { classDefinition }, new RelationDefinition[0]); _mockRepository.ReplayAll(); new MappingConfiguration(_mockMappingLoader, persistenceModelStub); }
public override void SetUp() { base.SetUp(); _customerClassDefinition = ClassDefinitionObjectMother.CreateClassDefinition(classType: typeof(Customer)); _customerOrdersEndPoint = VirtualRelationEndPointDefinitionFactory.Create( _customerClassDefinition, "Orders", false, CardinalityType.Many, typeof(OrderCollection), "OrderNumber desc"); _orderClassDefinition = CreateOrderDefinition_WithEmptyMembers_AndDerivedClasses(); }
public override void SetUp() { base.SetUp(); _classDefinition = ClassDefinitionObjectMother.CreateClassDefinition(); var propertyDefinition1 = PropertyDefinitionObjectMother.CreateForFakePropertyInfo_ObjectID(_classDefinition, "Property1"); var propertyDefinition2 = PropertyDefinitionObjectMother.CreateForFakePropertyInfo_ObjectID(_classDefinition, "Property2"); var propertyDefinition3 = PropertyDefinitionObjectMother.CreateForFakePropertyInfo_ObjectID(_classDefinition, "Property3"); var propertyDefinition4 = PropertyDefinitionObjectMother.CreateForFakePropertyInfo_ObjectID(_classDefinition, "Property4"); _classDefinition.SetPropertyDefinitions( new PropertyDefinitionCollection(new[] { propertyDefinition1, propertyDefinition2, propertyDefinition3, propertyDefinition4 }, true)); _endPoint1 = new RelationEndPointDefinition(propertyDefinition1, false); _endPoint2 = new RelationEndPointDefinition(propertyDefinition2, false); _collection = new RelationEndPointDefinitionCollection(); }
public void CreateForAllPropertyDefinitions_ClassDefinitionWithBaseClassDefinition() { var baseClassDefinition = ClassDefinitionObjectMother.CreateClassDefinition(classType: typeof(Company)); var classDefinition = ClassDefinitionObjectMother.CreateClassDefinition(classType: typeof(Partner), baseClass: baseClassDefinition); var propertyDefinitionInBaseClass = PropertyDefinitionObjectMother.CreateForFakePropertyInfo(baseClassDefinition, "Property1"); var propertyDefinitionInDerivedClass = PropertyDefinitionObjectMother.CreateForFakePropertyInfo(classDefinition, "Property2"); baseClassDefinition.SetPropertyDefinitions(new PropertyDefinitionCollection(new[] { propertyDefinitionInBaseClass }, true)); classDefinition.SetPropertyDefinitions(new PropertyDefinitionCollection(new[] { propertyDefinitionInDerivedClass }, true)); var propertyDefinitions = PropertyDefinitionCollection.CreateForAllProperties(classDefinition, false); Assert.That(propertyDefinitions.Count, Is.EqualTo(2)); Assert.That(propertyDefinitions[0], Is.SameAs(propertyDefinitionInDerivedClass)); Assert.That(propertyDefinitions[1], Is.SameAs(propertyDefinitionInBaseClass)); }
public void GetTypeDefinitions() { var classDefinition1 = ClassDefinitionObjectMother.CreateClassDefinition("C1", typeof(RelationEndPointPropertyClass)); classDefinition1.SetPropertyDefinitions(new PropertyDefinitionCollection()); classDefinition1.SetDerivedClasses(Enumerable.Empty <ClassDefinition>()); var classDefinition2 = ClassDefinitionObjectMother.CreateClassDefinition("C2", typeof(RelationEndPointPropertyClass1)); classDefinition2.SetPropertyDefinitions(new PropertyDefinitionCollection()); classDefinition2.SetDerivedClasses(Enumerable.Empty <ClassDefinition>()); StubMockMappingLoader(new[] { classDefinition1, classDefinition2 }, _emptyRelationDefinitions); var persistenceModelLoaderStub = CreatePersistenceModelLoaderStub(); _mockRepository.ReplayAll(); var configuration = new MappingConfiguration(_mockMappingLoader, persistenceModelLoaderStub); Assert.That(configuration.GetTypeDefinitions(), Is.EquivalentTo(new[] { classDefinition1, classDefinition2 })); }
public override void SetUp() { base.SetUp(); _mixinTargetClassDefinition = ClassDefinitionObjectMother.CreateClassDefinitionWithMixins( typeof(TargetClassForPersistentMixin), typeof(MixinAddingPersistentProperties)); _multiMixinTargetClassDefinition = ClassDefinitionObjectMother.CreateClassDefinitionWithMixins( typeof(TargetClassReceivingTwoReferencesToDerivedClass), typeof(MixinAddingTwoReferencesToDerivedClass1), typeof(MixinAddingTwoReferencesToDerivedClass2)); _multiMixinRelatedClassDefinition = ClassDefinitionObjectMother.CreateClassDefinitionWithMixins(typeof(DerivedClassWithTwoBaseReferencesViaMixins)); _relatedClassDefinition = ClassDefinitionObjectMother.CreateClassDefinitionWithMixins( typeof(RelationTargetForPersistentMixin), typeof(MixinAddingPersistentProperties)); _inheritanceRootInheritingMixinClassDefinition = ClassDefinitionObjectMother.CreateClassDefinition(classType: typeof(InheritanceRootInheritingPersistentMixin), persistentMixinFinder: new PersistentMixinFinder(typeof(InheritanceRootInheritingPersistentMixin), true)); _classDefinitions = new[] { _mixinTargetClassDefinition, _relatedClassDefinition, _multiMixinTargetClassDefinition } .ToDictionary(cd => cd.ClassType); }
public void PersistenceModelIsValidated() { var unionViewDefinition = UnionViewDefinitionObjectMother.Create(TestDomainStorageProviderDefinition); var classDefinition = ClassDefinitionObjectMother.CreateClassDefinition(classType: typeof(DerivedValidationDomainObjectClass)); classDefinition.SetStorageEntity(unionViewDefinition); classDefinition.SetPropertyDefinitions(new PropertyDefinitionCollection()); classDefinition.SetDerivedClasses(new ClassDefinition[0]); StubMockMappingLoaderWithValidation(new[] { classDefinition }, new RelationDefinition[0]); var persistenceModelLoaderStub = _mockRepository.Stub <IPersistenceModelLoader>(); persistenceModelLoaderStub .Stub(stub => stub.ApplyPersistenceModelToHierarchy(Arg <ClassDefinition> .Is.Anything)); persistenceModelLoaderStub .Stub(stub => stub.CreatePersistenceMappingValidator(Arg <ClassDefinition> .Is.Anything)) .Return(new PersistenceMappingValidator(new ClassAboveTableIsAbstractValidationRule())); _mockRepository.ReplayAll(); new MappingConfiguration(_mockMappingLoader, persistenceModelLoaderStub); }
public void CreateForAllRelationEndPoints_ClassDefinitionWithBaseClassDefinition() { var baseClassDefinition = ClassDefinitionObjectMother.CreateClassDefinition(classType: typeof(Company)); var basedPropertyDefinition = PropertyDefinitionObjectMother.CreateForFakePropertyInfo_ObjectID(baseClassDefinition, "Property1"); baseClassDefinition.SetPropertyDefinitions(new PropertyDefinitionCollection(new[] { basedPropertyDefinition }, true)); var derivedClassDefinition = ClassDefinitionObjectMother.CreateClassDefinition(classType: typeof(Partner), baseClass: baseClassDefinition); var derivedPropertyDefinition = PropertyDefinitionObjectMother.CreateForFakePropertyInfo_ObjectID(derivedClassDefinition, "Property2"); derivedClassDefinition.SetPropertyDefinitions(new PropertyDefinitionCollection(new[] { derivedPropertyDefinition }, true)); var endPoint1 = new RelationEndPointDefinition(basedPropertyDefinition, false); var endPoint2 = new RelationEndPointDefinition(derivedPropertyDefinition, false); baseClassDefinition.SetRelationEndPointDefinitions(new RelationEndPointDefinitionCollection(new[] { endPoint1 }, true)); derivedClassDefinition.SetRelationEndPointDefinitions(new RelationEndPointDefinitionCollection(new[] { endPoint2 }, true)); var endPoints = RelationEndPointDefinitionCollection.CreateForAllRelationEndPoints(derivedClassDefinition, true); Assert.That(endPoints.Count, Is.EqualTo(2)); Assert.That(endPoints[0], Is.SameAs(endPoint2)); Assert.That(endPoints[1], Is.SameAs(endPoint1)); }
public void CreateClassDefinitionCollection_DerivedClassAreSet() { var fakeClassDefinitionCompany = ClassDefinitionObjectMother.CreateClassDefinitionWithMixins(typeof(Company)); var fakeClassDefinitionPartner = ClassDefinitionObjectMother.CreateClassDefinition(classType: typeof(Partner), baseClass: fakeClassDefinitionCompany); var fakeClassDefinitionCustomer = ClassDefinitionObjectMother.CreateClassDefinition(classType: typeof(Customer), baseClass: fakeClassDefinitionCompany); _mappingObjectFactoryMock .Expect(mock => mock.CreateClassDefinition(typeof(Order), null)) .Return(_fakeClassDefinition); _mappingObjectFactoryMock .Expect(mock => mock.CreateClassDefinition(typeof(Company), null)) .Return(fakeClassDefinitionCompany); _mappingObjectFactoryMock .Expect(mock => mock.CreateClassDefinition(typeof(Partner), fakeClassDefinitionCompany)) .Return(fakeClassDefinitionPartner); _mappingObjectFactoryMock .Expect(mock => mock.CreateClassDefinition(typeof(Customer), fakeClassDefinitionCompany)) .Return(fakeClassDefinitionCustomer); _mappingObjectFactoryMock.Replay(); var classDefinitions = _classDefinitionCollectionFactory.CreateClassDefinitionCollection( new[] { typeof(Order), typeof(Company), typeof(Partner), typeof(Customer) }); _mappingObjectFactoryMock.VerifyAllExpectations(); Assert.That(classDefinitions.Length, Is.EqualTo(4)); var orderClassDefinition = classDefinitions.Single(cd => cd.ClassType == typeof(Order)); Assert.That(orderClassDefinition.DerivedClasses.Count, Is.EqualTo(0)); var companyClassDefinition = classDefinitions.Single(cd => cd.ClassType == typeof(Company)); Assert.That(companyClassDefinition.DerivedClasses, Is.EquivalentTo(new[] { fakeClassDefinitionPartner, fakeClassDefinitionCustomer })); }
public void PersistenceModelIsLoaded_NoStorageEntityIsAppliedToDerivedClass() { var fakeStorageEntityDefinition = _fakeStorageEntityDefinition; var companyClass = ClassDefinitionObjectMother.CreateClassDefinition("Company", typeof(Company)); var partnerClass = ClassDefinitionObjectMother.CreateClassDefinition("Partner", typeof(Partner), baseClass: companyClass); companyClass.SetPropertyDefinitions(new PropertyDefinitionCollection()); partnerClass.SetPropertyDefinitions(new PropertyDefinitionCollection()); companyClass.SetDerivedClasses(new[] { partnerClass }); Assert.That(companyClass.StorageEntityDefinition, Is.Null); Assert.That(partnerClass.StorageEntityDefinition, Is.Null); var persistenceModelStub = MockRepository.GenerateStub <IPersistenceModelLoader>(); StubMockMappingLoader(new[] { companyClass }, new RelationDefinition[0]); _mockRepository.ReplayAll(); persistenceModelStub.Stub(stub => stub.ApplyPersistenceModelToHierarchy(companyClass)).WhenCalled( mi => companyClass.SetStorageEntity(fakeStorageEntityDefinition)); new MappingConfiguration(_mockMappingLoader, persistenceModelStub); }
public void PersistenceModelIsLoaded_NoStoragePropertyIsAppliedToTheRootClassProperty() { var fakeStorageEntityDefinition = _fakeStorageEntityDefinition; var classDefinition = ClassDefinitionObjectMother.CreateClassDefinition("Order", typeof(Order)); var propertyDefinition = PropertyDefinitionObjectMother.CreateForFakePropertyInfo(classDefinition, "Fake"); PrivateInvoke.SetNonPublicField(propertyDefinition, "_storagePropertyDefinition", null); classDefinition.SetPropertyDefinitions(new PropertyDefinitionCollection(new[] { propertyDefinition }, true)); Assert.That(classDefinition.StorageEntityDefinition, Is.Null); Assert.That(propertyDefinition.StoragePropertyDefinition, Is.Null); var persistenceModelStub = MockRepository.GenerateStub <IPersistenceModelLoader>(); StubMockMappingLoader(new[] { classDefinition }, new RelationDefinition[0]); _mockRepository.ReplayAll(); persistenceModelStub.Stub(stub => stub.ApplyPersistenceModelToHierarchy(classDefinition)).WhenCalled( mi => classDefinition.SetStorageEntity(fakeStorageEntityDefinition)); new MappingConfiguration(_mockMappingLoader, persistenceModelStub); }
public static PropertyDefinition CreateForFakePropertyInfo_ObjectID() { return(CreateForFakePropertyInfo_ObjectID(ClassDefinitionObjectMother.CreateClassDefinition())); }
public static PropertyDefinition CreateForFakePropertyInfo(string propertyName, Type propertyType, bool isNullable) { var classDefinition = ClassDefinitionObjectMother.CreateClassDefinition(); return(CreateForFakePropertyInfo(classDefinition, propertyName, false, propertyType, isNullable, null, StorageClass.Persistent)); }
public static PropertyDefinition CreateForFakePropertyInfo(string propertyName, StorageClass storageClass) { return(CreateForFakePropertyInfo(ClassDefinitionObjectMother.CreateClassDefinition(), propertyName, storageClass)); }
public static PropertyDefinition CreateForFakePropertyInfo_MaxLength(string propertyName, Type propertyType, int maxLength) { return(CreateForFakePropertyInfo(ClassDefinitionObjectMother.CreateClassDefinition(), propertyName, false, propertyType, true, maxLength, StorageClass.Persistent)); }
public void SetUp() { _storageProviderDefinitionStub = MockRepository.GenerateStub <IStorageProviderDefinitionFinder> (); _persistenceModelLoader = new PersistenceModelLoader(_storageProviderDefinitionStub); _classDefinition = ClassDefinitionObjectMother.CreateClassDefinition(classType: typeof(Order), baseClass: null); }