|
1 | | -using System; |
2 | | -using System.Collections.Generic; |
| 1 | +using System; |
3 | 2 | using System.Data; |
4 | 3 | using System.Diagnostics; |
5 | 4 | using System.Linq; |
@@ -112,7 +111,7 @@ public void CancelCommandBeforeRead() |
112 | 111 | Assert.Equal((int) MySqlErrorCode.QueryInterrupted, ex.Number); |
113 | 112 | } |
114 | 113 | Assert.False(reader.NextResult()); |
115 | | - Assert.InRange(stopwatch.ElapsedMilliseconds, 0, 1000 * c_ciDelayFactor); |
| 114 | + TestUtilities.AssertDuration(stopwatch, 0, 1000); |
116 | 115 | Assert.InRange(rows, 0, 10000000); |
117 | 116 | } |
118 | 117 | } |
@@ -174,7 +173,7 @@ public void DapperQueryMultiple() |
174 | 173 | stopwatch = Stopwatch.StartNew(); |
175 | 174 | } |
176 | 175 | stopwatch.Stop(); |
177 | | - Assert.InRange(stopwatch.ElapsedMilliseconds, 0, 1000 * c_ciDelayFactor); |
| 176 | + TestUtilities.AssertDuration(stopwatch, 0, 1000); |
178 | 177 | } |
179 | 178 |
|
180 | 179 | #if !BASELINE |
@@ -294,7 +293,7 @@ public async Task CancelSlowQueryWithTokenAfterExecuteReader() |
294 | 293 | var stopwatch = Stopwatch.StartNew(); |
295 | 294 | using (var reader = await cmd.ExecuteReaderAsync(cts.Token)) |
296 | 295 | { |
297 | | - Assert.InRange(stopwatch.ElapsedMilliseconds, 450, 750 * c_ciDelayFactor); |
| 296 | + TestUtilities.AssertDuration(stopwatch, 450, 300); |
298 | 297 |
|
299 | 298 | var rows = 0; |
300 | 299 | try |
@@ -329,7 +328,7 @@ public async Task CancelSlowQueryWithTokenAfterNextResult() |
329 | 328 | // the call to NextResult should block until the token is cancelled |
330 | 329 | var stopwatch = Stopwatch.StartNew(); |
331 | 330 | Assert.True(await reader.NextResultAsync(cts.Token)); |
332 | | - Assert.InRange(stopwatch.ElapsedMilliseconds, 450, 750 * c_ciDelayFactor); |
| 331 | + TestUtilities.AssertDuration(stopwatch, 450, 300); |
333 | 332 |
|
334 | 333 | int rows = 0; |
335 | 334 | try |
@@ -393,10 +392,6 @@ private static CancellationToken GetCanceledToken() |
393 | 392 | const string c_slowQuery = @"select * from integers a join integers b join integers c join integers d join integers e join integers f join integers g join integers h |
394 | 393 | where sqrt(a.value) + sqrt(b.value) + sqrt(c.value) + sqrt(d.value) + sqrt(e.value) + sqrt(f.value) + sqrt(g.value) + sqrt(h.value) = 20;"; |
395 | 394 |
|
396 | | - // tests can run extremely slowly on Appveyor (and slightly slower under Travis) |
397 | | - static readonly int c_ciDelayFactor = Environment.GetEnvironmentVariable("APPVEYOR") == "True" ? 10 : |
398 | | - Environment.GetEnvironmentVariable("TRAVIS") == "true" ? 3 : 1; |
399 | | - |
400 | 395 | readonly DatabaseFixture m_database; |
401 | 396 | } |
402 | 397 | } |
0 commit comments