public void IsInParentContext_WithEmptyParentContext()
        {
            var finder = new PersistentMixinFinder(typeof(TargetClassBase), false);

            Assert.That(finder.ParentClassContext.IsEmpty(), Is.True);
            Assert.That(finder.IsInParentContext(typeof(MixinBase)), Is.False);
        }
        public void IsInParentContext_WithParentContext()
        {
            var finder = new PersistentMixinFinder(typeof(TargetClassA), false);

            Assert.That(finder.ParentClassContext, Is.Not.Null);
            Assert.That(finder.IsInParentContext(typeof(MixinBase)), Is.True);
            Assert.That(finder.IsInParentContext(typeof(MixinA)), Is.False);
        }
 public void FindOriginalMixinTarget_NoMixinConfiguration_InheritedTrue()
 {
     using (MixinConfiguration.BuildNew().EnterScope())
     {
         Type originalTarget = new PersistentMixinFinder(typeof(TargetClassA), true).FindOriginalMixinTarget(typeof(MixinB));
         Assert.That(originalTarget, Is.Null);
     }
 }
 public void PersistenceIrrelevant_OpenGenericMixin()
 {
     using (MixinConfiguration.BuildFromActive().ForClass(typeof(Order)).Clear().AddMixins(typeof(NonPersistedGenericMixin <>)).EnterScope())
     {
         Type[] persistentMixins = new PersistentMixinFinder(typeof(Order), false).GetPersistentMixins();
         Assert.That(persistentMixins, Is.Empty);
     }
 }
 public void Initialization_NullBaseType()
 {
     using (MixinConfiguration.BuildNew().ForClass <object> ().AddMixin <int> ().EnterScope())
     {
         var finder = new PersistentMixinFinder(typeof(object), false);
         Assert.That(finder.MixinConfiguration, Is.Not.Null);
         Assert.That(finder.ParentClassContext, Is.Null);
     }
 }
 public void FindOriginalMixinTarget_MixinOnBaseBaseBase()
 {
     using (MixinConfiguration.BuildNew()
            .ForClass(typeof(object))
            .AddMixin(typeof(MixinA))
            .EnterScope())
     {
         Type originalTarget = new PersistentMixinFinder(typeof(TargetClassB), true).FindOriginalMixinTarget(typeof(MixinA));
         Assert.That(originalTarget, Is.SameAs(typeof(object)));
     }
 }
 public void FindOriginalMixinTarget_MixinOnClass_InheritedFalse()
 {
     using (MixinConfiguration.BuildNew()
            .ForClass(typeof(TargetClassA))
            .AddMixin(typeof(MixinA))
            .EnterScope())
     {
         Type originalTarget = new PersistentMixinFinder(typeof(TargetClassA), false).FindOriginalMixinTarget(typeof(MixinA));
         Assert.That(originalTarget, Is.SameAs(typeof(TargetClassA)));
     }
 }
 public void FindOriginalMixinTarget_MixinNotDefined()
 {
     using (MixinConfiguration.BuildNew()
            .ForClass(typeof(TargetClassA))
            .AddMixin(typeof(MixinA))
            .EnterScope())
     {
         Type originalTarget = new PersistentMixinFinder(typeof(TargetClassA), false).FindOriginalMixinTarget(typeof(MixinB));
         Assert.That(originalTarget, Is.Null);
     }
 }
 public void PersistenceIrrelevant_MixinSuppressingInherited()
 {
     using (MixinConfiguration.BuildNew()
            .ForClass(typeof(TargetClassBase))
            .AddMixins(typeof(NonDomainObjectMixin))
            .ForClass(typeof(TargetClassA))
            .AddMixin(typeof(NonPersistedGenericMixin <>)).SuppressMixin(typeof(NonDomainObjectMixin))
            .EnterScope())
     {
         Type[] persistentMixins = new PersistentMixinFinder(typeof(TargetClassA), false).GetPersistentMixins();
         Assert.That(persistentMixins, Is.Empty);
     }
 }
        private MixinPropertyFinder CreatePropertyFinder(Type type, bool includeBaseProperties)
        {
            var persistentMixinFinder = new PersistentMixinFinder(type, includeBaseProperties);

            Func <Type, bool, bool, PropertyFinderBase> propertyFinderFactory = (typeArg, includeBasePropertiesArg, includeMixinPropertiesArg) =>
                                                                                (PropertyFinderBase) new StubPropertyFinderBase(
                typeArg,
                includeBasePropertiesArg,
                includeMixinPropertiesArg,
                new ReflectionBasedMemberInformationNameResolver(),
                persistentMixinFinder,
                new PropertyMetadataReflector());

            return(new MixinPropertyFinder(propertyFinderFactory, persistentMixinFinder, includeBaseProperties));
        }
