Exemplo n.º 1
0
        public void GetMetadata_ForBaseClass()
        {
            DomainModelConstraintProviderStub
            .Stub(stub => stub.IsNullable(Arg <IPropertyInformation> .Matches(pi => pi.Name == "BaseString")))
            .Return(true);
            DomainModelConstraintProviderStub
            .Stub(stub => stub.IsNullable(Arg <IPropertyInformation> .Matches(pi => pi.Name == "BaseUnidirectionalOneToOne")))
            .Return(true);
            DomainModelConstraintProviderStub
            .Stub(stub => stub.IsNullable(Arg <IPropertyInformation> .Matches(pi => pi.Name == "BasePrivateUnidirectionalOneToOne")))
            .Return(true);
            DomainModelConstraintProviderStub
            .Stub(stub => stub.IsNullable(Arg <IPropertyInformation> .Matches(pi => pi.Name == "String")))
            .Return(true);
            DomainModelConstraintProviderStub
            .Stub(stub => stub.IsNullable(Arg <IPropertyInformation> .Matches(pi => pi.Name == "UnidirectionalOneToOne")))
            .Return(true);
            DomainModelConstraintProviderStub
            .Stub(stub => stub.IsNullable(Arg <IPropertyInformation> .Matches(pi => pi.Name == "PrivateString")))
            .Return(true);

            ClassIDProviderStub.Stub(stub => stub.GetClassID(typeof(ClassWithDifferentProperties))).Return("ClassWithDifferentProperties");

            var classReflector = CreateClassReflector(typeof(ClassWithDifferentProperties));
            var expected       = CreateClassWithDifferentPropertiesClassDefinition();

            var actual = classReflector.GetMetadata(null);

            Assert.That(actual, Is.Not.Null);
            _classDefinitionChecker.Check(expected, actual);
            _endPointDefinitionChecker.Check(expected.MyRelationEndPointDefinitions, actual.MyRelationEndPointDefinitions, false);
        }
Exemplo n.º 2
0
        public void GetMetadata_ForClosedGenericClass()
        {
            ClassIDProviderStub.Stub(stub => stub.GetClassID(typeof(ClosedGenericClass))).Return("ClassID");

            var classReflector = CreateClassReflector(typeof(ClosedGenericClass));

            Assert.That(classReflector.GetMetadata(null), Is.Not.Null);
        }
Exemplo n.º 3
0
        public void GetMetadata_ForMixedClass()
        {
            ClassIDProviderStub.Stub(stub => stub.GetClassID(typeof(TargetClassA))).Return("ClassID");

            var classReflector = CreateClassReflector(typeof(TargetClassA));
            var actual         = classReflector.GetMetadata(null);

            Assert.That(actual.PersistentMixins, Is.EquivalentTo(new[] { typeof(MixinA), typeof(MixinC), typeof(MixinD) }));
        }
Exemplo n.º 4
0
        public void GetMetadata_InstanceCreator()
        {
            ClassIDProviderStub.Stub(stub => stub.GetClassID(typeof(ClassWithDifferentProperties))).Return("ClassID");

            var classReflector = CreateClassReflector(typeof(ClassWithDifferentProperties));

            var actual = classReflector.GetMetadata(null);

            Assert.That(actual.InstanceCreator, Is.SameAs(DomainObjectCreatorStub));
        }
Exemplo n.º 5
0
        public void GetMetadata_PersistentMixinFinder_ForBaseClass()
        {
            ClassIDProviderStub.Stub(mock => mock.GetClassID(typeof(ClassWithDifferentProperties))).Return("ClassID");

            var classReflector = CreateClassReflector(typeof(ClassWithDifferentProperties));

            var actual = classReflector.GetMetadata(null);

            Assert.That(actual.PersistentMixinFinder.IncludeInherited, Is.True);
        }
Exemplo n.º 6
0
        public void GetMetadata_PersistentMixinFinder_ForDerivedClass()
        {
            ClassIDProviderStub.Stub(stub => stub.GetClassID(typeof(DerivedClassWithDifferentProperties))).Return("ClassID");

            var classReflector      = CreateClassReflector(typeof(DerivedClassWithDifferentProperties));
            var baseClassDefinition = ClassDefinitionObjectMother.CreateClassDefinition_WithEmptyMembers_AndDerivedClasses();

            var actual = classReflector.GetMetadata(baseClassDefinition);

            Assert.That(actual.PersistentMixinFinder.IncludeInherited, Is.False);
        }
