Skip to content

Commit d55dbc5

Browse files
DAXaholicstephentoub
authored andcommitted
Remove unused parameters for custom test errors (dotnet/corefx#40151)
Closes dotnet/corefx#38575 Commit migrated from dotnet/corefx@22259d8
1 parent 9209be9 commit d55dbc5

9 files changed

Lines changed: 46 additions & 63 deletions

File tree

src/libraries/System.Collections.Concurrent/tests/BlockingCollectionCancellationTests.cs

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -71,36 +71,30 @@ public static void ExternalCancel_Negative()
7171

7272
int item;
7373
EnsureOperationCanceledExceptionThrown(
74-
() => bc.Take(cs.Token), cs.Token,
75-
"ExternalCancel_Take: The operation should wake up via token cancellation.");
74+
() => bc.Take(cs.Token), cs.Token);
7675
EnsureOperationCanceledExceptionThrown(
77-
() => bc.TryTake(out item, 100000, cs.Token), cs.Token,
78-
"ExternalCancel_TryTake: The operation should wake up via token cancellation.");
76+
() => bc.TryTake(out item, 100000, cs.Token), cs.Token);
7977
EnsureOperationCanceledExceptionThrown(
80-
() => bc.Add(1, cs.Token), cs.Token,
81-
"ExternalCancel_Add: The operation should wake up via token cancellation.");
78+
() => bc.Add(1, cs.Token), cs.Token);
8279
EnsureOperationCanceledExceptionThrown(
8380
() => bc.TryAdd(1, 100000, cs.Token), // a long timeout.
84-
cs.Token,
85-
"ExternalCancel_TryAdd: The operation should wake up via token cancellation.");
81+
cs.Token);
8682

8783
BlockingCollection<int> bc1 = new BlockingCollection<int>(1);
8884
BlockingCollection<int> bc2 = new BlockingCollection<int>(1);
8985
bc1.Add(1); //fill the bc.
9086
bc2.Add(1); //fill the bc.
9187
EnsureOperationCanceledExceptionThrown(
9288
() => BlockingCollection<int>.AddToAny(new[] { bc1, bc2 }, 1, cs.Token),
93-
cs.Token,
94-
"ExternalCancel_AddToAny: The operation should wake up via token cancellation.");
89+
cs.Token);
9590
EnsureOperationCanceledExceptionThrown(
9691
() => BlockingCollection<int>.TryAddToAny(new[] { bc1, bc2 }, 1, 10000, cs.Token),
97-
cs.Token,
98-
"ExternalCancel_AddToAny: The operation should wake up via token cancellation.");
92+
cs.Token);
9993

10094
IEnumerable<int> enumerable = bc.GetConsumingEnumerable(cs.Token);
10195
EnsureOperationCanceledExceptionThrown(
10296
() => enumerable.GetEnumerator().MoveNext(),
103-
cs.Token, "ExternalCancel_GetConsumingEnumerable: The operation should wake up via token cancellation.");
97+
cs.Token);
10498
}
10599

106100
[Fact]
@@ -159,7 +153,7 @@ public static void ExternalCancel_GetConsumingEnumerable()
159153

160154
#region Helper Methods
161155

162-
private static void EnsureOperationCanceledExceptionThrown(Action action, CancellationToken token, string message)
156+
private static void EnsureOperationCanceledExceptionThrown(Action action, CancellationToken token)
163157
{
164158
OperationCanceledException operationCanceledEx =
165159
Assert.Throws<OperationCanceledException>(action); // "BlockingCollectionCancellationTests: OperationCanceledException not thrown.");

src/libraries/System.Collections.Immutable/tests/ImmutableStackTest.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ private void PopTestHelper<T>(params T[] values)
6868
var nextStack = currentStack.Pop();
6969
Assert.Equal(expectedCount, currentStack.Count());
7070
Assert.NotSame(currentStack, nextStack);
71-
AssertAreSame(currentStack.Pop(), currentStack.Pop(), "Popping the stack 2X should yield the same shorter stack.");
71+
AssertAreSame(currentStack.Pop(), currentStack.Pop());
7272
currentStack = nextStack;
7373
}
7474
}
@@ -86,7 +86,7 @@ private void PeekTestHelper<T>(params T[] values)
8686
current.Pop(out element);
8787
AssertAreSame(current.Peek(), element);
8888
var next = current.Pop();
89-
AssertAreSame(values[i], current.Peek(), "Pop mutated the stack instance.");
89+
AssertAreSame(values[i], current.Peek());
9090
current = next;
9191
}
9292
}

src/libraries/System.Collections.Immutable/tests/ImmutableTestBase.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ protected int RandomOperationsCount
2121
get { return 100; }
2222
}
2323

