1 /* OLEDB Database tests
3 * Copyright 2012 Alistair Leslie-Hughes
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
22 #define NONAMELESSUNION
23 #define NONAMELESSSTRUCT
33 #include "wine/test.h"
35 DEFINE_GUID(CSLID_MSDAER
, 0xc8b522cf,0x5cf3,0x11ce,0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d);
37 static WCHAR initstring_default
[] = {'D','a','t','a',' ','S','o','u','r','c','e','=','d','u','m','m','y',';',0};
39 static void test_GetDataSource(WCHAR
*initstring
)
41 IDataInitialize
*datainit
= NULL
;
42 IDBInitialize
*dbinit
= NULL
;
45 trace("Data Source: %s\n", wine_dbgstr_w(initstring
));
47 hr
= CoCreateInstance(&CLSID_MSDAINITIALIZE
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IDataInitialize
,(void**)&datainit
);
48 ok(hr
== S_OK
, "got %08x\n", hr
);
50 /* a failure to create data source here may indicate provider is simply not present */
51 hr
= IDataInitialize_GetDataSource(datainit
, NULL
, CLSCTX_INPROC_SERVER
, initstring
, &IID_IDBInitialize
, (IUnknown
**)&dbinit
);
54 IDBProperties
*props
= NULL
;
57 hr
= SHGetMalloc(&ppM
);
60 ok(0, "Couldn't get IMalloc object.\n");
64 hr
= IDBInitialize_QueryInterface(dbinit
, &IID_IDBProperties
, (void**)&props
);
65 ok(hr
== S_OK
, "got %08x\n", hr
);
69 DBPROPINFOSET
*pInfoset
;
72 hr
= IDBProperties_GetPropertyInfo(props
, 0, NULL
, &cnt
, &pInfoset
, &ary
);
73 todo_wine
ok(hr
== S_OK
, "got %08x\n", hr
);
77 for(i
=0; i
< pInfoset
->cPropertyInfos
; i
++)
79 trace("(0x%04x) '%s' %d\n", pInfoset
->rgPropertyInfos
[i
].dwPropertyID
, wine_dbgstr_w(pInfoset
->rgPropertyInfos
[i
].pwszDescription
),
80 pInfoset
->rgPropertyInfos
[i
].vtType
);
83 IMalloc_Free(ppM
, ary
);
86 IDBProperties_Release(props
);
92 IDBInitialize_Release(dbinit
);
95 IDataInitialize_Release(datainit
);
98 static void test_database(void)
100 static WCHAR initstring_jet
[] = {'P','r','o','v','i','d','e','r','=','M','i','c','r','o','s','o','f','t','.',
101 'J','e','t','.','O','L','E','D','B','.','4','.','0',';',
102 'D','a','t','a',' ','S','o','u','r','c','e','=','d','u','m','m','y',';',
103 'P','e','r','s','i','s','t',' ','S','e','c','u','r','i','t','y',' ','I','n','f','o','=','F','a','l','s','e',';',0};
104 static WCHAR initstring_lower
[] = {'d','a','t','a',' ','s','o','u','r','c','e','=','d','u','m','m','y',';',0};
105 IDataInitialize
*datainit
= NULL
;
108 hr
= CoCreateInstance(&CLSID_MSDAINITIALIZE
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IDataInitialize
, (void**)&datainit
);
111 win_skip("Unable to load oledb library\n");
114 IDataInitialize_Release(datainit
);
116 test_GetDataSource(NULL
);
117 test_GetDataSource(initstring_jet
);
118 test_GetDataSource(initstring_default
);
119 test_GetDataSource(initstring_lower
);
122 static void test_errorinfo(void)
125 IUnknown
*unk
= NULL
;
127 hr
= CoCreateInstance(&CSLID_MSDAER
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IUnknown
,(void**)&unk
);
128 todo_wine
ok(hr
== S_OK
, "got %08x\n", hr
);
131 IErrorInfo
*errorinfo
;
133 hr
= IUnknown_QueryInterface(unk
, &IID_IErrorInfo
, (void**)&errorinfo
);
134 ok(hr
== S_OK
, "got %08x\n", hr
);
137 IErrorInfo_Release(errorinfo
);
140 IUnknown_Release(unk
);
144 static void test_initializationstring(void)
146 static WCHAR initstring_msdasql
[] = {'P','r','o','v','i','d','e','r','=','M','S','D','A','S','Q','L','.','1',';',
147 'D','a','t','a',' ','S','o','u','r','c','e','=','d','u','m','m','y', 0};
148 static WCHAR initstring_sqloledb
[] = {'P','r','o','v','i','d','e','r','=','S','Q','L','O','L','E','D','B','.','1',';',
149 'D','a','t','a',' ','S','o','u','r','c','e','=','d','u','m','m','y', 0};
150 IDataInitialize
*datainit
= NULL
;
151 IDBInitialize
*dbinit
= NULL
;
153 WCHAR
*initstring
= NULL
;
155 hr
= CoCreateInstance(&CLSID_MSDAINITIALIZE
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IDataInitialize
,(void**)&datainit
);
156 ok(hr
== S_OK
, "got %08x\n", hr
);
159 hr
= IDataInitialize_GetDataSource(datainit
, NULL
, CLSCTX_INPROC_SERVER
, initstring_default
,
160 &IID_IDBInitialize
, (IUnknown
**)&dbinit
);
163 hr
= IDataInitialize_GetInitializationString(datainit
, (IUnknown
*)dbinit
, 0, &initstring
);
164 ok(hr
== S_OK
, "got %08x\n", hr
);
167 trace("Init String: %s\n", wine_dbgstr_w(initstring
));
168 todo_wine
ok(!lstrcmpW(initstring_msdasql
, initstring
) ||
169 !lstrcmpW(initstring_sqloledb
, initstring
), "got %s\n", wine_dbgstr_w(initstring
));
170 CoTaskMemFree(initstring
);
173 IDBInitialize_Release(dbinit
);
176 IDataInitialize_Release(datainit
);
186 test_initializationstring();