Inheritance: MappingBase, ICollectionContentsMapping
        public void ShouldWriteOneToManyForOneToManyMapping()
        {
            var mapping = new OneToManyMapping();

            writer.VerifyXml(mapping)
                .RootElement.HasName("one-to-many");
        }
コード例 #2
0
        public override void establish_context()
        {
            manyToOneARankedFirstToHolder = new ManyToOneMapping();
            manyToOneARankedFirstToHolder.Set(x => x.Class, Layer.Defaults, new TypeReference(typeof(Holder)));
            manyToOneARankedFirstToHolder.Set(x => x.Name, Layer.Defaults, "ARankedFirstProperty");
            manyToOneARankedFirstToHolder.ContainingEntityType = typeof(ARankedFirst);
            manyToOneARankedFirstToHolder.Member = new PropertyMember(typeof(ARankedFirst).GetProperty("ARankedFirstProperty"));

            manyToOneBRankedSecondToHolder = new ManyToOneMapping();
            manyToOneBRankedSecondToHolder.Set(x => x.Class, Layer.Defaults, new TypeReference(typeof(Holder)));
            manyToOneBRankedSecondToHolder.Set(x => x.Name, Layer.Defaults, "BRankedSecondProperty");
            manyToOneBRankedSecondToHolder.ContainingEntityType = typeof(BRankedSecond);
            manyToOneBRankedSecondToHolder.Member = new PropertyMember(typeof(BRankedSecond).GetProperty("BRankedSecondProperty"));

            var relationship = new OneToManyMapping();
            relationship.Set(x => x.Class, Layer.Defaults, new TypeReference(typeof(BRankedSecond)));
            relationship.ContainingEntityType = typeof(Holder);

            collectionMappingToBRankedSecond = CollectionMapping.Bag();
            collectionMappingToBRankedSecond.Set(x => x.ChildType, Layer.Defaults, typeof(BRankedSecond));
            collectionMappingToBRankedSecond.Set(x => x.Name, Layer.Defaults, "ColectionOfBRankedSeconds");
            collectionMappingToBRankedSecond.Set(x => x.Relationship, Layer.Defaults, relationship);
            collectionMappingToBRankedSecond.ContainingEntityType = typeof(Holder);

            visitor = new RelationshipPairingVisitor(A.Fake<PairBiDirectionalManyToManySidesDelegate>());
        }
コード例 #3
0
 public override void ProcessOneToMany(OneToManyMapping oneToManyMapping)
 {
     if (!oneToManyMapping.Attributes.IsSpecified(x => x.ClassName))
     {
         if (oneToManyMapping.ChildType == null)
             throw new ConventionException("Cannot apply the naming convention. No type specified.", oneToManyMapping);
         oneToManyMapping.ClassName = DetermineNameFromType(oneToManyMapping.ChildType);
     }
 }
コード例 #4
0
        private void SetRelationship(Member property, ClassMappingBase classMap, ICollectionMapping mapping)
        {
            var relationship = new OneToManyMapping
            {
                Class = new TypeReference(property.PropertyType.GetGenericArguments()[0]),
                ContainingEntityType = classMap.Type
            };

            mapping.SetDefaultValue(x => x.Relationship, relationship);
        }
        public void Should_write_one_to_many()
        {
            var oneToMany = new OneToManyMapping();
            var oneToManyWriter = MockRepository.GenerateStub<IHbmWriter<OneToManyMapping>>();
            oneToManyWriter.Expect(x => x.Write(oneToMany)).Return(new HbmOneToMany());
            var writer = new HbmCollectionContentsWriter(oneToManyWriter, null);

            object result = writer.Write(oneToMany);
            result.ShouldBeOfType(typeof(HbmOneToMany));
        }
コード例 #6
0
        static void SetRelationship(Member property, ClassMappingBase classMap, CollectionMapping mapping)
        {
            var relationship = new OneToManyMapping
            {
                ContainingEntityType = classMap.Type
            };
            relationship.Set(x => x.Class, Layer.Defaults, new TypeReference(property.PropertyType.GetGenericArguments()[0]));

            mapping.Set(x => x.Relationship, Layer.Defaults, relationship);
        }
        public void Should_return_null_when_writing_unrecognised_object_after_having_processed_a_recognised_object()
        {
            var recognisedMapping = new OneToManyMapping();
            var oneToManyWriter = MockRepository.GenerateStub<IHbmWriter<OneToManyMapping>>();
            oneToManyWriter.Expect(x => x.Write(recognisedMapping)).Return(new HbmOneToMany());
            var writer = new HbmCollectionContentsWriter(oneToManyWriter, null);

            writer.ProcessOneToMany(recognisedMapping);

            var result = writer.Write(new UnrecognisedCollectionContents());
            result.ShouldBeNull();
        }
コード例 #8
0
 public bool Equals(OneToManyMapping other)
 {
     if (ReferenceEquals(null, other))
     {
         return(false);
     }
     if (ReferenceEquals(this, other))
     {
         return(true);
     }
     return(Equals(other.attributes, attributes) && Equals(other.ContainingEntityType, ContainingEntityType));
 }
コード例 #9
0
 public virtual void Visit(OneToManyMapping mapping)
 {
 }
コード例 #10
0
 public virtual void ProcessOneToMany(OneToManyMapping oneToManyMapping)
 {
 }
 public void ExceptionOnNotFound_should_default_to_true()
 {
     var oneToMany = new OneToManyMapping();
     oneToMany.Attributes.IsSpecified(x => x.ExceptionOnNotFound).ShouldBeFalse();
     oneToMany.ExceptionOnNotFound.ShouldBeTrue();
 }
コード例 #12
0
        public void Should_apply_to_one_to_many_mapping()
        {
            var oneToManyMapping = new OneToManyMapping();
            oneToManyMapping.ChildType = typeof (Album);
            _namingConvention.ProcessOneToMany(oneToManyMapping);

            oneToManyMapping.ClassName.ShouldEqual(oneToManyMapping.ChildType.AssemblyQualifiedName);
        }
 public void Should_produce_valid_hbm()
 {
     var oneToMany = new OneToManyMapping() { ClassName = "class1" };
     var writer = new HbmOneToManyWriter();
     writer.ShouldGenerateValidOutput(oneToMany);
 }
コード例 #14
0
 public OneToManyInspector(OneToManyMapping mapping)
 {
     this.mapping = mapping;
 }
コード例 #15
0
 public override void ProcessOneToMany(OneToManyMapping oneToManyMapping)
 {
     ProcessCollectionContents(oneToManyMapping);
 }
 public void CreateDsl()
 {
     mapping = new OneToManyMapping();
     inspector = new OneToManyInspector(mapping);
 }
コード例 #17
0
 public OneToManyInstance(OneToManyMapping mapping)
     : base(mapping)
 {
     this.mapping = mapping;
 }