24-
internal static void AssertAreSame<T>(T expected, T actual, string message = null, params object[] formattingArgs)
24+
internal static void AssertAreSame<T>(T expected, T actual)
2525
{
2626
if (typeof(T).GetTypeInfo().IsValueType)
2727
{

src/libraries/System.Composition/tests/Util/AssertX.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ namespace System.Composition.UnitTests.Util
1010
{
1111
internal static class AssertX
1212
{
13-
public static void Equivalent<T>(IEnumerable<T> expected, IEnumerable<T> actual, string message = null, params object[] args)
13+
public static void Equivalent<T>(IEnumerable<T> expected, IEnumerable<T> actual)
1414
{
1515
IDictionary<T, int> expectedCounts = expected.GroupBy(x => x).ToDictionary(x => x.Key, x => x.Count());
1616
IDictionary<T, int> actualCounts = actual.GroupBy(x => x).ToDictionary(x => x.Key, x => x.Count());

src/libraries/System.Runtime.Numerics/tests/BigInteger/Comparison.cs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -390,16 +390,16 @@ private static void VerifyComparison(BigInteger x, BigInteger y, int expectedRes
390390
Assert.Equal(expectedEquals, x.Equals((object)y));
391391
Assert.Equal(expectedEquals, y.Equals((object)x));
392392

393-
VerifyCompareResult(expectedResult, x.CompareTo(y), "x.CompareTo(y)");
394-
VerifyCompareResult(-expectedResult, y.CompareTo(x), "y.CompareTo(x)");
393+
VerifyCompareResult(expectedResult, x.CompareTo(y));
394+
VerifyCompareResult(-expectedResult, y.CompareTo(x));
395395

396396
IComparable comparableX = x;
397397
IComparable comparableY = y;
398-
VerifyCompareResult(expectedResult, comparableX.CompareTo(y), "comparableX.CompareTo(y)");
399-
VerifyCompareResult(-expectedResult, comparableY.CompareTo(x), "comparableY.CompareTo(x)");
398+
VerifyCompareResult(expectedResult, comparableX.CompareTo(y));
399+
VerifyCompareResult(-expectedResult, comparableY.CompareTo(x));
400400

401-
VerifyCompareResult(expectedResult, BigInteger.Compare(x, y), "Compare(x,y)");
402-
VerifyCompareResult(-expectedResult, BigInteger.Compare(y, x), "Compare(y,x)");
401+
VerifyCompareResult(expectedResult, BigInteger.Compare(x, y));
402+
VerifyCompareResult(-expectedResult, BigInteger.Compare(y, x));
403403

404404
if (expectedEquals)
405405
{
@@ -437,7 +437,7 @@ private static void VerifyComparison(BigInteger x, int y, int expectedResult)
437437

438438
Assert.Equal(expectedEquals, x.Equals(y));
439439

440-
VerifyCompareResult(expectedResult, x.CompareTo(y), "x.CompareTo(y)");
440+
VerifyCompareResult(expectedResult, x.CompareTo(y));
441441

442442
if (expectedEquals)
443443
{
@@ -475,7 +475,7 @@ private static void VerifyComparison(BigInteger x, uint y, int expectedResult)
475475

476476
Assert.Equal(expectedEquals, x.Equals(y));
477477

478-
VerifyCompareResult(expectedResult, x.CompareTo(y), "x.CompareTo(y)");
478+
VerifyCompareResult(expectedResult, x.CompareTo(y));
479479

480480
if (expectedEquals)
481481
{
@@ -514,7 +514,7 @@ private static void VerifyComparison(BigInteger x, long y, int expectedResult)
514514

515515
Assert.Equal(expectedEquals, x.Equals(y));
516516

517-
VerifyCompareResult(expectedResult, x.CompareTo(y), "x.CompareTo(y)");
517+
VerifyCompareResult(expectedResult, x.CompareTo(y));
518518

519519
if (expectedEquals)
520520
{
@@ -552,7 +552,7 @@ private static void VerifyComparison(BigInteger x, ulong y, int expectedResult)
552552

553553
Assert.Equal(expectedEquals, x.Equals(y));
554554

555-
VerifyCompareResult(expectedResult, x.CompareTo(y), "x.CompareTo(y)");
555+
VerifyCompareResult(expectedResult, x.CompareTo(y));
556556

557557
if (expectedEquals)
558558
{
@@ -608,8 +608,8 @@ private static void VerifyComparison(BigInteger x, bool IsXNegative, BigInteger
608608
Assert.Equal(expectedEquals, x.Equals((object)y));
609609
Assert.Equal(expectedEquals, y.Equals((object)x));
610610

611-
VerifyCompareResult(expectedResult, x.CompareTo(y), "x.CompareTo(y)");
612-
VerifyCompareResult(-expectedResult, y.CompareTo(x), "y.CompareTo(x)");
611+
VerifyCompareResult(expectedResult, x.CompareTo(y));
612+
VerifyCompareResult(-expectedResult, y.CompareTo(x));
613613

614614
if (expectedEquals)
615615
{
@@ -637,8 +637,8 @@ private static void VerifyComparison(BigInteger x, bool IsXNegative, BigInteger
637637
Assert.Equal(expectedGreaterThan || expectedEquals, x >= y);
638638
Assert.Equal(expectedLessThan || expectedEquals, y >= x);
639639
}
640-
641-
private static void VerifyCompareResult(int expected, int actual, string message)
640+
641+
private static void VerifyCompareResult(int expected, int actual)
642642
{
643643
if (0 == expected)
644644
{

src/libraries/System.Threading/tests/BarrierCancellationTests.cs

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,11 @@ public static void BarrierCancellationTestsCancelBeforeWait()
2222
TimeSpan timeSpan = new TimeSpan(100);
2323

2424
EnsureOperationCanceledExceptionThrown(
25-
() => barrier.SignalAndWait(ct), ct,
26-
"CancelBeforeWait: An OCE should have been thrown.");
25+
() => barrier.SignalAndWait(ct), ct);
2726
EnsureOperationCanceledExceptionThrown(
28-
() => barrier.SignalAndWait(millisec, ct), ct,
29-
"CancelBeforeWait: An OCE should have been thrown.");
27+
() => barrier.SignalAndWait(millisec, ct), ct);
3028
EnsureOperationCanceledExceptionThrown(
31-
() => barrier.SignalAndWait(timeSpan, ct), ct,
32-
"CancelBeforeWait: An OCE should have been thrown.");
29+
() => barrier.SignalAndWait(timeSpan, ct), ct);
3330

3431
barrier.Dispose();
3532
}
@@ -48,8 +45,7 @@ public static void BarrierCancellationTestsCancelAfterWait_Negative()
4845
//Now wait.. the wait should abort and an exception should be thrown
4946
EnsureOperationCanceledExceptionThrown(
5047
() => barrier.SignalAndWait(cancellationToken),
51-
cancellationToken,
52-
"CancelAfterWait: An OCE(null) should have been thrown that references the cancellationToken.");
48+
cancellationToken);
5349

5450
// the token should not have any listeners.
5551
// currently we don't expose this.. but it was verified manually
@@ -73,7 +69,7 @@ public static void BarrierCancellationTestsCancelAfterWait()
7369
// currently we don't expose this.. but it was verified manually
7470
}
7571

76-
private static void EnsureOperationCanceledExceptionThrown(Action action, CancellationToken token, string message)
72+
private static void EnsureOperationCanceledExceptionThrown(Action action, CancellationToken token)
7773
{
7874
OperationCanceledException operationCanceledEx =
7975
Assert.Throws<OperationCanceledException>(action);

src/libraries/System.Threading/tests/CountdownEventCancellationTests.cs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,9 @@ public static void CancelBeforeWait()
1919

2020
const int millisec = 100;
2121
TimeSpan timeSpan = new TimeSpan(100);
22-
string message = "CancelBeforeWait: > Cancellation token does not match.";
23-
EnsureOperationCanceledExceptionThrown(() => countdownEvent.Wait(ct), ct, message);
24-
EnsureOperationCanceledExceptionThrown(() => countdownEvent.Wait(millisec, ct), ct, message);
25-
EnsureOperationCanceledExceptionThrown(() => countdownEvent.Wait(timeSpan, ct), ct, message);
22+
EnsureOperationCanceledExceptionThrown(() => countdownEvent.Wait(ct), ct);
23+
EnsureOperationCanceledExceptionThrown(() => countdownEvent.Wait(millisec, ct), ct);
24+
EnsureOperationCanceledExceptionThrown(() => countdownEvent.Wait(timeSpan, ct), ct);
2625

2726
countdownEvent.Dispose();
2827
}
@@ -41,14 +40,13 @@ public static void CancelAfterWait()
4140
});
4241

4342
//Now wait.. the wait should abort and an exception should be thrown
44-
EnsureOperationCanceledExceptionThrown(() => countdownEvent.Wait(cancellationToken), cancellationToken,
45-
"CancelAfterWait: An OCE(null) should have been thrown that references the cancellationToken.");
43+
EnsureOperationCanceledExceptionThrown(() => countdownEvent.Wait(cancellationToken), cancellationToken);
4644

4745
// the token should not have any listeners.
4846
// currently we don't expose this.. but it was verified manually
4947
}
5048

51-
private static void EnsureOperationCanceledExceptionThrown(Action action, CancellationToken token, string message)
49+
private static void EnsureOperationCanceledExceptionThrown(Action action, CancellationToken token)
5250
{
5351
OperationCanceledException operationCanceledEx =
5452
Assert.Throws<OperationCanceledException>(action);

src/libraries/System.Threading/tests/ManualResetEventSlimCancellationTests.cs

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,9 @@ public static void CancelBeforeWait()
2020
const int millisec = 100;
2121
TimeSpan timeSpan = new TimeSpan(100);
2222

23-
EnsureOperationCanceledExceptionThrown(
24-
() => mres.Wait(ct), ct, "CancelBeforeWait: An OCE should have been thrown.");
25-
EnsureOperationCanceledExceptionThrown(
26-
() => mres.Wait(millisec, ct), ct, "CancelBeforeWait: An OCE should have been thrown.");
27-
EnsureOperationCanceledExceptionThrown(
28-
() => mres.Wait(timeSpan, ct), ct, "CancelBeforeWait: An OCE should have been thrown.");
23+
EnsureOperationCanceledExceptionThrown(() => mres.Wait(ct), ct);
24+
EnsureOperationCanceledExceptionThrown(() => mres.Wait(millisec, ct), ct);
25+
EnsureOperationCanceledExceptionThrown(() => mres.Wait(timeSpan, ct), ct);
2926
mres.Dispose();
3027
}
3128

@@ -46,15 +43,13 @@ public static void CancelAfterWait()
4643
);
4744

4845
//Now wait.. the wait should abort and an exception should be thrown
49-
EnsureOperationCanceledExceptionThrown(
50-
() => mres.Wait(cancellationToken), cancellationToken,
51-
"CancelBeforeWait: An OCE(null) should have been thrown that references the cancellationToken.");
46+
EnsureOperationCanceledExceptionThrown(() => mres.Wait(cancellationToken), cancellationToken);
5247

5348
// the token should not have any listeners.
5449
// currently we don't expose this.. but it was verified manually
5550
}
5651

57-
private static void EnsureOperationCanceledExceptionThrown(Action action, CancellationToken token, string message)
52+
private static void EnsureOperationCanceledExceptionThrown(Action action, CancellationToken token)
5853
{
5954
OperationCanceledException operationCanceledEx =
6055
Assert.Throws<OperationCanceledException>(action);

src/libraries/System.Threading/tests/SemaphoreSlimCancellationTests.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ public static void CancelBeforeWait()
2020

2121
const int millisec = 100;
2222
TimeSpan timeSpan = new TimeSpan(100);
23-
EnsureOperationCanceledExceptionThrown(() => semaphoreSlim.Wait(ct), ct, "CancelBeforeWait: An OCE should have been thrown.");
24-
EnsureOperationCanceledExceptionThrown(() => semaphoreSlim.Wait(millisec, ct), ct, "CancelBeforeWait: An OCE should have been thrown.");
25-
EnsureOperationCanceledExceptionThrown(() => semaphoreSlim.Wait(timeSpan, ct), ct, "CancelBeforeWait: An OCE should have been thrown.");
23+
EnsureOperationCanceledExceptionThrown(() => semaphoreSlim.Wait(ct), ct);
24+
EnsureOperationCanceledExceptionThrown(() => semaphoreSlim.Wait(millisec, ct), ct);
25+
EnsureOperationCanceledExceptionThrown(() => semaphoreSlim.Wait(timeSpan, ct), ct);
2626
semaphoreSlim.Dispose();
2727
}
2828

@@ -44,13 +44,13 @@ public static void CancelAfterWait()
4444
//Now wait.. the wait should abort and an exception should be thrown
4545
EnsureOperationCanceledExceptionThrown(
4646
() => semaphoreSlim.Wait(cancellationToken),
47-
cancellationToken, "CancelAfterWait: An OCE(null) should have been thrown that references the cancellationToken.");
47+
cancellationToken);
4848

4949
// the token should not have any listeners.
5050
// currently we don't expose this.. but it was verified manually
5151
}
5252

53-
private static void EnsureOperationCanceledExceptionThrown(Action action, CancellationToken token, string message)
53+
private static void EnsureOperationCanceledExceptionThrown(Action action, CancellationToken token)
5454
{
5555
OperationCanceledException operationCanceledEx =
5656
Assert.Throws<OperationCanceledException>(action);

0 commit comments

Comments
 (0)