@@ -4,14 +4,16 @@ namespace Simple.Data
44
55 internal class DatabaseOpenerMethods
66 {
7- private Func < Database > _openDefault ;
7+ private Func < string , Database > _openDefault ;
88 private Func < string , Database > _openFile ;
99 private Func < string , Database > _openConnection ;
1010 private Func < string , string , Database > _openConnectionWithProvider ;
11+ private Func < string , string , string , Database > _openConnectionWithProviderAndSchema ;
1112 private Func < string , Database > _openNamedConnection ;
13+ private Func < string , string , Database > _openNamedConnectionAndSchema ;
1214 private Func < string , object , Database > _open ;
1315
14- public Func < Database > OpenDefaultImpl
16+ public Func < string , Database > OpenDefaultImpl
1517 {
1618 get { return _openDefault ?? DatabaseOpener . OpenDefaultMethod ; }
1719 }
@@ -31,54 +33,64 @@ public Func<string, string, Database> OpenConnectionWithProviderImpl
3133 get { return _openConnectionWithProvider ?? DatabaseOpener . OpenConnectionMethod ; }
3234 }
3335
36+ public Func < string , string , string , Database > OpenConnectionWithProviderAndSchemaImpl
37+ {
38+ get { return _openConnectionWithProviderAndSchema ?? DatabaseOpener . OpenConnectionAndSchemaMethod ; }
39+ }
40+
3441 public Func < string , Database > OpenNamedConnectionImpl
3542 {
3643 get { return _openNamedConnection ?? DatabaseOpener . OpenNamedConnectionMethod ; }
3744 }
3845
46+ public Func < string , string , Database > OpenNamedConnectionAndSchemaImpl
47+ {
48+ get { return _openNamedConnectionAndSchema ?? DatabaseOpener . OpenNamedConnectionAndSchemaMethod ; }
49+ }
50+
3951 public Func < string , object , Database > OpenImpl
4052 {
4153 get { return _open ?? DatabaseOpener . OpenMethod ; }
4254 }
4355
4456 public void UseMockDatabase ( Database database )
4557 {
46- _openDefault = ( ) => database ;
47- _openFile = _openConnection = _openNamedConnection = ignore => database ;
58+ _openDefault = _openFile = _openConnection = _openNamedConnection = ignore => database ;
4859 _open = ( ignore1 , ignore2 ) => database ;
49- _openConnectionWithProvider = ( ignore1 , ignore2 ) => database ;
60+ _openNamedConnectionAndSchema = _openConnectionWithProvider = ( ignore1 , ignore2 ) => database ;
61+ _openConnectionWithProviderAndSchema = ( ignore1 , ignore2 , ignore3 ) => database ;
5062 }
5163
5264 public void UseMockAdapter ( Adapter adapter )
5365 {
54- _openDefault = ( ) => new Database ( adapter ) ;
55- _openFile = _openConnection = _openNamedConnection = ignore => new Database ( adapter ) ;
66+ _openDefault = _openFile = _openConnection = _openNamedConnection = ignore => new Database ( adapter ) ;
5667 _open = ( ignore1 , ignore2 ) => new Database ( adapter ) ;
57- _openConnectionWithProvider = ( ignore1 , ignore2 ) => new Database ( adapter ) ;
68+ _openNamedConnectionAndSchema = _openConnectionWithProvider = ( ignore1 , ignore2 ) => new Database ( adapter ) ;
69+ _openConnectionWithProviderAndSchema = ( ignore1 , ignore2 , ignore3 ) => new Database ( adapter ) ;
5870 }
5971
6072 public void UseMockDatabase ( Func < Database > databaseCreator )
6173 {
62- _openDefault = databaseCreator ;
63- _openFile = _openConnection = _openNamedConnection = ignore => databaseCreator ( ) ;
74+ _openDefault = _openFile = _openConnection = _openNamedConnection = ignore => databaseCreator ( ) ;
6475 _open = ( ignore1 , ignore2 ) => databaseCreator ( ) ;
65- _openConnectionWithProvider = ( ignore1 , ignore2 ) => databaseCreator ( ) ;
76+ _openNamedConnectionAndSchema = _openConnectionWithProvider = ( ignore1 , ignore2 ) => databaseCreator ( ) ;
77+ _openConnectionWithProviderAndSchema = ( ignore1 , ignore2 , ignore3 ) => databaseCreator ( ) ;
6678 }
6779
6880 public void UseMockAdapter ( Func < Adapter > adapterCreator )
6981 {
70- _openDefault = ( ) => new Database ( adapterCreator ( ) ) ;
71- _openFile = _openConnection = _openNamedConnection = ignore => new Database ( adapterCreator ( ) ) ;
82+ _openDefault = _openFile = _openConnection = _openNamedConnection = ignore => new Database ( adapterCreator ( ) ) ;
7283 _open = ( ignore1 , ignore2 ) => new Database ( adapterCreator ( ) ) ;
73- _openConnectionWithProvider = ( ignore1 , ignore2 ) => new Database ( adapterCreator ( ) ) ;
84+ _openNamedConnectionAndSchema = _openConnectionWithProvider = ( ignore1 , ignore2 ) => new Database ( adapterCreator ( ) ) ;
85+ _openConnectionWithProviderAndSchema = ( ignore1 , ignore2 , ignore3 ) => new Database ( adapterCreator ( ) ) ;
7486 }
7587
7688 public void StopUsingMock ( )
7789 {
78- _openDefault = null ;
79- _openFile = _openConnection = _openNamedConnection = null ;
90+ _openDefault = _openFile = _openConnection = _openNamedConnection = null ;
8091 _open = null ;
81- _openConnectionWithProvider = null ;
92+ _openNamedConnectionAndSchema = _openConnectionWithProvider = null ;
93+ _openConnectionWithProviderAndSchema = null ;
8294 }
8395 }
8496}
0 commit comments