1
+ using NHibernate . AdoNet ;
2
+ using NHibernate . Cache ;
3
+ using NHibernate . Cfg ;
4
+ using NHibernate . Dialect ;
5
+ using NHibernate . Driver ;
6
+ using NHibernate . Hql . Classic ;
7
+ using NHibernate . Type ;
8
+ using NUnit . Framework ;
9
+ using NHibernate . Cfg . Loquacious ;
10
+ using System . Data ;
11
+ using NHibernate . Exceptions ;
12
+
13
+ namespace NHibernate . Test . CfgTest . Loquacious
14
+ {
15
+ [ TestFixture ]
16
+ public class LambdaConfigurationFixture
17
+ {
18
+ [ Test ]
19
+ public void FullConfiguration ( )
20
+ {
21
+ var configure = new Configuration ( ) ;
22
+ configure . SessionFactoryName ( "SomeName" ) ;
23
+ configure . Cache ( c =>
24
+ {
25
+ c . UseMinimalPuts = true ;
26
+ c . DefaultExpiration = 15 ;
27
+ c . RegionsPrefix = "xyz" ;
28
+ c . Provider < HashtableCacheProvider > ( ) ;
29
+ c . QueryCache < StandardQueryCache > ( ) ;
30
+ } ) ;
31
+ configure . CollectionTypeFactory < DefaultCollectionTypeFactory > ( ) ;
32
+ configure . HqlQueryTranslator < ClassicQueryTranslatorFactory > ( ) ;
33
+ configure . Proxy ( p =>
34
+ {
35
+ p . Validation = false ;
36
+ p . ProxyFactoryFactory < ByteCode . LinFu . ProxyFactoryFactory > ( ) ;
37
+ } ) ;
38
+ configure . Mappings ( m=>
39
+ {
40
+ m . DefaultCatalog = "MyCatalog" ;
41
+ m . DefaultSchema = "MySche" ;
42
+ } ) ;
43
+ configure . DataBaseIntegration ( db =>
44
+ {
45
+ db . Dialect < MsSql2000Dialect > ( ) ;
46
+ db . KeywordsAutoImport = Hbm2DDLKeyWords . AutoQuote ;
47
+ db . Batcher < SqlClientBatchingBatcherFactory > ( ) ;
48
+ db . BatchSize = 15 ;
49
+ db . ConnectionProvider < DebugConnectionProvider > ( ) ;
50
+ db . Driver < SqlClientDriver > ( ) ;
51
+ db . ConnectionReleaseMode = ConnectionReleaseMode . AfterTransaction ;
52
+ db . IsolationLevel = IsolationLevel . ReadCommitted ;
53
+ db . ConnectionString = "The connection string" ;
54
+ db . AutoCommentSql = true ;
55
+ db . ExceptionConverter < SQLStateConverter > ( ) ;
56
+ db . PrepareCommands = true ;
57
+ db . Timeout = 10 ;
58
+ db . MaximumDepthOfOuterJoinFetching = 11 ;
59
+ db . HqlToSqlSubstitutions = "true 1, false 0, yes 'Y', no 'N'" ;
60
+ db . SchemaAction = SchemaAutoAction . Validate ;
61
+ } ) ;
62
+
63
+ Assert . That ( configure . Properties [ Environment . SessionFactoryName ] , Is . EqualTo ( "SomeName" ) ) ;
64
+ Assert . That ( configure . Properties [ Environment . CacheProvider ] ,
65
+ Is . EqualTo ( typeof ( HashtableCacheProvider ) . AssemblyQualifiedName ) ) ;
66
+ Assert . That ( configure . Properties [ Environment . CacheRegionPrefix ] , Is . EqualTo ( "xyz" ) ) ;
67
+ Assert . That ( configure . Properties [ Environment . QueryCacheFactory ] ,
68
+ Is . EqualTo ( typeof ( StandardQueryCache ) . AssemblyQualifiedName ) ) ;
69
+ Assert . That ( configure . Properties [ Environment . UseMinimalPuts ] , Is . EqualTo ( "true" ) ) ;
70
+ Assert . That ( configure . Properties [ Environment . CacheDefaultExpiration ] , Is . EqualTo ( "15" ) ) ;
71
+ Assert . That ( configure . Properties [ Environment . CollectionTypeFactoryClass ] ,
72
+ Is . EqualTo ( typeof ( DefaultCollectionTypeFactory ) . AssemblyQualifiedName ) ) ;
73
+ Assert . That ( configure . Properties [ Environment . UseProxyValidator ] , Is . EqualTo ( "false" ) ) ;
74
+ Assert . That ( configure . Properties [ Environment . ProxyFactoryFactoryClass ] ,
75
+ Is . EqualTo ( typeof ( ByteCode . LinFu . ProxyFactoryFactory ) . AssemblyQualifiedName ) ) ;
76
+ Assert . That ( configure . Properties [ Environment . QueryTranslator ] ,
77
+ Is . EqualTo ( typeof ( ClassicQueryTranslatorFactory ) . AssemblyQualifiedName ) ) ;
78
+ Assert . That ( configure . Properties [ Environment . DefaultCatalog ] , Is . EqualTo ( "MyCatalog" ) ) ;
79
+ Assert . That ( configure . Properties [ Environment . DefaultSchema ] , Is . EqualTo ( "MySche" ) ) ;
80
+ Assert . That ( configure . Properties [ Environment . Dialect ] ,
81
+ Is . EqualTo ( typeof ( MsSql2000Dialect ) . AssemblyQualifiedName ) ) ;
82
+ Assert . That ( configure . Properties [ Environment . Hbm2ddlKeyWords ] , Is . EqualTo ( "auto-quote" ) ) ;
83
+ Assert . That ( configure . Properties [ Environment . BatchStrategy ] ,
84
+ Is . EqualTo ( typeof ( SqlClientBatchingBatcherFactory ) . AssemblyQualifiedName ) ) ;
85
+ Assert . That ( configure . Properties [ Environment . BatchSize ] , Is . EqualTo ( "15" ) ) ;
86
+ Assert . That ( configure . Properties [ Environment . ConnectionProvider ] ,
87
+ Is . EqualTo ( typeof ( DebugConnectionProvider ) . AssemblyQualifiedName ) ) ;
88
+ Assert . That ( configure . Properties [ Environment . ConnectionDriver ] ,
89
+ Is . EqualTo ( typeof ( SqlClientDriver ) . AssemblyQualifiedName ) ) ;
90
+ Assert . That ( configure . Properties [ Environment . ReleaseConnections ] ,
91
+ Is . EqualTo ( ConnectionReleaseModeParser . ToString ( ConnectionReleaseMode . AfterTransaction ) ) ) ;
92
+ Assert . That ( configure . Properties [ Environment . Isolation ] , Is . EqualTo ( "ReadCommitted" ) ) ;
93
+ Assert . That ( configure . Properties [ Environment . ConnectionString ] , Is . EqualTo ( "The connection string" ) ) ;
94
+ Assert . That ( configure . Properties [ Environment . UseSqlComments ] , Is . EqualTo ( "true" ) ) ;
95
+ Assert . That ( configure . Properties [ Environment . SqlExceptionConverter ] ,
96
+ Is . EqualTo ( typeof ( SQLStateConverter ) . AssemblyQualifiedName ) ) ;
97
+ Assert . That ( configure . Properties [ Environment . PrepareSql ] , Is . EqualTo ( "true" ) ) ;
98
+ Assert . That ( configure . Properties [ Environment . CommandTimeout ] , Is . EqualTo ( "10" ) ) ;
99
+ Assert . That ( configure . Properties [ Environment . MaxFetchDepth ] , Is . EqualTo ( "11" ) ) ;
100
+ Assert . That ( configure . Properties [ Environment . QuerySubstitutions ] , Is . EqualTo ( "true 1, false 0, yes 'Y', no 'N'" ) ) ;
101
+ Assert . That ( configure . Properties [ Environment . Hbm2ddlAuto ] , Is . EqualTo ( "validate" ) ) ;
102
+ }
103
+ }
104
+ }
0 commit comments