|
9 | 9 | using System.Reflection; |
10 | 10 | using System.Text; |
11 | 11 | using System.Threading; |
| 12 | +using System.Threading.Tasks; |
12 | 13 | using Xunit; |
13 | 14 |
|
14 | 15 | namespace Microsoft.Data.SqlClient.ManualTesting.Tests |
@@ -300,6 +301,105 @@ public static void CheckNullRowVersionIsBDNull() |
300 | 301 | } |
301 | 302 | } |
302 | 303 |
|
| 304 | + [ConditionalFact(typeof(DataTestUtility), nameof(DataTestUtility.AreConnStringsSetup))] |
| 305 | + public static int CanReadEmployeesTableCompletely() |
| 306 | + { |
| 307 | + int counter = 0; |
| 308 | + |
| 309 | + using (var conn = new SqlConnection(DataTestUtility.TCPConnectionString)) |
| 310 | + { |
| 311 | + using (var cmd = new SqlCommand("SELECT EmployeeID,LastName,FirstName,Title,TitleOfCourtesy,BirthDate,HireDate,Address,City,Region,PostalCode,Country,HomePhone,Extension,Photo,Notes,ReportsTo,PhotoPath FROM Employees WHERE ReportsTo = @p0 OR (ReportsTo IS NULL AND @p0 IS NULL)", conn)) |
| 312 | + { |
| 313 | + cmd.Parameters.AddWithValue("@p0", 5); |
| 314 | + |
| 315 | + conn.Open(); |
| 316 | + |
| 317 | + using (var reader = cmd.ExecuteReader()) |
| 318 | + { |
| 319 | + if (reader.Read()) |
| 320 | + { |
| 321 | + for (int index = 0; index < reader.FieldCount; index++) |
| 322 | + { |
| 323 | + if (!reader.IsDBNull(index)) |
| 324 | + { |
| 325 | + object value = reader[index]; |
| 326 | + counter += 1; |
| 327 | + } |
| 328 | + } |
| 329 | + } |
| 330 | + } |
| 331 | + } |
| 332 | + } |
| 333 | + |
| 334 | + return counter; |
| 335 | + } |
| 336 | + |
| 337 | + [ConditionalFact(typeof(DataTestUtility), nameof(DataTestUtility.AreConnStringsSetup))] |
| 338 | + public static async Task<int> CanReadEmployeesTableCompletelyAsync() |
| 339 | + { |
| 340 | + int counter = 0; |
| 341 | + |
| 342 | + using (var conn = new SqlConnection(DataTestUtility.TCPConnectionString)) |
| 343 | + { |
| 344 | + using (var cmd = new SqlCommand("SELECT EmployeeID,LastName,FirstName,Title,TitleOfCourtesy,BirthDate,HireDate,Address,City,Region,PostalCode,Country,HomePhone,Extension,Photo,Notes,ReportsTo,PhotoPath FROM Employees WHERE ReportsTo = @p0 OR (ReportsTo IS NULL AND @p0 IS NULL)", conn)) |
| 345 | + { |
| 346 | + cmd.Parameters.AddWithValue("@p0", 5); |
| 347 | + |
| 348 | + await conn.OpenAsync(); |
| 349 | + |
| 350 | + using (var reader = await cmd.ExecuteReaderAsync()) |
| 351 | + { |
| 352 | + if (await reader.ReadAsync()) |
| 353 | + { |
| 354 | + for (int index = 0; index < reader.FieldCount; index++) |
| 355 | + { |
| 356 | + if (!await reader.IsDBNullAsync(index)) |
| 357 | + { |
| 358 | + object value = reader[index]; |
| 359 | + counter += 1; |
| 360 | + } |
| 361 | + } |
| 362 | + } |
| 363 | + } |
| 364 | + } |
| 365 | + } |
| 366 | + |
| 367 | + return counter; |
| 368 | + } |
| 369 | + |
| 370 | + [ConditionalFact(typeof(DataTestUtility), nameof(DataTestUtility.AreConnStringsSetup))] |
| 371 | + public static async Task<int> CanReadEmployeesTableCompletelyWithNullImageAsync() |
| 372 | + { |
| 373 | + int counter = 0; |
| 374 | + |
| 375 | + using (var conn = new SqlConnection(DataTestUtility.TCPConnectionString)) |
| 376 | + { |
| 377 | + using (var cmd = new SqlCommand("SELECT EmployeeID,LastName,FirstName,Title,TitleOfCourtesy,BirthDate,HireDate,Address,City,Region,PostalCode,Country,HomePhone,Extension,convert(image,NULL) as Photo,Notes,ReportsTo,PhotoPath FROM Employees WHERE ReportsTo = @p0 OR (ReportsTo IS NULL AND @p0 IS NULL)", conn)) |
| 378 | + { |
| 379 | + cmd.Parameters.AddWithValue("@p0", 5); |
| 380 | + |
| 381 | + await conn.OpenAsync(); |
| 382 | + |
| 383 | + using (var reader = await cmd.ExecuteReaderAsync()) |
| 384 | + { |
| 385 | + if (await reader.ReadAsync()) |
| 386 | + { |
| 387 | + for (int index = 0; index < reader.FieldCount; index++) |
| 388 | + { |
| 389 | + if (!await reader.IsDBNullAsync(index)) |
| 390 | + { |
| 391 | + object value = reader[index]; |
| 392 | + counter += 1; |
| 393 | + } |
| 394 | + } |
| 395 | + } |
| 396 | + } |
| 397 | + } |
| 398 | + } |
| 399 | + |
| 400 | + return counter; |
| 401 | + } |
| 402 | + |
303 | 403 | // Synapse: Cannot find data type 'rowversion'. |
304 | 404 | [ConditionalFact(typeof(DataTestUtility), nameof(DataTestUtility.AreConnStringsSetup), nameof(DataTestUtility.IsNotAzureSynapse))] |
305 | 405 | public static void CheckLegacyNullRowVersionIsEmptyArray() |
|
0 commit comments