Skip to content

Commit e010988

Browse files
committed
- Fixed tests sensitive to OS newlines.
1 parent 5b6cd7e commit e010988

File tree

1 file changed

+31
-5
lines changed
  • src/Microsoft.Data.SqlClient/tests/ManualTests/AlwaysEncrypted

1 file changed

+31
-5
lines changed

src/Microsoft.Data.SqlClient/tests/ManualTests/AlwaysEncrypted/ApiShould.cs

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,20 @@ public sealed class ApiShould : IClassFixture<PlatformSpecificTestContext>, IDis
4747

4848
private HashSet<string> _cancellationExceptionMessages = new HashSet<string>()
4949
{
50-
"A severe error occurred on the current command. The results, if any, should be discarded.\r\nOperation cancelled by user.",
51-
"A severe error occurred on the current command. The results, if any, should be discarded.",
50+
"A severe error occurred on the current command. " +
51+
"The results, if any, should be discarded." + Environment.NewLine +
5252
"Operation cancelled by user.",
53-
"The request failed to run because the batch is aborted, this can be caused by abort signal sent from client, or another request is running in the same session, which makes the session busy.\r\nOperation cancelled by user."
53+
54+
"A severe error occurred on the current command. " +
55+
"The results, if any, should be discarded.",
56+
57+
"Operation cancelled by user.",
58+
59+
"The request failed to run because the batch is aborted, " +
60+
"this can be caused by abort signal sent from client, " +
61+
"or another request is running in the same session, " +
62+
"which makes the session busy." + Environment.NewLine +
63+
"Operation cancelled by user."
5464
};
5565

5666
public ApiShould(PlatformSpecificTestContext context)
@@ -3195,7 +3205,15 @@ private void Thread_ExecuteReader(object state)
31953205
while (reader.Read())
31963206
{ }
31973207
});
3198-
Assert.Contains(ex.Message, _cancellationExceptionMessages);
3208+
3209+
// We don't use Assert.Contains() here because it truncates the
3210+
// actual and expected strings when outputting a failure.
3211+
if (!_cancellationExceptionMessages.Contains(ex.Message))
3212+
{
3213+
Assert.Fail(
3214+
$"Exception message \"{ex.Message}\" not found in: [\"" +
3215+
string.Join("\", \"", _cancellationExceptionMessages) + "\"]");
3216+
}
31993217
}
32003218
finally
32013219
{
@@ -3219,7 +3237,15 @@ private void Thread_ExecuteNonQuery(object state)
32193237
cancelCommandTestParamsObject.StartWorkloadSignal.Wait();
32203238

32213239
Exception ex = Assert.ThrowsAny<Exception>(() => sqlCommand.ExecuteNonQuery());
3222-
Assert.Contains(ex.Message, _cancellationExceptionMessages);
3240+
3241+
// We don't use Assert.Contains() here because it truncates the
3242+
// actual and expected strings when outputting a failure.
3243+
if (!_cancellationExceptionMessages.Contains(ex.Message))
3244+
{
3245+
Assert.Fail(
3246+
$"Exception message \"{ex.Message}\" not found in: [\"" +
3247+
string.Join("\", \"", _cancellationExceptionMessages) + "\"]");
3248+
}
32233249
}
32243250
finally
32253251
{

0 commit comments

Comments
 (0)