8
8
using FluentNHibernate . Testing . DomainModel ;
9
9
using FluentNHibernate . Testing . Fixtures . Basic ;
10
10
using FluentNHibernate . Testing . Fixtures . MixedMappingsInSameLocation ;
11
+ using FluentNHibernate . Testing . Fixtures . MixedMappingsInSameLocation . Mappings ;
11
12
using NHibernate . Cfg ;
12
13
using NUnit . Framework ;
13
14
@@ -93,7 +94,7 @@ public void MappingsCanBeMixedAndDontConflict()
93
94
. Database ( SQLiteConfiguration . Standard . InMemory )
94
95
. Mappings ( m =>
95
96
{
96
- m . FluentMappings . AddFromAssemblyOf < Foo > ( ) ;
97
+ m . FluentMappings . Add < FooMap > ( ) ;
97
98
m . AutoMappings . Add ( AutoMap . AssemblyOf < Bar > ( )
98
99
. Where ( t => t . Namespace == typeof ( Bar ) . Namespace ) ) ;
99
100
} )
@@ -108,7 +109,7 @@ public void ShouldGetASessionFactoryIfEverythingIsOK()
108
109
var sessionFactory = Fluently . Configure ( )
109
110
. Database ( SQLiteConfiguration . Standard . InMemory )
110
111
. Mappings ( m =>
111
- m . FluentMappings . AddFromAssemblyOf < Record > ( ) )
112
+ m . FluentMappings . Add < BinaryRecordMap > ( ) )
112
113
. BuildSessionFactory ( ) ;
113
114
114
115
sessionFactory . ShouldNotBeNull ( ) ;
@@ -120,19 +121,31 @@ public void ShouldGetAConfigurationIfEverythingIsOK()
120
121
var configuration = Fluently . Configure ( )
121
122
. Database ( SQLiteConfiguration . Standard . InMemory )
122
123
. Mappings ( m =>
123
- m . FluentMappings . AddFromAssemblyOf < Record > ( ) )
124
+ m . FluentMappings . Add < BinaryRecordMap > ( ) )
124
125
. BuildConfiguration ( ) ;
125
126
126
127
configuration . ShouldNotBeNull ( ) ;
127
128
}
128
129
129
130
[ Test ]
130
- public void ShouldSetCurrentSessionContext ( ) { var configuration = Fluently . Configure ( ) . CurrentSessionContext ( "thread_static" ) . BuildConfiguration ( ) ;
131
- configuration . Properties [ "current_session_context_class" ] . ShouldEqual ( "thread_static" ) ; }
131
+ public void ShouldSetCurrentSessionContext ( )
132
+ {
133
+ var configuration = Fluently . Configure ( )
134
+ . CurrentSessionContext ( "thread_static" )
135
+ . BuildConfiguration ( ) ;
136
+
137
+ configuration . Properties [ "current_session_context_class" ] . ShouldEqual ( "thread_static" ) ;
138
+ }
132
139
133
140
[ Test ]
134
- public void ShouldSetCurrentSessionContextUsingGeneric ( ) { var configuration = Fluently . Configure ( ) . CurrentSessionContext < NHibernate . Context . ThreadStaticSessionContext > ( ) . BuildConfiguration ( ) ;
135
- configuration . Properties [ "current_session_context_class" ] . ShouldEqual ( typeof ( NHibernate . Context . ThreadStaticSessionContext ) . AssemblyQualifiedName ) ; }
141
+ public void ShouldSetCurrentSessionContextUsingGeneric ( )
142
+ {
143
+ var configuration = Fluently . Configure ( )
144
+ . CurrentSessionContext < NHibernate . Context . ThreadStaticSessionContext > ( )
145
+ . BuildConfiguration ( ) ;
146
+
147
+ configuration . Properties [ "current_session_context_class" ] . ShouldEqual ( typeof ( NHibernate . Context . ThreadStaticSessionContext ) . AssemblyQualifiedName ) ;
148
+ }
136
149
137
150
#pragma warning disable 612 , 618
138
151
[ Test ]
@@ -166,7 +179,54 @@ public void ShouldSetConnectionIsolationLevel()
166
179
configuration . Properties [ "connection.isolation" ] . ShouldEqual ( "ReadUncommitted" ) ;
167
180
}
168
181
169
- [ Test ] public void Use_Minimal_Puts_should_set_value_to_const_true ( ) { var configuration = Fluently . Configure ( ) . Cache ( x => x . UseMinimalPuts ( ) ) . BuildConfiguration ( ) ; configuration . Properties . ShouldContain ( "cache.use_minimal_puts" , "true" ) ; } [ Test ] public void Use_Query_Cache_should_set_value_to_const_true ( ) { var configuration = Fluently . Configure ( ) . Cache ( x => x . UseQueryCache ( ) ) . BuildConfiguration ( ) ; configuration . Properties . ShouldContain ( "cache.use_query_cache" , "true" ) ; } [ Test ] public void Query_Cache_Factory_should_set_property_value ( ) { var configuration = Fluently . Configure ( ) . Cache ( x => x . QueryCacheFactory ( "foo" ) ) . BuildConfiguration ( ) ; configuration . Properties . ShouldContain ( "cache.query_cache_factory" , "foo" ) ; } [ Test ] public void Region_Prefix_should_set_property_value ( ) { var configuration = Fluently . Configure ( ) . Cache ( x => x . RegionPrefix ( "foo" ) ) . BuildConfiguration ( ) ; configuration . Properties . ShouldContain ( "cache.region_prefix" , "foo" ) ; } [ Test ] public void Provider_Class_should_set_property_value ( ) { var configuration = Fluently . Configure ( ) . Cache ( x => x . ProviderClass ( "foo" ) ) . BuildConfiguration ( ) ; } }
182
+ [ Test ]
183
+ public void Use_Minimal_Puts_should_set_value_to_const_true ( )
184
+ {
185
+ var configuration = Fluently . Configure ( )
186
+ . Cache ( x => x . UseMinimalPuts ( ) )
187
+ . BuildConfiguration ( ) ;
188
+
189
+ configuration . Properties . ShouldContain ( "cache.use_minimal_puts" , "true" ) ;
190
+ }
191
+
192
+ [ Test ]
193
+ public void Use_Query_Cache_should_set_value_to_const_true ( )
194
+ {
195
+ var configuration = Fluently . Configure ( )
196
+ . Cache ( x => x . UseQueryCache ( ) )
197
+ . BuildConfiguration ( ) ;
198
+
199
+ configuration . Properties . ShouldContain ( "cache.use_query_cache" , "true" ) ;
200
+ }
201
+
202
+ [ Test ]
203
+ public void Query_Cache_Factory_should_set_property_value ( )
204
+ {
205
+ var configuration = Fluently . Configure ( )
206
+ . Cache ( x => x . QueryCacheFactory ( "foo" ) )
207
+ . BuildConfiguration ( ) ;
208
+
209
+ configuration . Properties . ShouldContain ( "cache.query_cache_factory" , "foo" ) ;
210
+ }
211
+
212
+ [ Test ]
213
+ public void Region_Prefix_should_set_property_value ( )
214
+ {
215
+ var configuration = Fluently . Configure ( )
216
+ . Cache ( x => x . RegionPrefix ( "foo" ) )
217
+ . BuildConfiguration ( ) ;
218
+
219
+ configuration . Properties . ShouldContain ( "cache.region_prefix" , "foo" ) ;
220
+ }
221
+
222
+ [ Test ]
223
+ public void Provider_Class_should_set_property_value ( )
224
+ {
225
+ var configuration = Fluently . Configure ( )
226
+ . Cache ( x => x . ProviderClass ( "foo" ) )
227
+ . BuildConfiguration ( ) ;
228
+ }
229
+ }
170
230
171
231
[ TestFixture ]
172
232
public class InvalidFluentConfigurationTests
@@ -271,12 +331,12 @@ public void WritesFluentMappingsOut()
271
331
. Database ( SQLiteConfiguration . Standard . InMemory )
272
332
. Mappings ( m =>
273
333
m . FluentMappings
274
- . AddFromAssemblyOf < Record > ( )
334
+ . Add < BinaryRecordMap > ( )
275
335
. ExportTo ( ExportPath ) )
276
336
. BuildConfiguration ( ) ;
277
337
278
338
Directory . GetFiles ( ExportPath )
279
- . ShouldContain ( HbmFor < Record > ) ;
339
+ . ShouldContain ( HbmFor < BinaryRecord > ) ;
280
340
}
281
341
282
342
[ Test ]
@@ -288,7 +348,7 @@ public void WritesFluentMappingsOutToTextWriter()
288
348
. Database ( SQLiteConfiguration . Standard . InMemory )
289
349
. Mappings ( m =>
290
350
m . FluentMappings
291
- . AddFromAssemblyOf < Record > ( )
351
+ . Add < BinaryRecordMap > ( )
292
352
. ExportTo ( stringWriter ) )
293
353
. BuildConfiguration ( ) ;
294
354
@@ -304,7 +364,7 @@ public void WritesFluentMappingsOutMergedWhenFlagSet()
304
364
. Mappings ( m =>
305
365
m . MergeMappings ( )
306
366
. FluentMappings
307
- . AddFromAssemblyOf < Record > ( )
367
+ . Add < BinaryRecordMap > ( )
308
368
. ExportTo ( ExportPath ) )
309
369
. BuildConfiguration ( ) ;
310
370
@@ -351,18 +411,18 @@ public void WritesBothOut()
351
411
. Mappings ( m =>
352
412
{
353
413
m . FluentMappings
354
- . AddFromAssemblyOf < Record > ( )
414
+ . Add < BinaryRecordMap > ( )
355
415
. ExportTo ( ExportPath ) ;
356
416
357
- m . AutoMappings . Add ( AutoMap . AssemblyOf < Person > ( )
417
+ m . AutoMappings . Add ( AutoMap . Source ( new StubTypeSource ( typeof ( Person ) ) )
358
418
. Where ( type => type . Namespace == "FluentNHibernate.Testing.Fixtures.Basic" ) )
359
419
. ExportTo ( ExportPath ) ;
360
420
} )
361
421
. BuildSessionFactory ( ) ;
362
422
363
423
var files = Directory . GetFiles ( ExportPath ) ;
364
424
365
- files . ShouldContain ( HbmFor < Record > ) ;
425
+ files . ShouldContain ( HbmFor < BinaryRecord > ) ;
366
426
files . ShouldContain ( HbmFor < Person > ) ;
367
427
}
368
428
@@ -374,7 +434,7 @@ public void DoesNotThrowWhenExportToIsBeforeBuildConfigurationOnCachePartMapping
374
434
. Database ( SQLiteConfiguration . Standard . InMemory )
375
435
. Mappings ( m =>
376
436
m . FluentMappings
377
- . AddFromAssemblyOf < CachedRecord > ( )
437
+ . Add < CachedRecordMap > ( )
378
438
. ExportTo ( ExportPath ) )
379
439
. BuildConfiguration ( ) ;
380
440
}
0 commit comments