10
10
using NHibernate . Exceptions ;
11
11
using NHibernate . Hql . Classic ;
12
12
using NHibernate . Type ;
13
+ using NUnit . Framework ;
13
14
14
15
namespace NHibernate . Test . CfgTest . Loquacious
15
16
{
17
+ [ TestFixture ]
16
18
public class ConfigurationFixture
17
19
{
18
- public void ProofOfConcept ( )
20
+ [ Test ]
21
+ public void CompleteConfiguration ( )
19
22
{
20
23
// Here I'm configuring near all properties outside the scope of Configuration class
21
24
// Using the Configuration class the user can add mappings and configure listeners
@@ -42,27 +45,67 @@ public void ProofOfConcept()
42
45
. AutoQuoteKeywords ( )
43
46
. BatchingQueries
44
47
. Through < SqlClientBatchingBatcherFactory > ( )
45
- . Each ( 10 )
48
+ . Each ( 15 )
46
49
. Connected
47
50
. Through < DebugConnectionProvider > ( )
48
51
. By < SqlClientDriver > ( )
49
52
. Releasing ( ConnectionReleaseMode . AfterTransaction )
50
53
. With ( IsolationLevel . ReadCommitted )
51
- . Using ( "The connection string but it has some overload " )
54
+ . Using ( "The connection string" )
52
55
. CreateCommands
53
56
. AutoCommentingSql ( )
54
57
. ConvertingExceptionsThrough < SQLStateConverter > ( )
55
58
. Preparing ( )
56
59
. WithTimeout ( 10 )
57
- . WithMaximumDepthOfOuterJoinFetching ( 10 )
60
+ . WithMaximumDepthOfOuterJoinFetching ( 11 )
58
61
. WithHqlToSqlSubstitutions ( "true 1, false 0, yes 'Y', no 'N'" )
59
62
. Schema
60
63
. Validating ( )
61
64
;
62
65
66
+ Assert . That ( cfg . Properties [ Environment . SessionFactoryName ] , Is . EqualTo ( "SomeName" ) ) ;
67
+ Assert . That ( cfg . Properties [ Environment . CacheProvider ] ,
68
+ Is . EqualTo ( typeof ( HashtableCacheProvider ) . AssemblyQualifiedName ) ) ;
69
+ Assert . That ( cfg . Properties [ Environment . CacheRegionPrefix ] , Is . EqualTo ( "xyz" ) ) ;
70
+ Assert . That ( cfg . Properties [ Environment . QueryCacheFactory ] ,
71
+ Is . EqualTo ( typeof ( StandardQueryCache ) . AssemblyQualifiedName ) ) ;
72
+ Assert . That ( cfg . Properties [ Environment . UseMinimalPuts ] , Is . EqualTo ( "true" ) ) ;
73
+ Assert . That ( cfg . Properties [ Environment . CacheDefaultExpiration ] , Is . EqualTo ( "15" ) ) ;
74
+ Assert . That ( cfg . Properties [ Environment . CollectionTypeFactoryClass ] ,
75
+ Is . EqualTo ( typeof ( DefaultCollectionTypeFactory ) . AssemblyQualifiedName ) ) ;
76
+ Assert . That ( cfg . Properties [ Environment . UseProxyValidator ] , Is . EqualTo ( "false" ) ) ;
77
+ Assert . That ( cfg . Properties [ Environment . ProxyFactoryFactoryClass ] ,
78
+ Is . EqualTo ( typeof ( ProxyFactoryFactory ) . AssemblyQualifiedName ) ) ;
79
+ Assert . That ( cfg . Properties [ Environment . QueryTranslator ] ,
80
+ Is . EqualTo ( typeof ( ClassicQueryTranslatorFactory ) . AssemblyQualifiedName ) ) ;
81
+ Assert . That ( cfg . Properties [ Environment . DefaultCatalog ] , Is . EqualTo ( "MyCatalog" ) ) ;
82
+ Assert . That ( cfg . Properties [ Environment . DefaultSchema ] , Is . EqualTo ( "MySche" ) ) ;
83
+ Assert . That ( cfg . Properties [ Environment . Dialect ] ,
84
+ Is . EqualTo ( typeof ( MsSql2000Dialect ) . AssemblyQualifiedName ) ) ;
85
+ Assert . That ( cfg . Properties [ Environment . Hbm2ddlKeyWords ] , Is . EqualTo ( "auto-quote" ) ) ;
86
+ Assert . That ( cfg . Properties [ Environment . BatchStrategy ] ,
87
+ Is . EqualTo ( typeof ( SqlClientBatchingBatcherFactory ) . AssemblyQualifiedName ) ) ;
88
+ Assert . That ( cfg . Properties [ Environment . BatchSize ] , Is . EqualTo ( "15" ) ) ;
89
+ Assert . That ( cfg . Properties [ Environment . ConnectionProvider ] ,
90
+ Is . EqualTo ( typeof ( DebugConnectionProvider ) . AssemblyQualifiedName ) ) ;
91
+ Assert . That ( cfg . Properties [ Environment . ConnectionDriver ] ,
92
+ Is . EqualTo ( typeof ( SqlClientDriver ) . AssemblyQualifiedName ) ) ;
93
+ Assert . That ( cfg . Properties [ Environment . ReleaseConnections ] ,
94
+ Is . EqualTo ( ConnectionReleaseModeParser . ToString ( ConnectionReleaseMode . AfterTransaction ) ) ) ;
95
+ Assert . That ( cfg . Properties [ Environment . Isolation ] , Is . EqualTo ( "ReadCommitted" ) ) ;
96
+ Assert . That ( cfg . Properties [ Environment . ConnectionString ] , Is . EqualTo ( "The connection string" ) ) ;
97
+ Assert . That ( cfg . Properties [ Environment . UseSqlComments ] , Is . EqualTo ( "true" ) ) ;
98
+ Assert . That ( cfg . Properties [ Environment . SqlExceptionConverter ] ,
99
+ Is . EqualTo ( typeof ( SQLStateConverter ) . AssemblyQualifiedName ) ) ;
100
+ Assert . That ( cfg . Properties [ Environment . PrepareSql ] , Is . EqualTo ( "true" ) ) ;
101
+ Assert . That ( cfg . Properties [ Environment . CommandTimeout ] , Is . EqualTo ( "10" ) ) ;
102
+ Assert . That ( cfg . Properties [ Environment . MaxFetchDepth ] , Is . EqualTo ( "11" ) ) ;
103
+ Assert . That ( cfg . Properties [ Environment . QuerySubstitutions ] , Is . EqualTo ( "true 1, false 0, yes 'Y', no 'N'" ) ) ;
104
+ Assert . That ( cfg . Properties [ Environment . Hbm2ddlAuto ] , Is . EqualTo ( "validate" ) ) ;
63
105
}
64
106
65
- public void ProofOfConceptMinimalConfiguration ( )
107
+ [ Test ]
108
+ public void UseDbConfigurationStringBuilder ( )
66
109
{
67
110
// This is a possible minimal configuration
68
111
// in this case we must define best default properties for each dialect
@@ -79,6 +122,13 @@ public void ProofOfConceptMinimalConfiguration()
79
122
InitialCatalog = "nhibernate" ,
80
123
IntegratedSecurity = true
81
124
} ) ;
125
+
126
+ Assert . That ( cfg . Properties [ Environment . ProxyFactoryFactoryClass ] ,
127
+ Is . EqualTo ( typeof ( ProxyFactoryFactory ) . AssemblyQualifiedName ) ) ;
128
+ Assert . That ( cfg . Properties [ Environment . Dialect ] ,
129
+ Is . EqualTo ( typeof ( MsSql2005Dialect ) . AssemblyQualifiedName ) ) ;
130
+ Assert . That ( cfg . Properties [ Environment . ConnectionString ] ,
131
+ Is . EqualTo ( "Data Source=(local);Initial Catalog=nhibernate;Integrated Security=True" ) ) ;
82
132
}
83
133
}
84
134
}
0 commit comments