Skip to content

Commit dd26efa

Browse files
committed
fixup! Failing test
1 parent beff969 commit dd26efa

File tree

2 files changed

+26
-8
lines changed

2 files changed

+26
-8
lines changed

src/NHibernate.Test/Async/Linq/ConstantTest.cs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,7 @@ public async Task PlansAreCachedAsync()
237237
}
238238
}
239239

240+
[KnownBug("GH-2222")]
240241
[Test]
241242
public async Task DmlPlansAreCachedAsync()
242243
{
@@ -252,9 +253,10 @@ public async Task DmlPlansAreCachedAsync()
252253
{
253254
await (db.Customers.Where(c => c.CustomerId == "UNKNOWN").UpdateAsync(x => new Customer {CompanyName = "Constant1"}));
254255
await (db.Customers.Where(c => c.CustomerId == "ALFKI").UpdateAsync(x => new Customer {CompanyName = x.CompanyName}));
256+
await (db.Customers.Where(c => c.CustomerId == "UNKNOWN").UpdateAsync(x => new Customer {ContactName = "Constant1"}));
255257
Assert.That(
256258
cache,
257-
Has.Count.EqualTo(2),
259+
Has.Count.EqualTo(3),
258260
"Query plans should be cached.");
259261

260262
using (var spy = new LogSpy(queryPlanCacheType))
@@ -264,6 +266,7 @@ public async Task DmlPlansAreCachedAsync()
264266
{
265267
await (db.Customers.Where(c => c.CustomerId == "ANATR").UpdateAsync(x => new Customer {CompanyName = x.CompanyName}));
266268
await (db.Customers.Where(c => c.CustomerId == "UNKNOWN").UpdateAsync(x => new Customer {CompanyName = "Constant2"}));
269+
await (db.Customers.Where(c => c.CustomerId == "UNKNOWN").UpdateAsync(x => new Customer {ContactName = "Constant2"}));
267270

268271
var sqlEvents = sqlSpy.Appender.GetEvents();
269272
Assert.That(
@@ -272,19 +275,25 @@ public async Task DmlPlansAreCachedAsync()
272275
"Unexpected constant parameter value");
273276
Assert.That(
274277
sqlEvents[1].RenderedMessage,
275-
Does.Contain("UNKNOWN").And.Contain("Constant2").And.Not.Contain("Constant1"),
278+
Does.Contain("UNKNOWN").And.Contain("Constant2").And.Contain("CompanyName").IgnoreCase
279+
.And.Not.Contain("Constant1"),
280+
"Unexpected constant parameter value");
281+
Assert.That(
282+
sqlEvents[1].RenderedMessage,
283+
Does.Contain("UNKNOWN").And.Contain("Constant2").And.Contain("ContactName").IgnoreCase
284+
.And.Not.Contain("Constant1"),
276285
"Unexpected constant parameter value");
277286
}
278287

279-
Assert.That(cache, Has.Count.EqualTo(2), "Additional queries should not cause a plan to be cached.");
288+
Assert.That(cache, Has.Count.EqualTo(3), "Additional queries should not cause a plan to be cached.");
280289
Assert.That(
281290
spy.GetWholeLog(),
282291
Does
283292
.Contain("located HQL query plan in cache")
284293
.And.Not.Contain("unable to locate HQL query plan in cache"));
285294

286295
await (db.Customers.Where(c => c.CustomerId == "ANATR").UpdateAsync(x => new Customer {ContactName = x.ContactName}));
287-
Assert.That(cache, Has.Count.EqualTo(3), "Query should be cached");
296+
Assert.That(cache, Has.Count.EqualTo(4), "Query should be cached");
288297
}
289298
}
290299
}

src/NHibernate.Test/Linq/ConstantTest.cs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,7 @@ public void PlansAreCached()
258258
}
259259
}
260260

261+
[KnownBug("GH-2222")]
261262
[Test]
262263
public void DmlPlansAreCached()
263264
{
@@ -273,9 +274,10 @@ public void DmlPlansAreCached()
273274
{
274275
db.Customers.Where(c => c.CustomerId == "UNKNOWN").Update(x => new Customer {CompanyName = "Constant1"});
275276
db.Customers.Where(c => c.CustomerId == "ALFKI").Update(x => new Customer {CompanyName = x.CompanyName});
277+
db.Customers.Where(c => c.CustomerId == "UNKNOWN").Update(x => new Customer {ContactName = "Constant1"});
276278
Assert.That(
277279
cache,
278-
Has.Count.EqualTo(2),
280+
Has.Count.EqualTo(3),
279281
"Query plans should be cached.");
280282

281283
using (var spy = new LogSpy(queryPlanCacheType))
@@ -285,6 +287,7 @@ public void DmlPlansAreCached()
285287
{
286288
db.Customers.Where(c => c.CustomerId == "ANATR").Update(x => new Customer {CompanyName = x.CompanyName});
287289
db.Customers.Where(c => c.CustomerId == "UNKNOWN").Update(x => new Customer {CompanyName = "Constant2"});
290+
db.Customers.Where(c => c.CustomerId == "UNKNOWN").Update(x => new Customer {ContactName = "Constant2"});
288291

289292
var sqlEvents = sqlSpy.Appender.GetEvents();
290293
Assert.That(
@@ -293,19 +296,25 @@ public void DmlPlansAreCached()
293296
"Unexpected constant parameter value");
294297
Assert.That(
295298
sqlEvents[1].RenderedMessage,
296-
Does.Contain("UNKNOWN").And.Contain("Constant2").And.Not.Contain("Constant1"),
299+
Does.Contain("UNKNOWN").And.Contain("Constant2").And.Contain("CompanyName").IgnoreCase
300+
.And.Not.Contain("Constant1"),
301+
"Unexpected constant parameter value");
302+
Assert.That(
303+
sqlEvents[1].RenderedMessage,
304+
Does.Contain("UNKNOWN").And.Contain("Constant2").And.Contain("ContactName").IgnoreCase
305+
.And.Not.Contain("Constant1"),
297306
"Unexpected constant parameter value");
298307
}
299308

300-
Assert.That(cache, Has.Count.EqualTo(2), "Additional queries should not cause a plan to be cached.");
309+
Assert.That(cache, Has.Count.EqualTo(3), "Additional queries should not cause a plan to be cached.");
301310
Assert.That(
302311
spy.GetWholeLog(),
303312
Does
304313
.Contain("located HQL query plan in cache")
305314
.And.Not.Contain("unable to locate HQL query plan in cache"));
306315

307316
db.Customers.Where(c => c.CustomerId == "ANATR").Update(x => new Customer {ContactName = x.ContactName});
308-
Assert.That(cache, Has.Count.EqualTo(3), "Query should be cached");
317+
Assert.That(cache, Has.Count.EqualTo(4), "Query should be cached");
309318
}
310319
}
311320
}

0 commit comments

Comments
 (0)