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 override void SetUp() { base.SetUp(); _propertyDefinition = PropertyDefinitionObjectMother.CreateForFakePropertyInfo(); _collection = new PropertyDefinitionCollection(); }
public void SetStorageProperty() { PropertyDefinition propertyDefinition = PropertyDefinitionObjectMother.CreateForFakePropertyInfo(_classDefinition); var storagePropertyDefinition = SimpleStoragePropertyDefinitionObjectMother.CreateStorageProperty("Test"); propertyDefinition.SetStorageProperty(storagePropertyDefinition); Assert.That(propertyDefinition.StoragePropertyDefinition, Is.SameAs(storagePropertyDefinition)); }
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 GetAllPersistent() { var persistentProperty1 = PropertyDefinitionObjectMother.CreateForFakePropertyInfo("P1", StorageClass.Persistent); var persistentProperty2 = PropertyDefinitionObjectMother.CreateForFakePropertyInfo("P2", StorageClass.Persistent); var nonPersistentProperty1 = PropertyDefinitionObjectMother.CreateForFakePropertyInfo("P3", StorageClass.Transaction); var nonPersistentProperty2 = PropertyDefinitionObjectMother.CreateForFakePropertyInfo("P4", StorageClass.None); _collection.Add(persistentProperty1); _collection.Add(persistentProperty2); _collection.Add(nonPersistentProperty1); _collection.Add(nonPersistentProperty2); Assert.That(_collection.GetAllPersistent().ToArray(), Is.EqualTo(new[] { persistentProperty1, persistentProperty2 })); }
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)); }
private VirtualRelationEndPointDefinition CreateFullVirtualEndPointAndClassDefinition_WithProductProperty(string sortExpressionString) { var endPoint = VirtualRelationEndPointDefinitionFactory.Create( _orderClassDefinition, "OrderItems", false, CardinalityType.Many, typeof(ObjectList <OrderItem>), sortExpressionString); var orderItemClassDefinition = ClassDefinitionObjectMother.CreateClassDefinitionWithMixins(typeof(OrderItem)); var oppositeProperty = PropertyDefinitionObjectMother.CreateForFakePropertyInfo_ObjectID(orderItemClassDefinition, "Order"); var productProperty = PropertyDefinitionObjectMother.CreateForFakePropertyInfo(orderItemClassDefinition, "Product"); orderItemClassDefinition.SetPropertyDefinitions(new PropertyDefinitionCollection(new[] { oppositeProperty, productProperty }, true)); orderItemClassDefinition.SetRelationEndPointDefinitions(new RelationEndPointDefinitionCollection()); var oppositeEndPoint = new RelationEndPointDefinition(oppositeProperty, false); var relationDefinition = new RelationDefinition("test", endPoint, oppositeEndPoint); orderItemClassDefinition.SetReadOnly(); endPoint.SetRelationDefinition(relationDefinition); return(endPoint); }
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 new void ToString() { PropertyDefinition propertyDefinition = PropertyDefinitionObjectMother.CreateForFakePropertyInfo(_classDefinition, "ThePropertyName"); Assert.That(propertyDefinition.ToString(), Is.EqualTo(typeof(PropertyDefinition).FullName + ": ThePropertyName")); }