Skip to content

Commit cc2ee4f

Browse files
fixup! Support evaluation of Random.Next and NextDouble on db side
Fix again a test error causing 10% of runs to fail. (I am having a hard time getting this one right...)
1 parent 247769d commit cc2ee4f

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -321,9 +321,9 @@ public async Task CanQueryByRandomIntWithMaxAsync()
321321
// done next to the conditional operator. Having the cast only on one side is enough for avoiding
322322
// Firebird complain, so moving the constants on the left side have been put before the order id, in
323323
// order for these constants to be casted by the driver.
324-
var x = await (db.Orders.CountAsync(o => -idMin + o.OrderId < random.Next(10)));
324+
var x = await (db.Orders.CountAsync(o => -idMin + o.OrderId <= random.Next(10)));
325325

326-
Assert.That(x, Is.GreaterThan(0).And.LessThan(10));
326+
Assert.That(x, Is.GreaterThan(0).And.LessThan(11));
327327
// Next requires support of both floor and rand
328328
AssertFunctionInSql(IsFunctionSupported("floor") ? "random" : "floor", spy);
329329
}
@@ -371,7 +371,7 @@ public async Task CanQueryByRandomIntWithMinMaxAsync()
371371
// done next to the conditional operator. Having the cast only on one side is enough for avoiding
372372
// Firebird complain, so moving the constants on the left side have been put before the order id, in
373373
// order for these constants to be casted by the driver.
374-
var x = await (db.Orders.CountAsync(o => -idMin + o.OrderId< random.Next(1, 11)));
374+
var x = await (db.Orders.CountAsync(o => -idMin + o.OrderId < random.Next(1, 11)));
375375

376376
Assert.That(x, Is.GreaterThan(0).And.LessThan(10));
377377
// Next requires support of both floor and rand

src/NHibernate.Test/Linq/PreEvaluationTests.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -309,9 +309,9 @@ public void CanQueryByRandomIntWithMax()
309309
// done next to the conditional operator. Having the cast only on one side is enough for avoiding
310310
// Firebird complain, so moving the constants on the left side have been put before the order id, in
311311
// order for these constants to be casted by the driver.
312-
var x = db.Orders.Count(o => -idMin + o.OrderId < random.Next(10));
312+
var x = db.Orders.Count(o => -idMin + o.OrderId <= random.Next(10));
313313

314-
Assert.That(x, Is.GreaterThan(0).And.LessThan(10));
314+
Assert.That(x, Is.GreaterThan(0).And.LessThan(11));
315315
// Next requires support of both floor and rand
316316
AssertFunctionInSql(IsFunctionSupported("floor") ? "random" : "floor", spy);
317317
}
@@ -359,7 +359,7 @@ public void CanQueryByRandomIntWithMinMax()
359359
// done next to the conditional operator. Having the cast only on one side is enough for avoiding
360360
// Firebird complain, so moving the constants on the left side have been put before the order id, in
361361
// order for these constants to be casted by the driver.
362-
var x = db.Orders.Count(o => -idMin + o.OrderId< random.Next(1, 11));
362+
var x = db.Orders.Count(o => -idMin + o.OrderId < random.Next(1, 11));
363363

364364
Assert.That(x, Is.GreaterThan(0).And.LessThan(10));
365365
// Next requires support of both floor and rand

0 commit comments

Comments
 (0)