2
2
using System . Collections ;
3
3
using System . Data ;
4
4
using NHibernate . Dialect ;
5
+ using NHibernate . Driver ;
6
+ using NHibernate . Engine ;
5
7
using NHibernate . Exceptions ;
6
8
using NHibernate . Util ;
7
9
using NUnit . Framework ;
@@ -21,36 +23,51 @@ protected override IList Mappings
21
23
get { return new [ ] { "ExceptionsTest.User.hbm.xml" , "ExceptionsTest.Group.hbm.xml" } ; }
22
24
}
23
25
26
+ protected override bool AppliesTo ( Dialect . Dialect dialect )
27
+ {
28
+ return dialect is MsSql2000Dialect || dialect is PostgreSQLDialect || dialect is FirebirdDialect || dialect is Oracle8iDialect ;
29
+ }
30
+
31
+ protected override bool AppliesTo ( ISessionFactoryImplementor factory )
32
+ {
33
+ var driver = factory . ConnectionProvider . Driver ;
34
+ return ! ( driver is OracleDataClientDriver ) && ! ( driver is OracleManagedDataClientDriver ) && ! ( driver is OracleLiteDataClientDriver ) && ! ( driver is OdbcDriver ) && ! ( driver is OleDbDriver ) ;
35
+ }
36
+
24
37
protected override void Configure ( Cfg . Configuration configuration )
25
38
{
26
39
if ( Dialect is MsSql2000Dialect )
27
40
{
28
- configuration . SetProperty ( Cfg . Environment . SqlExceptionConverter ,
29
- typeof ( MSSQLExceptionConverterExample ) . AssemblyQualifiedName ) ;
41
+ configuration . SetProperty (
42
+ Cfg . Environment . SqlExceptionConverter ,
43
+ typeof ( MSSQLExceptionConverterExample ) . AssemblyQualifiedName ) ;
30
44
}
45
+
31
46
if ( Dialect is Oracle8iDialect )
32
47
{
33
- configuration . SetProperty ( Cfg . Environment . SqlExceptionConverter ,
34
- typeof ( OracleClientExceptionConverterExample ) . AssemblyQualifiedName ) ;
48
+ configuration . SetProperty (
49
+ Cfg . Environment . SqlExceptionConverter ,
50
+ typeof ( OracleClientExceptionConverterExample ) . AssemblyQualifiedName ) ;
35
51
}
36
52
37
53
if ( Dialect is PostgreSQLDialect )
38
54
{
39
- configuration . SetProperty ( Cfg . Environment . SqlExceptionConverter ,
40
- typeof ( PostgresExceptionConverterExample ) . AssemblyQualifiedName ) ;
55
+ configuration . SetProperty (
56
+ Cfg . Environment . SqlExceptionConverter ,
57
+ typeof ( PostgresExceptionConverterExample ) . AssemblyQualifiedName ) ;
41
58
}
42
59
43
60
if ( Dialect is FirebirdDialect )
44
61
{
45
- configuration . SetProperty ( Cfg . Environment . SqlExceptionConverter , typeof ( FbExceptionConverterExample ) . AssemblyQualifiedName ) ;
62
+ configuration . SetProperty (
63
+ Cfg . Environment . SqlExceptionConverter ,
64
+ typeof ( FbExceptionConverterExample ) . AssemblyQualifiedName ) ;
46
65
}
47
66
}
48
67
49
68
[ Test ]
50
69
public void IntegrityViolation ( )
51
70
{
52
- if ( Dialect is SQLiteDialect )
53
- Assert . Ignore ( "Example exception converter not implemented." ) ;
54
71
55
72
//ISQLExceptionConverter converter = Dialect.BuildSQLExceptionConverter();
56
73
ISQLExceptionConverter converter = sessions . Settings . SqlExceptionConverter ;
@@ -115,9 +132,6 @@ public void IntegrityViolation()
115
132
[ Test ]
116
133
public void BadGrammar ( )
117
134
{
118
- if ( Dialect is SQLiteDialect )
119
- Assert . Ignore ( "Example exception converter not implemented." ) ;
120
-
121
135
//ISQLExceptionConverter converter = Dialect.BuildSQLExceptionConverter();
122
136
ISQLExceptionConverter converter = sessions . Settings . SqlExceptionConverter ;
123
137
0 commit comments