public void WhenInterfaceForPoidThenShouldIncludePropertiesOfSuperInterfaces()
        {
            var memberProvider = new DefaultCandidatePersistentMembersProvider();
            var properties     = memberProvider.GetEntityMembersForPoid(typeof(IMyEntity));

            properties.Should().Have.Count.EqualTo(3);
            properties.Select(p => p.Name).Should().Have.SameValuesAs("Id", "Version", "Description");
        }
        public void WhenRootClassThenShouldIncludePropertiesOfSuperClasses()
        {
            var memberProvider = new DefaultCandidatePersistentMembersProvider();
            var properties     = memberProvider.GetRootEntityMembers(typeof(MyEntity));

            properties.Should().Have.Count.EqualTo(3);
            properties.Select(p => p.Name).Should().Have.SameValuesAs("Id", "Version", "Name");
        }
        public void WhenComponentThenShouldIncludePropertiesOfSuperClasses()
        {
            var memberProvider = new DefaultCandidatePersistentMembersProvider();
            var properties     = memberProvider.GetComponentMembers(typeof(MyComponent));

            properties.Should().Have.Count.EqualTo(2);
            properties.Select(p => p.Name).Should().Have.SameValuesAs("Something", "SomethingElse");
        }
        public void WhenSubclassThenShouldIncludePropertiesOnlyOfSubClassIfNoSkipedSuperClasses()
        {
            var memberProvider = new DefaultCandidatePersistentMembersProvider();
            var properties     = memberProvider.GetSubEntityMembers(typeof(MyInheritedEntityLevel2), typeof(MyInheritedEntityLevel1));

            properties.Should().Have.Count.EqualTo(1);
            properties.Select(p => p.Name).Should().Have.SameValuesAs("PropOfLevel2");
        }
		public void GetFirstPropertyOfTypeShouldUseSameConceptsOfCandidatePersistentMembersProvider()
		{
			var memberProvider = new DefaultCandidatePersistentMembersProvider();
			var properties = memberProvider.GetRootEntityMembers(typeof(Geo));
			if(properties.Select(p => p.Name).Contains("Parent"))
			{
				Assert.That(typeof(Geo).GetFirstPropertyOfType(typeof(Geo)), Is.Not.Null);
			}
		}
        public void WhenClassForPoidThenShouldIncludePropertiesAndFiedsOfSuperClasses()
        {
            var memberProvider = new DefaultCandidatePersistentMembersProvider();
            var properties     = memberProvider.GetEntityMembersForPoid(typeof(MyEntity)).ToArray();

            // the Intersect is to check only fields/properties I'm interested in this test
            properties.Select(p => p.Name).Intersect(new[] { "poid", "Id", "Version", "Name", "aField" })
            .Should().Have.SameValuesAs("poid", "Id", "Version", "Name", "aField");
        }
