1
+ using FluentNHibernate . Cfg . Db ;
2
+ using NHibernate . Dialect ;
3
+ using NHibernate . Driver ;
4
+ using NUnit . Framework ;
5
+
6
+
7
+ namespace FluentNHibernate . Testing . Cfg . Db
8
+ {
9
+ [ TestFixture ]
10
+ public class OracleManagedDataClientConfigurationTester
11
+ {
12
+ [ Test ]
13
+ public void Oracle9_should_default_to_the_Oracle9_dialect ( )
14
+ {
15
+ OracleManagedDataClientConfiguration . Oracle9
16
+ . ToProperties ( )
17
+ . ShouldContain ( "connection.driver_class" , typeof ( OracleManagedDataClientDriver ) . AssemblyQualifiedName )
18
+ . ShouldContain ( "dialect" , typeof ( Oracle9iDialect ) . AssemblyQualifiedName ) ;
19
+ }
20
+
21
+
22
+ [ Test ]
23
+ public void Oracle10_should_default_to_the_Oracle10_dialect ( )
24
+ {
25
+ OracleManagedDataClientConfiguration . Oracle10
26
+ . ToProperties ( )
27
+ . ShouldContain ( "connection.driver_class" , typeof ( OracleManagedDataClientDriver ) . AssemblyQualifiedName )
28
+ . ShouldContain ( "dialect" , typeof ( Oracle10gDialect ) . AssemblyQualifiedName ) ;
29
+ }
30
+
31
+ [ Test ]
32
+ public void ConnectionString_is_added_to_the_configuration ( )
33
+ {
34
+ OracleManagedDataClientConfiguration . Oracle9
35
+ . ConnectionString ( c => c
36
+ . Server ( "db-srv" )
37
+ . Instance ( "mydatabase" )
38
+ . Username ( "test" )
39
+ . Password ( "secret" )
40
+ . StatementCacheSize ( 50 ) )
41
+ . ToProperties ( ) . ShouldContain ( "connection.connection_string" ,
42
+ "User Id=test;Password=secret;Pooling=False;Statement Cache Size=50;Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=db-srv)(PORT=1521)))(CONNECT_DATA=(SERVICE_NAME=mydatabase)))" ) ;
43
+ }
44
+
45
+
46
+ [ Test ]
47
+ public void ConnectionString_leaving_out_the_StatementCacheSize_removes_from_string ( )
48
+ {
49
+ OracleClientConfiguration . Oracle9
50
+ . ConnectionString ( c => c
51
+ . Server ( "db-srv" )
52
+ . Instance ( "mydatabase" )
53
+ . Username ( "test" )
54
+ . Password ( "secret" ) )
55
+ . ToProperties ( ) . ShouldContain ( "connection.connection_string" ,
56
+ "User Id=test;Password=secret;Pooling=False;Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=db-srv)(PORT=1521)))(CONNECT_DATA=(SERVICE_NAME=mydatabase)))" ) ;
57
+ }
58
+
59
+ [ Test ]
60
+ public void ConnectionString_pooling_defaults_to_false_when_not_set ( )
61
+ {
62
+ OracleClientConfiguration . Oracle9
63
+ . ConnectionString ( c => c
64
+ . Server ( "db-srv" )
65
+ . Instance ( "mydatabase" )
66
+ . Username ( "test" )
67
+ . Password ( "secret" )
68
+ . Pooling ( true )
69
+ . StatementCacheSize ( 50 ) )
70
+ . ToProperties ( ) . ShouldContain ( "connection.connection_string" ,
71
+ "User Id=test;Password=secret;Pooling=True;Statement Cache Size=50;Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=db-srv)(PORT=1521)))(CONNECT_DATA=(SERVICE_NAME=mydatabase)))" ) ;
72
+ }
73
+
74
+
75
+ [ Test ]
76
+ public void ConnectionString_pooling_is_enabled_when_set ( )
77
+ {
78
+ OracleManagedDataClientConfiguration . Oracle9
79
+ . ConnectionString ( c => c
80
+ . Server ( "db-srv" )
81
+ . Instance ( "mydatabase" )
82
+ . Username ( "test" )
83
+ . Password ( "secret" )
84
+ . Pooling ( true )
85
+ . StatementCacheSize ( 50 ) )
86
+ . ToProperties ( ) . ShouldContain ( "connection.connection_string" ,
87
+ "User Id=test;Password=secret;Pooling=True;Statement Cache Size=50;Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=db-srv)(PORT=1521)))(CONNECT_DATA=(SERVICE_NAME=mydatabase)))" ) ;
88
+ }
89
+ [ Test ]
90
+ public void ConnectionString_other_options_are_enabled_and_parsed_when_set ( )
91
+ {
92
+ OracleManagedDataClientConfiguration . Oracle9
93
+ . ConnectionString ( c => c
94
+ . Server ( "db-srv" )
95
+ . Instance ( "mydatabase" )
96
+ . Username ( "test" )
97
+ . Password ( "secret" )
98
+ . OtherOptions ( "Min Pool Size=10;Incr Pool Size=5;Decr Pool Size=2" )
99
+ . StatementCacheSize ( 50 ) )
100
+ . ToProperties ( ) . ShouldContain ( "connection.connection_string" ,
101
+ "User Id=test;Password=secret;Pooling=False;Statement Cache Size=50;Min Pool Size=10;Incr Pool Size=5;Decr Pool Size=2;Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=db-srv)(PORT=1521)))(CONNECT_DATA=(SERVICE_NAME=mydatabase)))" ) ;
102
+ }
103
+
104
+ [ Test ]
105
+ public void ConnectionString_set_explicitly ( )
106
+ {
107
+ OracleManagedDataClientConfiguration . Oracle9
108
+ . ConnectionString ( c => c
109
+ . Is ( "value" ) )
110
+ . ToProperties ( ) . ShouldContain ( "connection.connection_string" , "value" ) ;
111
+ }
112
+
113
+ [ Test ]
114
+ public void ConnectionString_set_fromAppSetting ( )
115
+ {
116
+ OracleManagedDataClientConfiguration . Oracle9
117
+ . ConnectionString ( c => c
118
+ . FromAppSetting ( "connectionString" ) )
119
+ . ToProperties ( ) . ShouldContain ( "connection.connection_string" , "a-connection-string" ) ;
120
+ }
121
+
122
+ [ Test ]
123
+ public void ConnectionString_set_fromConnectionStrings ( )
124
+ {
125
+ OracleManagedDataClientConfiguration . Oracle9
126
+ . ConnectionString ( c => c
127
+ . FromConnectionStringWithKey ( "main" ) )
128
+ . ToProperties ( ) . ShouldContain ( "connection.connection_string" , "connection string" ) ;
129
+ }
130
+
131
+ [ Test ]
132
+ public void ShouldBeAbleToSpecifyConnectionStringDirectly ( )
133
+ {
134
+ OracleManagedDataClientConfiguration . Oracle9
135
+ . ConnectionString ( "conn" )
136
+ . ToProperties ( ) . ShouldContain ( "connection.connection_string" , "conn" ) ;
137
+ }
138
+ }
139
+ }
0 commit comments