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 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 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();
        }
Beispiel #4
0
        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 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));
        }