Exemplo n.º 7
0
        public void GetFirstPropertyOfTypeShouldUseSameConceptsOfCandidatePersistentMembersProvider()
        {
            var memberProvider = new DefaultCandidatePersistentMembersProvider();
            var properties     = memberProvider.GetRootEntityMembers(typeof(Geo));

            if (properties.Select(p => p.Name).Contains("Parent"))
            {
                typeof(Geo).GetFirstPropertyOfType(typeof(Geo)).Should().Not.Be.Null();
            }
        }
        protected SimpleModelMapper(IMappingAssemblies mappingAssemblies)
            : base(mappingAssemblies)
        {
            ModelMapper.BeforeMapSet   += OnBeforeMappingCollectionConvention;
            ModelMapper.BeforeMapBag   += OnBeforeMappingCollectionConvention;
            ModelMapper.BeforeMapList  += OnBeforeMappingCollectionConvention;
            ModelMapper.BeforeMapIdBag += OnBeforeMappingCollectionConvention;
            ModelMapper.BeforeMapMap   += OnBeforeMappingCollectionConvention;

            m_MembersProvider = new DefaultCandidatePersistentMembersProvider();

            ModelMapper.BeforeMapClass += NoPoidGuid;
            ModelMapper.BeforeMapClass += NoSetterPoidToField;

            ModelMapper.BeforeMapProperty += MemberToFieldAccessor;
            ModelMapper.BeforeMapProperty += MemberNoSetterToField;
            ModelMapper.BeforeMapProperty += MemberReadOnlyAccessor;

            ModelMapper.BeforeMapComponent += MemberToFieldAccessor;
            ModelMapper.BeforeMapComponent += MemberNoSetterToField;
            ModelMapper.BeforeMapComponent += MemberReadOnlyAccessor;
            ModelMapper.BeforeMapComponent += ComponentParentToFieldAccessor;
            ModelMapper.BeforeMapComponent += ComponentParentNoSetterToField;

            ModelMapper.BeforeMapBag   += MemberToFieldAccessor;
            ModelMapper.BeforeMapIdBag += MemberToFieldAccessor;
            ModelMapper.BeforeMapSet   += MemberToFieldAccessor;
            ModelMapper.BeforeMapMap   += MemberToFieldAccessor;
            ModelMapper.BeforeMapList  += MemberToFieldAccessor;

            ModelMapper.BeforeMapBag   += MemberNoSetterToField;
            ModelMapper.BeforeMapIdBag += MemberNoSetterToField;
            ModelMapper.BeforeMapSet   += MemberNoSetterToField;
            ModelMapper.BeforeMapMap   += MemberNoSetterToField;
            ModelMapper.BeforeMapList  += MemberNoSetterToField;

            ModelMapper.BeforeMapBag   += MemberReadOnlyAccessor;
            ModelMapper.BeforeMapIdBag += MemberReadOnlyAccessor;
            ModelMapper.BeforeMapSet   += MemberReadOnlyAccessor;
            ModelMapper.BeforeMapMap   += MemberReadOnlyAccessor;
            ModelMapper.BeforeMapList  += MemberReadOnlyAccessor;

            ModelMapper.BeforeMapManyToOne += MemberToFieldAccessor;
            ModelMapper.BeforeMapOneToOne  += MemberToFieldAccessor;
            ModelMapper.BeforeMapAny       += MemberToFieldAccessor;
            ModelMapper.BeforeMapManyToOne += MemberNoSetterToField;
            ModelMapper.BeforeMapOneToOne  += MemberNoSetterToField;
            ModelMapper.BeforeMapAny       += MemberNoSetterToField;
            ModelMapper.BeforeMapManyToOne += MemberReadOnlyAccessor;
            ModelMapper.BeforeMapOneToOne  += MemberReadOnlyAccessor;
            ModelMapper.BeforeMapAny       += MemberReadOnlyAccessor;
        }
        protected SimpleModelMapper(IMappingAssemblies mappingAssemblies)
            : base(mappingAssemblies)
        {
            ModelMapper.BeforeMapSet += OnBeforeMappingCollectionConvention;
            ModelMapper.BeforeMapBag += OnBeforeMappingCollectionConvention;
            ModelMapper.BeforeMapList += OnBeforeMappingCollectionConvention;
            ModelMapper.BeforeMapIdBag += OnBeforeMappingCollectionConvention;
            ModelMapper.BeforeMapMap += OnBeforeMappingCollectionConvention;

            m_MembersProvider = new DefaultCandidatePersistentMembersProvider();

            ModelMapper.BeforeMapClass += NoPoidGuid;
            ModelMapper.BeforeMapClass += NoSetterPoidToField;

            ModelMapper.BeforeMapProperty += MemberToFieldAccessor;
            ModelMapper.BeforeMapProperty += MemberNoSetterToField;
            ModelMapper.BeforeMapProperty += MemberReadOnlyAccessor;

            ModelMapper.BeforeMapComponent += MemberToFieldAccessor;
            ModelMapper.BeforeMapComponent += MemberNoSetterToField;
            ModelMapper.BeforeMapComponent += MemberReadOnlyAccessor;
            ModelMapper.BeforeMapComponent += ComponentParentToFieldAccessor;
            ModelMapper.BeforeMapComponent += ComponentParentNoSetterToField;

            ModelMapper.BeforeMapBag += MemberToFieldAccessor;
            ModelMapper.BeforeMapIdBag += MemberToFieldAccessor;
            ModelMapper.BeforeMapSet += MemberToFieldAccessor;
            ModelMapper.BeforeMapMap += MemberToFieldAccessor;
            ModelMapper.BeforeMapList += MemberToFieldAccessor;

            ModelMapper.BeforeMapBag += MemberNoSetterToField;
            ModelMapper.BeforeMapIdBag += MemberNoSetterToField;
            ModelMapper.BeforeMapSet += MemberNoSetterToField;
            ModelMapper.BeforeMapMap += MemberNoSetterToField;
            ModelMapper.BeforeMapList += MemberNoSetterToField;

            ModelMapper.BeforeMapBag += MemberReadOnlyAccessor;
            ModelMapper.BeforeMapIdBag += MemberReadOnlyAccessor;
            ModelMapper.BeforeMapSet += MemberReadOnlyAccessor;
            ModelMapper.BeforeMapMap += MemberReadOnlyAccessor;
            ModelMapper.BeforeMapList += MemberReadOnlyAccessor;

            ModelMapper.BeforeMapManyToOne += MemberToFieldAccessor;
            ModelMapper.BeforeMapOneToOne += MemberToFieldAccessor;
            ModelMapper.BeforeMapAny += MemberToFieldAccessor;
            ModelMapper.BeforeMapManyToOne += MemberNoSetterToField;
            ModelMapper.BeforeMapOneToOne += MemberNoSetterToField;
            ModelMapper.BeforeMapAny += MemberNoSetterToField;
            ModelMapper.BeforeMapManyToOne += MemberReadOnlyAccessor;
            ModelMapper.BeforeMapOneToOne += MemberReadOnlyAccessor;
            ModelMapper.BeforeMapAny += MemberReadOnlyAccessor;
        }