Пример #11
0
        public ClassDefinition GetMetadata(ClassDefinition baseClassDefinition)
        {
            var persistentMixinFinder = new PersistentMixinFinder(Type, baseClassDefinition == null);
            var classDefinition       = new ClassDefinition(
                _classIDProvider.GetClassID(Type), Type, IsAbstract(), baseClassDefinition, GetStorageGroupType(), persistentMixinFinder, _instanceCreator);

            var properties = MappingObjectFactory.CreatePropertyDefinitionCollection(classDefinition, GetPropertyInfos(classDefinition));

            classDefinition.SetPropertyDefinitions(properties);
            var endPoints = MappingObjectFactory.CreateRelationEndPointDefinitionCollection(classDefinition);

            classDefinition.SetRelationEndPointDefinitions(endPoints);

            return(classDefinition);
        }
Пример #12
0
        public void FindPropertyInfos_WithMixins_ForDerived()
        {
            var persistentMixinFinder = new PersistentMixinFinder(typeof(TargetClassB));
            var propertyFinder        = new StubPropertyFinderBase(typeof(TargetClassB), false, true, persistentMixinFinder);

            Assert.That(
                propertyFinder.FindPropertyInfos(),
                Is.EquivalentTo(
                    new[]
            {
                GetProperty(typeof(TargetClassB), "P3"),
                GetProperty(typeof(TargetClassB), "P4"),
                GetProperty(typeof(MixinB), "P6"),
                GetProperty(typeof(MixinE), "P9"),
            }));
        }
Пример #13
0
        public void FindPropertyInfos_WithMixins_ForNonInheritanceRoot()
        {
            var persistentMixinFinder = new PersistentMixinFinder(typeof(TargetClassA));
            var propertyFinder        = new StubPropertyFinderBase(typeof(TargetClassA), false, true, persistentMixinFinder);

            Assert.That(
                propertyFinder.FindPropertyInfos(),
                Is.EquivalentTo(
                    new[]
            {
                GetProperty(typeof(TargetClassA), "P1"),
                GetProperty(typeof(TargetClassA), "P2"),
                GetProperty(typeof(MixinA), "P5"),
                GetProperty(typeof(MixinC), "P7"),
                GetProperty(typeof(MixinD), "P8"),
            }));
        }
 public void IsPersistenceRelevant()
 {
     Assert.That(PersistentMixinFinder.IsPersistenceRelevant(typeof(MixinBase)), Is.True);
     Assert.That(PersistentMixinFinder.IsPersistenceRelevant(typeof(MixinA)), Is.True);
     Assert.That(PersistentMixinFinder.IsPersistenceRelevant(typeof(NonDomainObjectMixin)), Is.False);
 }
 private void CheckPersistentMixins(Type targetType, bool includeInherited, params Type[] expectedTypes)
 {
     Type[] mixinTypes = new PersistentMixinFinder(targetType, includeInherited).GetPersistentMixins();
     Assert.That(mixinTypes, Is.EquivalentTo(expectedTypes));
 }