2
2
using System . Collections . Generic ;
3
3
using System . Linq ;
4
4
using System . Text ;
5
+ using FakeItEasy ;
5
6
using FluentNHibernate . Conventions ;
6
7
using FluentNHibernate . Conventions . Inspections ;
7
8
using FluentNHibernate . Conventions . Instances ;
8
9
using FluentNHibernate . Mapping ;
9
10
using FluentNHibernate . MappingModel ;
10
11
using NUnit . Framework ;
11
- using Rhino . Mocks ;
12
12
13
13
namespace FluentNHibernate . Testing . ConventionsTests
14
14
{
@@ -20,147 +20,145 @@ public void ConventionSetsProxyOnProxiedClass()
20
20
{
21
21
ProxyConvention convention = GetConvention ( ) ;
22
22
23
- var classInstance = MockRepository . GenerateMock < IClassInstance > ( ) ;
24
- classInstance . Expect ( x => x . EntityType )
25
- . Return ( typeof ( ProxiedObject ) ) ;
26
-
23
+ var classInstance = A . Fake < IClassInstance > ( ) ;
24
+ A . CallTo ( ( ) => classInstance . EntityType ) . Returns ( typeof ( ProxiedObject ) ) ;
25
+
27
26
convention . Apply ( classInstance ) ;
28
27
29
- classInstance . AssertWasCalled ( x => x . Proxy ( typeof ( IProxiedObject ) ) ) ;
28
+ A . CallTo ( ( ) => classInstance . Proxy ( typeof ( IProxiedObject ) ) )
29
+ . MustHaveHappened ( ) ;
30
30
}
31
31
32
32
[ Test ]
33
33
public void ConventionSetsProxyOnProxiedSubclass ( )
34
34
{
35
35
ProxyConvention convention = GetConvention ( ) ;
36
36
37
- var classInstance = MockRepository . GenerateMock < ISubclassInstance > ( ) ;
38
- classInstance . Expect ( x => x . EntityType )
39
- . Return ( typeof ( ProxiedObject ) ) ;
37
+ var classInstance = A . Fake < ISubclassInstance > ( ) ;
38
+ A . CallTo ( ( ) => classInstance . EntityType ) . Returns ( typeof ( ProxiedObject ) ) ;
40
39
41
40
convention . Apply ( classInstance ) ;
42
41
43
- classInstance . AssertWasCalled ( x => x . Proxy ( typeof ( IProxiedObject ) ) ) ;
42
+ A . CallTo ( ( ) => classInstance . Proxy ( typeof ( IProxiedObject ) ) )
43
+ . MustHaveHappened ( ) ;
44
44
}
45
45
46
46
[ Test ]
47
47
public void ConventionDoesNotSetProxyOnUnproxiedClass ( )
48
48
{
49
49
ProxyConvention convention = GetConvention ( ) ;
50
50
51
- var classInstance = MockRepository . GenerateMock < IClassInstance > ( ) ;
52
- classInstance . Stub ( x => x . EntityType )
53
- . Return ( typeof ( NotProxied ) ) ;
51
+ var classInstance = A . Fake < IClassInstance > ( ) ;
52
+ A . CallTo ( ( ) => classInstance . EntityType ) . Returns ( typeof ( NotProxied ) ) ;
54
53
55
54
convention . Apply ( classInstance ) ;
56
55
57
- classInstance . AssertWasNotCalled ( x => x . Proxy ( Arg < Type > . Is . Anything ) ) ;
56
+ A . CallTo ( ( ) => classInstance . Proxy ( A < Type > . _ ) ) . MustNotHaveHappened ( ) ;
58
57
}
59
58
60
59
[ Test ]
61
60
public void ConventionDoesNotSetProxyOnUnproxiedSubclass ( )
62
61
{
63
62
ProxyConvention convention = GetConvention ( ) ;
64
63
65
- var classInstance = MockRepository . GenerateMock < ISubclassInstance > ( ) ;
66
- classInstance . Stub ( x => x . EntityType )
67
- . Return ( typeof ( NotProxied ) ) ;
64
+ var classInstance = A . Fake < ISubclassInstance > ( ) ;
65
+ A . CallTo ( ( ) => classInstance . EntityType ) . Returns ( typeof ( NotProxied ) ) ;
68
66
69
67
convention . Apply ( classInstance ) ;
70
68
71
- classInstance . AssertWasNotCalled ( x => x . Proxy ( Arg < Type > . Is . Anything ) ) ;
69
+ A . CallTo ( ( ) => classInstance . Proxy ( A < Type > . _ ) ) . MustNotHaveHappened ( ) ;
72
70
}
73
71
74
72
[ Test ]
75
73
public void ConventionSetsProxiedCollectionChildTypeToConcreteType ( )
76
74
{
77
75
ProxyConvention convention = GetConvention ( ) ;
78
76
79
- var collectionInstance = MockRepository . GenerateMock < ICollectionInstance > ( ) ;
80
- var relationship = MockRepository . GenerateMock < IRelationshipInstance > ( ) ;
77
+ var collectionInstance = A . Fake < ICollectionInstance > ( ) ;
78
+ var relationship = A . Fake < IRelationshipInstance > ( ) ;
81
79
82
- collectionInstance . Stub ( x => x . Relationship )
83
- . Return ( relationship ) ;
84
- relationship . Stub ( x => x . Class )
85
- . Return ( new TypeReference ( typeof ( IProxiedObject ) ) ) ;
80
+ A . CallTo ( ( ) => collectionInstance . Relationship ) . Returns ( relationship ) ;
81
+ A . CallTo ( ( ) => relationship . Class ) . Returns ( new TypeReference ( typeof ( IProxiedObject ) ) ) ;
86
82
87
83
convention . Apply ( collectionInstance ) ;
88
84
89
- relationship . AssertWasCalled ( x => x . CustomClass ( typeof ( ProxiedObject ) ) ) ;
85
+ A . CallTo ( ( ) => relationship . CustomClass ( typeof ( ProxiedObject ) ) )
86
+ . MustHaveHappened ( ) ;
90
87
}
91
88
92
89
[ Test ]
93
90
public void ConventionDoesNotSetCollectionChildTypeIfUnrecognised ( )
94
91
{
95
92
ProxyConvention convention = GetConvention ( ) ;
96
93
97
- var collectionInstance = MockRepository . GenerateMock < ICollectionInstance > ( ) ;
98
- var relationship = MockRepository . GenerateMock < IRelationshipInstance > ( ) ;
94
+ var collectionInstance = A . Fake < ICollectionInstance > ( ) ;
95
+ var relationship = A . Fake < IRelationshipInstance > ( ) ;
99
96
100
- collectionInstance . Stub ( x => x . Relationship )
101
- . Return ( relationship ) ;
102
- relationship . Stub ( x => x . Class )
103
- . Return ( new TypeReference ( typeof ( NotProxied ) ) ) ;
97
+ A . CallTo ( ( ) => collectionInstance . Relationship ) . Returns ( relationship ) ;
98
+ A . CallTo ( ( ) => relationship . Class ) . Returns ( new TypeReference ( typeof ( NotProxied ) ) ) ;
104
99
105
100
convention . Apply ( collectionInstance ) ;
106
101
107
- relationship . AssertWasNotCalled ( x => x . CustomClass ( Arg < Type > . Is . Anything ) ) ;
102
+ A . CallTo ( ( ) => relationship . CustomClass ( A < Type > . _ ) )
103
+ . MustNotHaveHappened ( ) ;
108
104
}
109
105
110
106
[ Test ]
111
107
public void ConventionSetsProxiedManyToOneTypeToConcreteType ( )
112
108
{
113
109
ProxyConvention convention = GetConvention ( ) ;
114
110
115
- var manyToOneInstance = MockRepository . GenerateMock < IManyToOneInstance > ( ) ;
116
- manyToOneInstance . Stub ( x => x . Class )
117
- . Return ( new TypeReference ( typeof ( IProxiedObject ) ) ) ;
111
+ var manyToOneInstance = A . Fake < IManyToOneInstance > ( ) ;
112
+ A . CallTo ( ( ) => manyToOneInstance . Class ) . Returns ( new TypeReference ( typeof ( IProxiedObject ) ) ) ;
118
113
119
114
convention . Apply ( manyToOneInstance ) ;
120
115
121
- manyToOneInstance . AssertWasCalled ( x => x . OverrideInferredClass ( typeof ( ProxiedObject ) ) ) ;
116
+ A . CallTo ( ( ) => manyToOneInstance . OverrideInferredClass ( typeof ( ProxiedObject ) ) )
117
+ . MustHaveHappened ( ) ;
122
118
}
123
119
124
120
[ Test ]
125
121
public void ConventionDoesNotSetManyToOneTypeIfUnrecognised ( )
126
122
{
127
123
ProxyConvention convention = GetConvention ( ) ;
128
124
129
- var manyToOneInstance = MockRepository . GenerateMock < IManyToOneInstance > ( ) ;
130
- manyToOneInstance . Stub ( x => x . Class )
131
- . Return ( new TypeReference ( typeof ( NotProxied ) ) ) ;
125
+ var manyToOneInstance = A . Fake < IManyToOneInstance > ( ) ;
126
+ A . CallTo ( ( ) => manyToOneInstance . Class ) . Returns ( new TypeReference ( typeof ( NotProxied ) ) ) ;
132
127
133
128
convention . Apply ( manyToOneInstance ) ;
134
129
135
- manyToOneInstance . AssertWasNotCalled ( x => x . OverrideInferredClass ( typeof ( ProxiedObject ) ) ) ;
130
+ A . CallTo ( ( ) => manyToOneInstance . OverrideInferredClass ( typeof ( ProxiedObject ) ) )
131
+ . MustNotHaveHappened ( ) ;
136
132
}
137
133
138
134
[ Test ]
139
135
public void ConventionSetsProxiedOneToOneTypeToConcreteType ( )
140
136
{
141
137
ProxyConvention convention = GetConvention ( ) ;
142
138
143
- var oneToOneInstance = MockRepository . GenerateMock < IOneToOneInstance > ( ) ;
144
- oneToOneInstance . Stub ( x => ( ( IOneToOneInspector ) x ) . Class )
145
- . Return ( new TypeReference ( typeof ( IProxiedObject ) ) ) ;
139
+ var oneToOneInstance = A . Fake < IOneToOneInstance > ( ) ;
140
+ A . CallTo ( ( ) => ( ( IOneToOneInspector ) oneToOneInstance ) . Class )
141
+ . Returns ( new TypeReference ( typeof ( IProxiedObject ) ) ) ;
146
142
147
143
convention . Apply ( oneToOneInstance ) ;
148
144
149
- oneToOneInstance . AssertWasCalled ( x => x . OverrideInferredClass ( typeof ( ProxiedObject ) ) ) ;
145
+ A . CallTo ( ( ) => oneToOneInstance . OverrideInferredClass ( typeof ( ProxiedObject ) ) )
146
+ . MustHaveHappened ( ) ;
150
147
}
151
148
152
149
[ Test ]
153
150
public void ConventionDoesNotSetOneToOneTypeIfUnrecognised ( )
154
151
{
155
152
ProxyConvention convention = GetConvention ( ) ;
156
153
157
- var oneToOneInstance = MockRepository . GenerateMock < IOneToOneInstance > ( ) ;
158
- oneToOneInstance . Stub ( x => ( ( IOneToOneInspector ) x ) . Class )
159
- . Return ( new TypeReference ( typeof ( NotProxied ) ) ) ;
154
+ var oneToOneInstance = A . Fake < IOneToOneInstance > ( ) ;
155
+ A . CallTo ( ( ) => ( ( IOneToOneInspector ) oneToOneInstance ) . Class )
156
+ . Returns ( new TypeReference ( typeof ( NotProxied ) ) ) ;
160
157
161
158
convention . Apply ( oneToOneInstance ) ;
162
159
163
- oneToOneInstance . AssertWasNotCalled ( x => x . OverrideInferredClass ( typeof ( ProxiedObject ) ) ) ;
160
+ A . CallTo ( ( ) => oneToOneInstance . OverrideInferredClass ( typeof ( ProxiedObject ) ) )
161
+ . MustNotHaveHappened ( ) ;
164
162
}
165
163
166
164
private static ProxyConvention GetConvention ( )
0 commit comments