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));
        }
Exemplo n.º 2
0
        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));
        }
Exemplo n.º 3
0
        public void CreateRelationDefinitionCollection_OneClassDefinitionWithOneEndPoint()
        {
            var classDefinitions = new[] { _orderItemClassDefinition }.ToDictionary(cd => cd.ClassType);

            _mappingObjectFactoryMock
            .Expect(
                mock =>
                mock.CreateRelationDefinition(
                    classDefinitions,
                    _orderItemClassDefinition,
                    _orderItemClassDefinition.MyRelationEndPointDefinitions["Remotion.Data.DomainObjects.UnitTests.TestDomain.OrderItem.Order"]
                    .PropertyInfo))
            .Return(_fakeRelationDefinition1);
            _mappingObjectFactoryMock.Replay();


            var result = _factory.CreateRelationDefinitionCollection(classDefinitions);

            _mappingObjectFactoryMock.VerifyAllExpectations();
            Assert.That(result, Is.EqualTo(new[] { _fakeRelationDefinition1 }));
        }
        public void CreateClassDefinitionCollection()
        {
            _mappingObjectFactoryMock
            .Expect(mock => mock.CreateClassDefinition(typeof(Order), null))
            .Return(_fakeClassDefinition);
            _mappingObjectFactoryMock.Replay();

            var classDefinitions = _classDefinitionCollectionFactory.CreateClassDefinitionCollection(new[] { typeof(Order) });

            _mappingObjectFactoryMock.VerifyAllExpectations();

            Assert.That(classDefinitions, Is.EqualTo(new[] { _fakeClassDefinition }));
        }