Exemplo n.º 7
0
        public void GetMetadata_GetClassID()
        {
            ClassIDProviderStub.Stub(stub => stub.GetClassID(typeof(ClassHavingClassIDAttribute))).Return("ClassIDForClassHavingClassIDAttribute");

            var classReflector = CreateClassReflector(typeof(ClassHavingClassIDAttribute));

            var actual = classReflector.GetMetadata(null);

            Assert.That(actual, Is.Not.Null);
            Assert.That(actual.ID, Is.EqualTo("ClassIDForClassHavingClassIDAttribute"));
        }
Exemplo n.º 8
0
        public void GetMetadata_ForClassWithStorageGroupAttribute()
        {
            var type = typeof(ClassWithStorageGroupAttributeAndBaseClass);

            ClassIDProviderStub.Stub(stub => stub.GetClassID(type)).Return("ClassID");
            Assert.That(type.IsDefined(typeof(DBStorageGroupAttribute), false), Is.True);

            var classReflector = CreateClassReflector(type);

            var actual = classReflector.GetMetadata(null);

            Assert.That(actual, Is.Not.Null);
            Assert.That(actual.StorageGroupType, Is.SameAs(typeof(DBStorageGroupAttribute)));
        }
Exemplo n.º 9
0
        public void GetMetadata_ForClassWithVirtualRelationEndPoints()
        {
            DomainModelConstraintProviderStub
            .Stub(stub => stub.IsNullable(Arg <IPropertyInformation> .Matches(pi => pi.Name == "BaseBidirectionalOneToOne")))
            .Return(true);
            DomainModelConstraintProviderStub
            .Stub(stub => stub.IsNullable(Arg <IPropertyInformation> .Matches(pi => pi.Name == "BaseBidirectionalOneToMany")))
            .Return(true);
            DomainModelConstraintProviderStub
            .Stub(stub => stub.IsNullable(Arg <IPropertyInformation> .Matches(pi => pi.Name == "BasePrivateBidirectionalOneToOne")))
            .Return(true);
            DomainModelConstraintProviderStub
            .Stub(stub => stub.IsNullable(Arg <IPropertyInformation> .Matches(pi => pi.Name == "BasePrivateBidirectionalOneToMany")))
            .Return(true);
            DomainModelConstraintProviderStub
            .Stub(stub => stub.IsNullable(Arg <IPropertyInformation> .Matches(pi => pi.Name == "NoAttribute")))
            .Return(true);
            DomainModelConstraintProviderStub
            .Stub(stub => stub.IsNullable(Arg <IPropertyInformation> .Matches(pi => pi.Name == "NotNullable")))
            .Return(false);
            DomainModelConstraintProviderStub
            .Stub(stub => stub.IsNullable(Arg <IPropertyInformation> .Matches(pi => pi.Name == "BidirectionalOneToOne")))
            .Return(true);
            DomainModelConstraintProviderStub
            .Stub(stub => stub.IsNullable(Arg <IPropertyInformation> .Matches(pi => pi.Name == "BidirectionalOneToMany")))
            .Return(true);

            ClassIDProviderStub.Stub(stub => stub.GetClassID(typeof(ClassWithVirtualRelationEndPoints))).Return("ClassWithVirtualRelationEndPoints");

            var classReflector = CreateClassReflector(typeof(ClassWithVirtualRelationEndPoints));
            var expected       = CreateClassWithVirtualRelationEndPointsClassDefinition();

            expected.SetPropertyDefinitions(new PropertyDefinitionCollection());
            CreateEndPointDefinitionsForClassWithVirtualRelationEndPoints(expected);

            var actual = classReflector.GetMetadata(null);

            Assert.That(actual, Is.Not.Null);
            _classDefinitionChecker.Check(expected, actual);
            _endPointDefinitionChecker.Check(expected.MyRelationEndPointDefinitions, actual.MyRelationEndPointDefinitions, false);
        }