public void ShouldWriteOneToManyForOneToManyMapping() { var mapping = new OneToManyMapping(); writer.VerifyXml(mapping) .RootElement.HasName("one-to-many"); }
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>()); }
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); } }
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)); }
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(); }
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)); }
public virtual void Visit(OneToManyMapping mapping) { }
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(); }
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); }
public OneToManyInspector(OneToManyMapping mapping) { this.mapping = mapping; }
public override void ProcessOneToMany(OneToManyMapping oneToManyMapping) { ProcessCollectionContents(oneToManyMapping); }
public void CreateDsl() { mapping = new OneToManyMapping(); inspector = new OneToManyInspector(mapping); }
public OneToManyInstance(OneToManyMapping mapping) : base(mapping) { this.mapping = mapping; }