Skip to content

Commit 4ed25d5

Browse files
author
richard.waspcroft@gmail.com
committed
RJB: Fixed a few of the SqlLite unit tests
1 parent 1394186 commit 4ed25d5

File tree

7 files changed

+40
-44
lines changed

7 files changed

+40
-44
lines changed

src/MyBatis.DataMapper.SqlClient.Test/Fixtures/Mapping/CacheTest.cs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -156,11 +156,11 @@ public void LRU_cache_should_work()
156156
[Test]
157157
public void TestJIRA104()
158158
{
159-
IList list = dataMapper.QueryForList("GetCachedAccountsViaResultMap", null);
159+
IList list = dataMapper.QueryForList("Account.GetCachedAccountsViaResultMap", null);
160160

161161
int firstId = HashCodeProvider.GetIdentityHashCode(list);
162162

163-
list = dataMapper.QueryForList("GetCachedAccountsViaResultMap", null);
163+
list = dataMapper.QueryForList("Account.GetCachedAccountsViaResultMap", null);
164164

165165
int secondId = HashCodeProvider.GetIdentityHashCode(list);
166166

@@ -173,11 +173,11 @@ public void TestJIRA104()
173173
[Test]
174174
public void TestQueryWithCache()
175175
{
176-
IList list = dataMapper.QueryForList("GetCachedAccountsViaResultMap", null);
176+
IList list = dataMapper.QueryForList("Account.GetCachedAccountsViaResultMap", null);
177177

178178
int firstId = HashCodeProvider.GetIdentityHashCode(list);
179179

180-
list = dataMapper.QueryForList("GetCachedAccountsViaResultMap", null);
180+
list = dataMapper.QueryForList("Account.GetCachedAccountsViaResultMap", null);
181181

182182
//Console.WriteLine(sqlMap.GetDataCacheStats());
183183

@@ -189,7 +189,7 @@ public void TestQueryWithCache()
189189
account.EmailAddress = "somebody@cache.com";
190190
dataMapper.Update("UpdateAccountViaInlineParameters", account);
191191

192-
list = dataMapper.QueryForList("GetCachedAccountsViaResultMap", null);
192+
list = dataMapper.QueryForList("Account.GetCachedAccountsViaResultMap", null);
193193

194194
int thirdId = HashCodeProvider.GetIdentityHashCode(list);
195195

@@ -205,19 +205,19 @@ public void TestQueryWithCache()
205205
[Test]
206206
public void TestFlushDataCache()
207207
{
208-
IList list = dataMapper.QueryForList("GetCachedAccountsViaResultMap", null);
208+
IList list = dataMapper.QueryForList("Account.GetCachedAccountsViaResultMap", null);
209209

210210
int firstId = HashCodeProvider.GetIdentityHashCode(list);
211211

212-
list = dataMapper.QueryForList("GetCachedAccountsViaResultMap", null);
212+
list = dataMapper.QueryForList("Account.GetCachedAccountsViaResultMap", null);
213213

214214
int secondId = HashCodeProvider.GetIdentityHashCode(list);
215215

216216
Assert.AreEqual(firstId, secondId);
217217

218218
((IModelStoreAccessor)dataMapper).ModelStore.FlushCaches();
219219

220-
list = dataMapper.QueryForList("GetCachedAccountsViaResultMap", null);
220+
list = dataMapper.QueryForList("Account.GetCachedAccountsViaResultMap", null);
221221

222222
int thirdId = HashCodeProvider.GetIdentityHashCode(list);
223223

@@ -227,15 +227,15 @@ public void TestFlushDataCache()
227227
[Test]
228228
public void TestFlushDataCacheOnExecute()
229229
{
230-
IList list = dataMapper.QueryForList("GetCachedAccountsViaResultMap", null);
230+
IList list = dataMapper.QueryForList("Account.GetCachedAccountsViaResultMap", null);
231231
int firstId = HashCodeProvider.GetIdentityHashCode(list);
232232

233-
list = dataMapper.QueryForList("GetCachedAccountsViaResultMap", null);
233+
list = dataMapper.QueryForList("Account.GetCachedAccountsViaResultMap", null);
234234
int secondId = HashCodeProvider.GetIdentityHashCode(list);
235235
Assert.AreEqual(firstId, secondId);
236236

237237
dataMapper.Update("UpdateAccountViaInlineParameters", list[0]);
238-
list = dataMapper.QueryForList("GetCachedAccountsViaResultMap", null);
238+
list = dataMapper.QueryForList("Account.GetCachedAccountsViaResultMap", null);
239239
int thirdId = HashCodeProvider.GetIdentityHashCode(list);
240240
Assert.AreNotEqual(firstId ,thirdId);
241241
}
@@ -248,10 +248,10 @@ public void TestMappedStatementQueryWithThreadedCache()
248248
{
249249
Hashtable results = new Hashtable();
250250

251-
TestCacheThread.StartThread(dataMapper, results, "GetCachedAccountsViaResultMap");
251+
TestCacheThread.StartThread(dataMapper, results, "Account.GetCachedAccountsViaResultMap");
252252
int firstId = (int) results["id"];
253253

254-
TestCacheThread.StartThread(dataMapper, results, "GetCachedAccountsViaResultMap");
254+
TestCacheThread.StartThread(dataMapper, results, "Account.GetCachedAccountsViaResultMap");
255255
int secondId = (int) results["id"];
256256

257257
Assert.AreEqual(firstId, secondId);
@@ -262,7 +262,7 @@ public void TestMappedStatementQueryWithThreadedCache()
262262
account.EmailAddress = "new.toto@somewhere.com";
263263
dataMapper.Update("UpdateAccountViaInlineParameters", account);
264264

265-
list = dataMapper.QueryForList("GetCachedAccountsViaResultMap", null);
265+
list = dataMapper.QueryForList("Account.GetCachedAccountsViaResultMap", null);
266266

267267
int thirdId = HashCodeProvider.GetIdentityHashCode(list);
268268

@@ -291,7 +291,7 @@ public void TestMappedStatementQueryWithThreadedReadWriteCache()
291291
account.EmailAddress = "new.toto@somewhere.com";
292292
dataMapper.Update("UpdateAccountViaInlineParameters", account);
293293

294-
list = dataMapper.QueryForList("GetCachedAccountsViaResultMap", null);
294+
list = dataMapper.QueryForList("Account.GetCachedAccountsViaResultMap", null);
295295

296296
int thirdId = HashCodeProvider.GetIdentityHashCode(list);
297297

src/MyBatis.DataMapper.SqlClient.Test/Fixtures/Mapping/StatementTest.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1277,10 +1277,10 @@ public void Cache_stats_should_only_be_calculated_on_CachingStatments()
12771277

12781278
// taken from TestFlushDataCache()
12791279
// first query is not cached, second query is: 50% cache hit
1280-
IList list = dataMapper.QueryForList("GetCachedAccountsViaResultMap", null);
1280+
IList list = dataMapper.QueryForList("Account.GetCachedAccountsViaResultMap", null);
12811281
int firstId = HashCodeProvider.GetIdentityHashCode(list);
12821282

1283-
list = dataMapper.QueryForList("GetCachedAccountsViaResultMap", null);
1283+
list = dataMapper.QueryForList("Account.GetCachedAccountsViaResultMap", null);
12841284
int secondId = HashCodeProvider.GetIdentityHashCode(list);
12851285

12861286
Assert.AreEqual(firstId, secondId);

src/MyBatis.DataMapper.SqlClient.Test/Maps/Account.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" >
324324
order by Account_LastName
325325
</select>
326326

327-
<select id="GetCachedAccountsViaResultMap"
327+
<select id="Account.GetCachedAccountsViaResultMap"
328328
resultMap="account-result"
329329
cacheModel="account-cache" >
330330
select *
@@ -342,7 +342,7 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" >
342342

343343
<select id="GetRWCachedAccountsViaResultMap"
344344
resultMap="account-result"
345-
cacheModel="rw-account-cache" extends="GetCachedAccountsViaResultMap">
345+
cacheModel="rw-account-cache" extends="Account.GetCachedAccountsViaResultMap">
346346
</select>
347347

348348
<select id="GetNoAccountWithCache"

src/MyBatis.DataMapper.Sqlite.Test/Fixtures/Mapping/CacheTest.cs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -156,11 +156,11 @@ public void LRU_cache_should_work()
156156
[Test]
157157
public void TestJIRA104()
158158
{
159-
IList list = dataMapper.QueryForList("GetCachedAccountsViaResultMap", null);
159+
IList list = dataMapper.QueryForList("Account.GetCachedAccountsViaResultMap", null);
160160

161161
int firstId = HashCodeProvider.GetIdentityHashCode(list);
162162

163-
list = dataMapper.QueryForList("GetCachedAccountsViaResultMap", null);
163+
list = dataMapper.QueryForList("Account.GetCachedAccountsViaResultMap", null);
164164

165165
int secondId = HashCodeProvider.GetIdentityHashCode(list);
166166

@@ -173,11 +173,11 @@ public void TestJIRA104()
173173
[Test]
174174
public void TestQueryWithCache()
175175
{
176-
IList list = dataMapper.QueryForList("GetCachedAccountsViaResultMap", null);
176+
IList list = dataMapper.QueryForList("Account.GetCachedAccountsViaResultMap", null);
177177

178178
int firstId = HashCodeProvider.GetIdentityHashCode(list);
179179

180-
list = dataMapper.QueryForList("GetCachedAccountsViaResultMap", null);
180+
list = dataMapper.QueryForList("Account.GetCachedAccountsViaResultMap", null);
181181

182182
//Console.WriteLine(sqlMap.GetDataCacheStats());
183183

@@ -189,7 +189,7 @@ public void TestQueryWithCache()
189189
account.EmailAddress = "somebody@cache.com";
190190
dataMapper.Update("UpdateAccountViaInlineParameters", account);
191191

192-
list = dataMapper.QueryForList("GetCachedAccountsViaResultMap", null);
192+
list = dataMapper.QueryForList("Account.GetCachedAccountsViaResultMap", null);
193193

194194
int thirdId = HashCodeProvider.GetIdentityHashCode(list);
195195

@@ -205,19 +205,19 @@ public void TestQueryWithCache()
205205
[Test]
206206
public void TestFlushDataCache()
207207
{
208-
IList list = dataMapper.QueryForList("GetCachedAccountsViaResultMap", null);
208+
IList list = dataMapper.QueryForList("Account.GetCachedAccountsViaResultMap", null);
209209

210210
int firstId = HashCodeProvider.GetIdentityHashCode(list);
211211

212-
list = dataMapper.QueryForList("GetCachedAccountsViaResultMap", null);
212+
list = dataMapper.QueryForList("Account.GetCachedAccountsViaResultMap", null);
213213

214214
int secondId = HashCodeProvider.GetIdentityHashCode(list);
215215

216216
Assert.AreEqual(firstId, secondId);
217217

218218
((IModelStoreAccessor)dataMapper).ModelStore.FlushCaches();
219219

220-
list = dataMapper.QueryForList("GetCachedAccountsViaResultMap", null);
220+
list = dataMapper.QueryForList("Account.GetCachedAccountsViaResultMap", null);
221221

222222
int thirdId = HashCodeProvider.GetIdentityHashCode(list);
223223

@@ -227,15 +227,15 @@ public void TestFlushDataCache()
227227
[Test]
228228
public void TestFlushDataCacheOnExecute()
229229
{
230-
IList list = dataMapper.QueryForList("GetCachedAccountsViaResultMap", null);
230+
IList list = dataMapper.QueryForList("Account.GetCachedAccountsViaResultMap", null);
231231
int firstId = HashCodeProvider.GetIdentityHashCode(list);
232232

233-
list = dataMapper.QueryForList("GetCachedAccountsViaResultMap", null);
233+
list = dataMapper.QueryForList("Account.GetCachedAccountsViaResultMap", null);
234234
int secondId = HashCodeProvider.GetIdentityHashCode(list);
235235
Assert.AreEqual(firstId, secondId);
236236

237237
dataMapper.Update("UpdateAccountViaInlineParameters", list[0]);
238-
list = dataMapper.QueryForList("GetCachedAccountsViaResultMap", null);
238+
list = dataMapper.QueryForList("Account.GetCachedAccountsViaResultMap", null);
239239
int thirdId = HashCodeProvider.GetIdentityHashCode(list);
240240
Assert.AreNotEqual(firstId ,thirdId);
241241
}
@@ -248,10 +248,10 @@ public void TestMappedStatementQueryWithThreadedCache()
248248
{
249249
Hashtable results = new Hashtable();
250250

251-
TestCacheThread.StartThread(dataMapper, results, "GetCachedAccountsViaResultMap");
251+
TestCacheThread.StartThread(dataMapper, results, "Account.GetCachedAccountsViaResultMap");
252252
int firstId = (int) results["id"];
253253

254-
TestCacheThread.StartThread(dataMapper, results, "GetCachedAccountsViaResultMap");
254+
TestCacheThread.StartThread(dataMapper, results, "Account.GetCachedAccountsViaResultMap");
255255
int secondId = (int) results["id"];
256256

257257
Assert.AreEqual(firstId, secondId);
@@ -262,7 +262,7 @@ public void TestMappedStatementQueryWithThreadedCache()
262262
account.EmailAddress = "new.toto@somewhere.com";
263263
dataMapper.Update("UpdateAccountViaInlineParameters", account);
264264

265-
list = dataMapper.QueryForList("GetCachedAccountsViaResultMap", null);
265+
list = dataMapper.QueryForList("Account.GetCachedAccountsViaResultMap", null);
266266

267267
int thirdId = HashCodeProvider.GetIdentityHashCode(list);
268268

@@ -291,7 +291,7 @@ public void TestMappedStatementQueryWithThreadedReadWriteCache()
291291
account.EmailAddress = "new.toto@somewhere.com";
292292
dataMapper.Update("UpdateAccountViaInlineParameters", account);
293293

294-
list = dataMapper.QueryForList("GetCachedAccountsViaResultMap", null);
294+
list = dataMapper.QueryForList("Account.GetCachedAccountsViaResultMap", null);
295295

296296
int thirdId = HashCodeProvider.GetIdentityHashCode(list);
297297

src/MyBatis.DataMapper.Sqlite.Test/Maps/Account.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" >
324324
order by Account_LastName
325325
</select>
326326

327-
<select id="GetCachedAccountsViaResultMap"
327+
<select id="Account.GetCachedAccountsViaResultMap"
328328
resultMap="account-result"
329329
cacheModel="account-cache" >
330330
select *
@@ -342,7 +342,7 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" >
342342

343343
<select id="GetRWCachedAccountsViaResultMap"
344344
resultMap="account-result"
345-
cacheModel="rw-account-cache" extends="GetCachedAccountsViaResultMap">
345+
cacheModel="rw-account-cache" extends="Account.GetCachedAccountsViaResultMap">
346346
</select>
347347

348348
<select id="GetNoAccountWithCache"

src/MyBatis.DataMapper.Sqlite.Test/Maps/ComplexBindNestedIterate.xml

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515

1616
<select id="FilterPeople" parameterClass="Filter" resultClass="data">
1717
<include refid="select-person-custom-field" />
18-
<include refid="join" />
18+
<include refid="from-person" />
19+
<include refid="where-person-custom-field" />
1920
</select>
2021

2122
<sql id="select-person-custom-field">
@@ -29,11 +30,6 @@
2930
</dynamic>
3031
</sql>
3132

32-
<sql id="join">
33-
<include refid="from-person" />
34-
<include refid="where-person-custom-field" />
35-
</sql>
36-
3733
<sql id="from-person">
3834
<![CDATA[
3935
FROM PERSON CP

src/MyBatis.DataMapper.Sqlite.Test/Maps/Mapping1.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@
238238
order by Account_LastName
239239
</select>
240240

241-
<select id="GetCachedAccountsViaResultMap"
241+
<select id="Account.GetCachedAccountsViaResultMap"
242242
resultMap="account-result"
243243
cacheModel="account-cache" >
244244
select *
@@ -248,7 +248,7 @@
248248

249249
<select id="GetRWCachedAccountsViaResultMap"
250250
resultMap="account-result"
251-
cacheModel="rw-account-cache" extends="GetCachedAccountsViaResultMap">
251+
cacheModel="rw-account-cache" extends="Account.GetCachedAccountsViaResultMap">
252252
where 1=1
253253
</select>
254254

0 commit comments

Comments
 (0)