7
7
8
8
namespace FluentNHibernate . Testing . Visitors
9
9
{
10
- public abstract class RelationshipPairingVisitorSpec : Specification
10
+ [ TestFixture ]
11
+ public class when_the_relationship_pairing_visitor_visits_with_multiple_many_to_one_mapping_references : Specification
11
12
{
12
13
protected RelationshipPairingVisitor visitor ;
13
- protected CollectionMapping collectionMappingToZ ;
14
- protected ManyToOneMapping manyToOneZToHolder ;
15
- protected ManyToOneMapping manyToOneYToHolder ;
16
- }
14
+ protected CollectionMapping collectionMappingToBRankedSecond ;
15
+ protected ManyToOneMapping manyToOneBRankedSecondToHolder ;
16
+ protected ManyToOneMapping manyToOneARankedFirstToHolder ;
17
17
18
- [ TestFixture ]
19
- public class when_the_relationship_pairing_visitor_visits_with_multiple_many_to_one_mapping_references : RelationshipPairingVisitorSpec
20
- {
21
18
public override void establish_context ( )
22
19
{
23
- manyToOneYToHolder = new ManyToOneMapping ( ) ;
24
- manyToOneYToHolder . Set ( x => x . Class , Layer . Defaults , new TypeReference ( typeof ( Holder ) ) ) ;
25
- manyToOneYToHolder . Set ( x => x . Name , Layer . Defaults , "ARankedFirstProperty" ) ;
26
- manyToOneYToHolder . ContainingEntityType = typeof ( ARankedFirst ) ;
27
- manyToOneYToHolder . Member = new PropertyMember ( typeof ( ARankedFirst ) . GetProperty ( "ARankedFirstProperty" ) ) ;
28
-
29
- manyToOneZToHolder = new ManyToOneMapping ( ) ;
30
- manyToOneZToHolder . Set ( x => x . Class , Layer . Defaults , new TypeReference ( typeof ( Holder ) ) ) ;
31
- manyToOneZToHolder . Set ( x => x . Name , Layer . Defaults , "BRankedSecondProperty" ) ;
32
- manyToOneZToHolder . ContainingEntityType = typeof ( BRankedSecond ) ;
33
- manyToOneZToHolder . Member = new PropertyMember ( typeof ( BRankedSecond ) . GetProperty ( "BRankedSecondProperty" ) ) ;
20
+ manyToOneARankedFirstToHolder = new ManyToOneMapping ( ) ;
21
+ manyToOneARankedFirstToHolder . Set ( x => x . Class , Layer . Defaults , new TypeReference ( typeof ( Holder ) ) ) ;
22
+ manyToOneARankedFirstToHolder . Set ( x => x . Name , Layer . Defaults , "ARankedFirstProperty" ) ;
23
+ manyToOneARankedFirstToHolder . ContainingEntityType = typeof ( ARankedFirst ) ;
24
+ manyToOneARankedFirstToHolder . Member = new PropertyMember ( typeof ( ARankedFirst ) . GetProperty ( "ARankedFirstProperty" ) ) ;
25
+
26
+ manyToOneBRankedSecondToHolder = new ManyToOneMapping ( ) ;
27
+ manyToOneBRankedSecondToHolder . Set ( x => x . Class , Layer . Defaults , new TypeReference ( typeof ( Holder ) ) ) ;
28
+ manyToOneBRankedSecondToHolder . Set ( x => x . Name , Layer . Defaults , "BRankedSecondProperty" ) ;
29
+ manyToOneBRankedSecondToHolder . ContainingEntityType = typeof ( BRankedSecond ) ;
30
+ manyToOneBRankedSecondToHolder . Member = new PropertyMember ( typeof ( BRankedSecond ) . GetProperty ( "BRankedSecondProperty" ) ) ;
34
31
35
32
var relationship = new OneToManyMapping ( ) ;
36
33
relationship . Set ( x => x . Class , Layer . Defaults , new TypeReference ( typeof ( BRankedSecond ) ) ) ;
37
34
relationship . ContainingEntityType = typeof ( Holder ) ;
38
35
39
- collectionMappingToZ = CollectionMapping . Bag ( ) ;
40
- collectionMappingToZ . Set ( x => x . ChildType , Layer . Defaults , typeof ( BRankedSecond ) ) ;
41
- collectionMappingToZ . Set ( x => x . Name , Layer . Defaults , "ColectionOfBRankedSeconds" ) ;
42
- collectionMappingToZ . Set ( x => x . Relationship , Layer . Defaults , relationship ) ;
43
- collectionMappingToZ . ContainingEntityType = typeof ( Holder ) ;
36
+ collectionMappingToBRankedSecond = CollectionMapping . Bag ( ) ;
37
+ collectionMappingToBRankedSecond . Set ( x => x . ChildType , Layer . Defaults , typeof ( BRankedSecond ) ) ;
38
+ collectionMappingToBRankedSecond . Set ( x => x . Name , Layer . Defaults , "ColectionOfBRankedSeconds" ) ;
39
+ collectionMappingToBRankedSecond . Set ( x => x . Relationship , Layer . Defaults , relationship ) ;
40
+ collectionMappingToBRankedSecond . ContainingEntityType = typeof ( Holder ) ;
44
41
45
42
visitor = new RelationshipPairingVisitor ( A . Fake < PairBiDirectionalManyToManySidesDelegate > ( ) ) ;
46
43
}
47
44
48
45
[ Test ]
49
46
public void should_associate_the_collection_mapping_to_the_correct_type ( )
50
47
{
51
- visitor . ProcessCollection ( collectionMappingToZ ) ;
52
- visitor . ProcessManyToOne ( manyToOneYToHolder ) ;
53
- visitor . ProcessManyToOne ( manyToOneZToHolder ) ;
48
+ visitor . ProcessCollection ( collectionMappingToBRankedSecond ) ;
49
+ visitor . ProcessManyToOne ( manyToOneARankedFirstToHolder ) ;
50
+ visitor . ProcessManyToOne ( manyToOneBRankedSecondToHolder ) ;
54
51
visitor . Visit ( Enumerable . Empty < HibernateMapping > ( ) ) ;
55
52
56
- var otherSide = ( ManyToOneMapping ) collectionMappingToZ . OtherSide ;
53
+ var otherSide = ( ManyToOneMapping ) collectionMappingToBRankedSecond . OtherSide ;
57
54
otherSide . ContainingEntityType . ShouldEqual ( typeof ( BRankedSecond ) ) ;
58
55
}
59
56
}
60
- }
57
+ }
0 commit comments