diff --git a/src/coreclr/tools/GCLogParser/parse-hb-log.cs b/src/coreclr/tools/GCLogParser/parse-hb-log.cs index ebf1a01a322452..34793ffc62d61d 100644 --- a/src/coreclr/tools/GCLogParser/parse-hb-log.cs +++ b/src/coreclr/tools/GCLogParser/parse-hb-log.cs @@ -579,7 +579,7 @@ private static void PrintAllocToAllPassOneFiles() { strAlloc += string.Format("|{0,5}", AllocMB[procIndex]); } - strAlloc += string.Format("|"); + strAlloc += "|"; PrintToAllPassOneFiles(strAlloc); } @@ -613,7 +613,7 @@ private static void PrintHeader() { strHeader += string.Format("|{0,5}", procIndex); } - strHeader += string.Format("|"); + strHeader += "|"; PrintToAllPassOneFiles(strHeader); } diff --git a/src/libraries/System.Reflection.MetadataLoadContext/tests/src/Tests/TypeInfoFromProjectN/TypeInfo_PropertyTests.cs b/src/libraries/System.Reflection.MetadataLoadContext/tests/src/Tests/TypeInfoFromProjectN/TypeInfo_PropertyTests.cs index fdd7c58117c4ad..41e2f0b5506041 100644 --- a/src/libraries/System.Reflection.MetadataLoadContext/tests/src/Tests/TypeInfoFromProjectN/TypeInfo_PropertyTests.cs +++ b/src/libraries/System.Reflection.MetadataLoadContext/tests/src/Tests/TypeInfoFromProjectN/TypeInfo_PropertyTests.cs @@ -45,7 +45,7 @@ public static void TestContainsGenericParameter1() bool hasgenericParam = ti.ContainsGenericParameters; - Assert.True(hasgenericParam, string.Format("Failed!! TestContainsGenericParameter did not return correct result. ")); + Assert.True(hasgenericParam, "Failed!! TestContainsGenericParameter did not return correct result. "); } // Verify ContainsGenericParameter @@ -57,7 +57,7 @@ public static void TestContainsGenericParameter2() bool hasgenericParam = ti.ContainsGenericParameters; - Assert.False(hasgenericParam, string.Format("Failed!! TestContainsGenericParameter did not return correct result. ")); + Assert.False(hasgenericParam, "Failed!! TestContainsGenericParameter did not return correct result. "); } // Verify FullName diff --git a/src/libraries/System.Runtime/tests/System.Threading.Tasks.Tests/CancellationTokenTests.cs b/src/libraries/System.Runtime/tests/System.Threading.Tasks.Tests/CancellationTokenTests.cs index 0d48e3840d96a9..c309ec3f10ea2b 100644 --- a/src/libraries/System.Runtime/tests/System.Threading.Tasks.Tests/CancellationTokenTests.cs +++ b/src/libraries/System.Runtime/tests/System.Threading.Tasks.Tests/CancellationTokenTests.cs @@ -178,7 +178,7 @@ public static void TokenSourceDispose() } catch { - Assert.Fail(string.Format("TokenSourceDispose: > ctr.Dispose() failed when referring to a disposed CTS")); + Assert.Fail("TokenSourceDispose: > ctr.Dispose() failed when referring to a disposed CTS"); } bool cr = tokenSource.IsCancellationRequested; //this is ok after dispose. @@ -863,7 +863,7 @@ public static void ODEWhenDisposingLinkedCTS() { if (ex is ObjectDisposedException) { - Assert.Fail(string.Format("Bug901737_ODEWhenDisposingLinkedCTS: - ODE Occurred!")); + Assert.Fail("Bug901737_ODEWhenDisposingLinkedCTS: - ODE Occurred!"); } else { @@ -990,9 +990,9 @@ public static void DerivedCancellationTokenSource_Negative() { // Accessing the Token property should throw an ObjectDisposedException if (c.Token.CanBeCanceled) - Assert.Fail(string.Format("DerivedCancellationTokenSource: Accessing the Token property should throw an ObjectDisposedException, but it did not.")); + Assert.Fail("DerivedCancellationTokenSource: Accessing the Token property should throw an ObjectDisposedException, but it did not."); else - Assert.Fail(string.Format("DerivedCancellationTokenSource: Accessing the Token property should throw an ObjectDisposedException, but it did not.")); + Assert.Fail("DerivedCancellationTokenSource: Accessing the Token property should throw an ObjectDisposedException, but it did not."); }); } } diff --git a/src/libraries/System.Runtime/tests/System.Threading.Tasks.Tests/System.Runtime.CompilerServices/YieldAwaitableTests.cs b/src/libraries/System.Runtime/tests/System.Threading.Tasks.Tests/System.Runtime.CompilerServices/YieldAwaitableTests.cs index b59975389042be..30234688656d00 100644 --- a/src/libraries/System.Runtime/tests/System.Threading.Tasks.Tests/System.Runtime.CompilerServices/YieldAwaitableTests.cs +++ b/src/libraries/System.Runtime/tests/System.Threading.Tasks.Tests/System.Runtime.CompilerServices/YieldAwaitableTests.cs @@ -43,7 +43,7 @@ public static void RunAsyncYieldAwaiterTests() try { ya.GetResult(); } catch { - Assert.Fail(string.Format("RunAsyncYieldAwaiterTests > FAILURE. YieldAwaiter.GetResult threw inappropriately")); + Assert.Fail("RunAsyncYieldAwaiterTests > FAILURE. YieldAwaiter.GetResult threw inappropriately"); } var mres = new ManualResetEventSlim(); Assert.False(ya.IsCompleted, "RunAsyncYieldAwaiterTests > FAILURE. YieldAwaiter.IsCompleted should always be false."); @@ -67,7 +67,7 @@ public static void RunAsyncYieldAwaiterTests() try { ya.GetResult(); } catch { - Assert.Fail(string.Format(" > FAILURE. YieldAwaiter.GetResult threw inappropriately")); + Assert.Fail(" > FAILURE. YieldAwaiter.GetResult threw inappropriately"); } var mres = new ManualResetEventSlim(); Assert.False(ya.IsCompleted, " > FAILURE. YieldAwaiter.IsCompleted should always be false."); @@ -79,7 +79,7 @@ public static void RunAsyncYieldAwaiterTests() mres.Wait(); ya.GetResult(); } - catch { Assert.Fail(string.Format(" > FAILURE. Unexpected exception from Yield")); } + catch { Assert.Fail(" > FAILURE. Unexpected exception from Yield"); } }, CancellationToken.None, TaskCreationOptions.None, new QUWITaskScheduler()).Wait(); } @@ -94,7 +94,7 @@ public static void RunAsyncYieldAwaiterTests() try { ya.GetResult(); } catch { - Assert.Fail(string.Format(" > FAILURE. YieldAwaiter.GetResult threw inappropriately")); + Assert.Fail(" > FAILURE. YieldAwaiter.GetResult threw inappropriately"); } var mres = new ManualResetEventSlim(); Assert.False(ya.IsCompleted, " > FAILURE. YieldAwaiter.IsCompleted should always be false."); @@ -106,7 +106,7 @@ public static void RunAsyncYieldAwaiterTests() mres.Wait(); ya.GetResult(); } - catch { Assert.Fail(string.Format(" > FAILURE. Unexpected exception from Yield")); } + catch { Assert.Fail(" > FAILURE. Unexpected exception from Yield"); } SynchronizationContext.SetSynchronizationContext(null); }, CancellationToken.None, TaskCreationOptions.None, new QUWITaskScheduler()).Wait(); } @@ -119,7 +119,7 @@ public static void RunAsyncYieldAwaiterTests() try { ya.GetResult(); } catch { - Assert.Fail(string.Format(" > FAILURE. YieldAwaiter.GetResult threw inappropriately")); + Assert.Fail(" > FAILURE. YieldAwaiter.GetResult threw inappropriately"); } var mres = new ManualResetEventSlim(); Assert.False(ya.IsCompleted, " > FAILURE. YieldAwaiter.IsCompleted should always be false."); diff --git a/src/libraries/System.Runtime/tests/System.Threading.Tasks.Tests/Task/TaskCancelWaitTest.cs b/src/libraries/System.Runtime/tests/System.Threading.Tasks.Tests/Task/TaskCancelWaitTest.cs index c057ae3db621bf..c2b2a30fe59d7c 100644 --- a/src/libraries/System.Runtime/tests/System.Threading.Tasks.Tests/Task/TaskCancelWaitTest.cs +++ b/src/libraries/System.Runtime/tests/System.Threading.Tasks.Tests/Task/TaskCancelWaitTest.cs @@ -258,25 +258,25 @@ private void VerifyCancel(TaskInfo current) if (current.Parent == null) { if (!ti.CancellationToken.IsCancellationRequested) - Assert.Fail(string.Format("Root task must be cancel-requested")); + Assert.Fail("Root task must be cancel-requested"); else if (_countdownEvent.IsSet && ti.Task.IsCanceled) - Assert.Fail(string.Format("Root task should not be cancelled when the whole tree has been created")); + Assert.Fail("Root task should not be cancelled when the whole tree has been created"); } else if (current.Parent.CancelChildren) { // need to make sure the parent task at least called .Cancel() on the child if (!ti.CancellationToken.IsCancellationRequested) - Assert.Fail(string.Format("Task which has been explicitly cancel-requested either by parent must have CancellationRequested set as true")); + Assert.Fail("Task which has been explicitly cancel-requested either by parent must have CancellationRequested set as true"); } else if (ti.IsRespectParentCancellation) { if (ti.CancellationToken.IsCancellationRequested != current.Parent.CancellationToken.IsCancellationRequested) - Assert.Fail(string.Format("Task with RespectParentCancellationcontract is broken")); + Assert.Fail("Task with RespectParentCancellationcontract is broken"); } else { if (ti.CancellationToken.IsCancellationRequested || ti.Task.IsCanceled) - Assert.Fail(string.Format("Inner non-directly canceled task which opts out RespectParentCancellationshould not be cancelled")); + Assert.Fail("Inner non-directly canceled task which opts out RespectParentCancellationshould not be cancelled"); } // verify IsCanceled indicate successfully dequeued based on the observing that @@ -303,7 +303,7 @@ private void VerifyWait(TaskInfo current) if ((ti.Option & TaskCreationOptions.AttachedToParent) != 0 && !ti.Task.IsCompleted) { - Assert.Fail(string.Format("Inner attached task must complete")); + Assert.Fail("Inner attached task must complete"); } } } @@ -365,7 +365,7 @@ private void VerifyResult(TaskInfo current) { //this means that the task was not scheduled - it was cancelled or it is still in the queue //-42 = UNINITIALED_RESULT - Assert.Fail(string.Format("Result must remain uninitialized for unstarted task")); + Assert.Fail("Result must remain uninitialized for unstarted task"); } else if (ti.Task.IsCompleted) { diff --git a/src/libraries/System.Runtime/tests/System.Threading.Tasks.Tests/Task/TaskContinueWhenAllTests.cs b/src/libraries/System.Runtime/tests/System.Threading.Tasks.Tests/Task/TaskContinueWhenAllTests.cs index 9f62d5343951ba..6a8d9ee5e9a1d9 100644 --- a/src/libraries/System.Runtime/tests/System.Threading.Tasks.Tests/Task/TaskContinueWhenAllTests.cs +++ b/src/libraries/System.Runtime/tests/System.Threading.Tasks.Tests/Task/TaskContinueWhenAllTests.cs @@ -857,7 +857,7 @@ private static void CheckForCorrectCT(Task canceledTask, CancellationToken corre try { canceledTask.Wait(); - Assert.Fail(string.Format(" > FAILED! Pre-canceled result did not throw from Wait()")); + Assert.Fail(" > FAILED! Pre-canceled result did not throw from Wait()"); } catch (AggregateException ae) { @@ -866,11 +866,11 @@ private static void CheckForCorrectCT(Task canceledTask, CancellationToken corre var tce = e as TaskCanceledException; if (tce == null) { - Assert.Fail(string.Format(" > FAILED! Pre-canceled result threw non-TCE from Wait()")); + Assert.Fail(" > FAILED! Pre-canceled result threw non-TCE from Wait()"); } else if (tce.CancellationToken != correctToken) { - Assert.Fail(string.Format(" > FAILED! Pre-canceled result threw TCE w/ wrong token")); + Assert.Fail(" > FAILED! Pre-canceled result threw TCE w/ wrong token"); } return true; diff --git a/src/libraries/System.Runtime/tests/System.Threading.Tasks.Tests/Task/TaskContinueWhenAnyTests.cs b/src/libraries/System.Runtime/tests/System.Threading.Tasks.Tests/Task/TaskContinueWhenAnyTests.cs index dd0df07d1d598a..6df5ba4c8b8fad 100644 --- a/src/libraries/System.Runtime/tests/System.Threading.Tasks.Tests/Task/TaskContinueWhenAnyTests.cs +++ b/src/libraries/System.Runtime/tests/System.Threading.Tasks.Tests/Task/TaskContinueWhenAnyTests.cs @@ -169,12 +169,12 @@ public static void RunContinueWhenAnyTests() { if (ex == null) { - Assert.Fail(string.Format("RunContinueWhenAnyTests: > FAILED! Expected AE from continuation.Wait() (no exception thrown)")); + Assert.Fail("RunContinueWhenAnyTests: > FAILED! Expected AE from continuation.Wait() (no exception thrown)"); ; } else if (ex.GetType() != typeof(AggregateException)) { - Assert.Fail(string.Format("RunContinueWhenAnyTests: > FAILED! Expected AE from continuation.Wait() (didn't throw aggregate exception)")); + Assert.Fail("RunContinueWhenAnyTests: > FAILED! Expected AE from continuation.Wait() (didn't throw aggregate exception)"); } else if (((AggregateException)ex).InnerException.GetType() != typeof(TaskCanceledException)) { @@ -490,7 +490,7 @@ private static void CheckForCorrectCT(Task canceledTask, CancellationToken corre try { canceledTask.Wait(); - Assert.Fail(string.Format(" > FAILED! Pre-canceled result did not throw from Wait()")); + Assert.Fail(" > FAILED! Pre-canceled result did not throw from Wait()"); } catch (AggregateException ae) { @@ -499,11 +499,11 @@ private static void CheckForCorrectCT(Task canceledTask, CancellationToken corre var tce = e as TaskCanceledException; if (tce == null) { - Assert.Fail(string.Format(" > FAILED! Pre-canceled result threw non-TCE from Wait()")); + Assert.Fail(" > FAILED! Pre-canceled result threw non-TCE from Wait()"); } else if (tce.CancellationToken != correctToken) { - Assert.Fail(string.Format(" > FAILED! Pre-canceled result threw TCE w/ wrong token")); + Assert.Fail(" > FAILED! Pre-canceled result threw TCE w/ wrong token"); } return true; diff --git a/src/libraries/System.Runtime/tests/System.Threading.Tasks.Tests/Task/TaskContinueWithAllAnyTests.cs b/src/libraries/System.Runtime/tests/System.Threading.Tasks.Tests/Task/TaskContinueWithAllAnyTests.cs index 8fab167f8dff67..e6d1a390e2e15f 100644 --- a/src/libraries/System.Runtime/tests/System.Threading.Tasks.Tests/Task/TaskContinueWithAllAnyTests.cs +++ b/src/libraries/System.Runtime/tests/System.Threading.Tasks.Tests/Task/TaskContinueWithAllAnyTests.cs @@ -350,7 +350,7 @@ internal void RealRun() // check continuation is non-blocking, i.e., it does not block until all/one tasks finish if (_continuation.Status != TaskStatus.WaitingForActivation) - Assert.Fail(string.Format("continuation task should be created when none task finish")); + Assert.Fail("continuation task should be created when none task finish"); // allow continuation to kick off later foreach (Task t in _tasks) @@ -448,7 +448,7 @@ private void VerifyAllT(Task[] inputTasks) private void VerifyAny(Task inputTask) { if (!inputTask.IsCompleted) - Assert.Fail(string.Format("ContinueWhenAny contract is broken -- none task has completed")); + Assert.Fail("ContinueWhenAny contract is broken -- none task has completed"); // do the sanity check against the input task @@ -464,7 +464,7 @@ private void VerifyAny(Task inputTask) } if (!found) - Assert.Fail(string.Format("input task do not exist in the expected original tasks")); + Assert.Fail("input task do not exist in the expected original tasks"); Verify(); } @@ -473,7 +473,7 @@ private void VerifyAny(Task inputTask) private void VerifyAnyT(Task inputTask) { if (!inputTask.IsCompleted) - Assert.Fail(string.Format("ContinueWhenAny contract is broken -- none task has completed")); + Assert.Fail("ContinueWhenAny contract is broken -- none task has completed"); // do the sanity check against the input task @@ -490,7 +490,7 @@ private void VerifyAnyT(Task inputTask) } if (!found) - Assert.Fail(string.Format("input task do not exist in the expected original tasks")); + Assert.Fail("input task do not exist in the expected original tasks"); Verify(); } @@ -568,7 +568,7 @@ private void Verify() //else if (ti.Thread == null && result != -1) //{ - // Assert.Fail(string.Format("Result must remain uninitialized for unstarted task")); + // Assert.Fail("Result must remain uninitialized for unstarted task"); //} } } diff --git a/src/libraries/System.Runtime/tests/System.Threading.Tasks.Tests/Task/TaskContinueWithTests.cs b/src/libraries/System.Runtime/tests/System.Threading.Tasks.Tests/Task/TaskContinueWithTests.cs index 4cb9d47ca4ec8c..940d1164a80864 100644 --- a/src/libraries/System.Runtime/tests/System.Threading.Tasks.Tests/Task/TaskContinueWithTests.cs +++ b/src/libraries/System.Runtime/tests/System.Threading.Tasks.Tests/Task/TaskContinueWithTests.cs @@ -204,20 +204,20 @@ public static void RunContinueWithParamsTest_Cancellation() if (c1b.Status != TaskStatus.Canceled) { - Assert.Fail(string.Format("RunContinueWithParamsTest: > FAILED. Continuation task w/NotOnCanceled should have been canceled when antecedent was canceled.")); + Assert.Fail("RunContinueWithParamsTest: > FAILED. Continuation task w/NotOnCanceled should have been canceled when antecedent was canceled."); } if (c1c.Status != TaskStatus.RanToCompletion) { - Assert.Fail(string.Format("RunContinueWithParamsTest: > FAILED. Continuation task w/ canceled antecedent should have run to completion.")); + Assert.Fail("RunContinueWithParamsTest: > FAILED. Continuation task w/ canceled antecedent should have run to completion."); } if (c2b.Status != TaskStatus.Canceled) { - Assert.Fail(string.Format("RunContinueWithParamsTest: > FAILED. Continuation task w/NotOnRanToCompletion should have been canceled when antecedent completed.")); + Assert.Fail("RunContinueWithParamsTest: > FAILED. Continuation task w/NotOnRanToCompletion should have been canceled when antecedent completed."); } c2c.Wait(); if (c2c.Status != TaskStatus.RanToCompletion) { - Assert.Fail(string.Format("RunContinueWithParamsTest: > FAILED. Continuation task w/ completed antecedent should have run to completion.")); + Assert.Fail("RunContinueWithParamsTest: > FAILED. Continuation task w/ completed antecedent should have run to completion."); } } @@ -229,14 +229,14 @@ public static void RunContinueWithParamsTest_IllegalArgs() try { Task t2 = t1.ContinueWith((ooo) => { }, (TaskContinuationOptions)0x1000000); - Assert.Fail(string.Format("RunContinueWithParamsTest: > FAILED. Should have seen exception from illegal continuation options.")); + Assert.Fail("RunContinueWithParamsTest: > FAILED. Should have seen exception from illegal continuation options."); } catch { } try { Task t2 = t1.ContinueWith((ooo) => { }, TaskContinuationOptions.LongRunning | TaskContinuationOptions.ExecuteSynchronously); - Assert.Fail(string.Format("RunContinueWithParamsTest: > FAILED. Should have seen exception when combining LongRunning and ExecuteSynchronously")); + Assert.Fail("RunContinueWithParamsTest: > FAILED. Should have seen exception when combining LongRunning and ExecuteSynchronously"); } catch { } @@ -246,7 +246,7 @@ public static void RunContinueWithParamsTest_IllegalArgs() TaskContinuationOptions.NotOnRanToCompletion | TaskContinuationOptions.NotOnFaulted | TaskContinuationOptions.NotOnCanceled); - Assert.Fail(string.Format("RunContinueWithParamsTest: > FAILED. Should have seen exception from illegal NotOnAny continuation options.")); + Assert.Fail("RunContinueWithParamsTest: > FAILED. Should have seen exception from illegal NotOnAny continuation options."); } catch (Exception) { } @@ -269,7 +269,7 @@ public static void RunContinuationCancelTest(bool useTimeSpan) CancellationTokenSource ctsForT2 = new CancellationTokenSource(); Task t2 = t1.ContinueWith((ContinuedTask) => { - Assert.Fail(string.Format("RunContinuationCancelTest: > Failed! t2 should not have run.")); + Assert.Fail("RunContinuationCancelTest: > Failed! t2 should not have run."); }, ctsForT2.Token); Task t3 = t2.ContinueWith((ContinuedTask) => @@ -297,12 +297,12 @@ public static void RunContinuationCancelTest(bool useTimeSpan) if (!t1Ran) { - Assert.Fail(string.Format("RunContinuationCancelTest: > Failed! t1 should have run.")); + Assert.Fail("RunContinuationCancelTest: > Failed! t1 should have run."); } if (!t3Ran) { - Assert.Fail(string.Format("RunContinuationCancelTest: > Failed! t3 should have run.")); + Assert.Fail("RunContinuationCancelTest: > Failed! t3 should have run."); } } @@ -753,7 +753,7 @@ public static void RunUnwrapTests() //try //{ // hanging1.Wait(); - // Assert.Fail(string.Format(" > FAILED. Expected an exception.")); + // Assert.Fail(" > FAILED. Expected an exception."); // return false; //} //catch (Exception e) { } @@ -778,7 +778,7 @@ public static void RunUnwrapTests() //try //{ // hanging2.Wait(); - // Assert.Fail(string.Format(" > FAILED. Expected an exception.")); + // Assert.Fail(" > FAILED. Expected an exception."); // return false; //} //catch (Exception e) { } @@ -871,7 +871,7 @@ public static void RunUnwrapTests_ExceptionTests() try { c.Wait(); - Assert.Fail(string.Format("RunUnwrapTests: > FAILED. Monadic continuation w/ excepted children failed to throw an exception.")); + Assert.Fail("RunUnwrapTests: > FAILED. Monadic continuation w/ excepted children failed to throw an exception."); } catch (AggregateException ae) { @@ -949,7 +949,7 @@ public static void RunUnwrapTests_CancellationTests() try { c1.Wait(); - Assert.Fail(string.Format("RunUnwrapTests: > FAILED. Expected Wait() to throw after cancellation of Task->Task.")); + Assert.Fail("RunUnwrapTests: > FAILED. Expected Wait() to throw after cancellation of Task->Task."); } catch { } TaskStatus ts = c1.Status; @@ -962,7 +962,7 @@ public static void RunUnwrapTests_CancellationTests() try { c2.Wait(); - Assert.Fail(string.Format("RunUnwrapTests: > FAILED. Expected Wait() to throw after cancellation of Task->Task.")); + Assert.Fail("RunUnwrapTests: > FAILED. Expected Wait() to throw after cancellation of Task->Task."); } catch { } ts = c2.Status; @@ -975,7 +975,7 @@ public static void RunUnwrapTests_CancellationTests() try { c5.Wait(); - Assert.Fail(string.Format("RunUnwrapTests: > FAILED. Expected Wait() to throw after cancellation of Task->Task.")); + Assert.Fail("RunUnwrapTests: > FAILED. Expected Wait() to throw after cancellation of Task->Task."); } catch { } ts = c5.Status; @@ -988,7 +988,7 @@ public static void RunUnwrapTests_CancellationTests() try { c6.Wait(); - Assert.Fail(string.Format("RunUnwrapTests: > FAILED. Expected Wait() to throw after cancellation of Task->Task.")); + Assert.Fail("RunUnwrapTests: > FAILED. Expected Wait() to throw after cancellation of Task->Task."); } catch { } ts = c6.Status; @@ -1015,22 +1015,22 @@ public static void RunUnwrapTests_CancellationTests() if (c1val != 0) { - Assert.Fail(string.Format("RunUnwrapTests: > FAILED. Cancellation of Task->Task failed to stop internal continuation")); + Assert.Fail("RunUnwrapTests: > FAILED. Cancellation of Task->Task failed to stop internal continuation"); } if (c2val != 0) { - Assert.Fail(string.Format("RunUnwrapTests: > FAILED. Cancellation of Task->Task failed to stop internal continuation")); + Assert.Fail("RunUnwrapTests: > FAILED. Cancellation of Task->Task failed to stop internal continuation"); } if (c5val != 0) { - Assert.Fail(string.Format("RunUnwrapTests: > FAILED. Cancellation of Task->Task failed to stop internal continuation")); + Assert.Fail("RunUnwrapTests: > FAILED. Cancellation of Task->Task failed to stop internal continuation"); } if (c6val != 0) { - Assert.Fail(string.Format("RunUnwrapTests: > FAILED. Cancellation of Task->Task failed to stop internal continuation")); + Assert.Fail("RunUnwrapTests: > FAILED. Cancellation of Task->Task failed to stop internal continuation"); } } @@ -1046,7 +1046,7 @@ public static void RunContinuationCancelTest_State() CancellationTokenSource ctsForT2 = new CancellationTokenSource(); Task t2 = t1.ContinueWith((ContinuedTask, obj) => { - Assert.Fail(string.Format("RunContinuationCancelTest_State > Failed! t2 should not have run.")); + Assert.Fail("RunContinuationCancelTest_State > Failed! t2 should not have run."); }, stateParam, ctsForT2.Token); @@ -1066,12 +1066,12 @@ public static void RunContinuationCancelTest_State() if (!t1Ran) { - Assert.Fail(string.Format("RunContinuationCancelTest_State > Failed! t1 should have run.")); + Assert.Fail("RunContinuationCancelTest_State > Failed! t1 should have run."); } if (!t3Ran) { - Assert.Fail(string.Format("RunContinuationCancelTest_State > Failed! t3 should have run.")); + Assert.Fail("RunContinuationCancelTest_State > Failed! t3 should have run."); } } diff --git a/src/libraries/System.Runtime/tests/System.Threading.Tasks.Tests/Task/TaskContinueWith_ContFuncAndActionWithArgsTests.cs b/src/libraries/System.Runtime/tests/System.Threading.Tasks.Tests/Task/TaskContinueWith_ContFuncAndActionWithArgsTests.cs index 00c34e5727ebd3..b24259d52c847b 100644 --- a/src/libraries/System.Runtime/tests/System.Threading.Tasks.Tests/Task/TaskContinueWith_ContFuncAndActionWithArgsTests.cs +++ b/src/libraries/System.Runtime/tests/System.Threading.Tasks.Tests/Task/TaskContinueWith_ContFuncAndActionWithArgsTests.cs @@ -222,7 +222,7 @@ public static void RunContinueWithPreCancelTests_State() try { c2.Wait(); - Assert.Fail(string.Format("RunContinueWithPreCancelTests_State: Expected c2.Wait to throw AE/TCE")); + Assert.Fail("RunContinueWithPreCancelTests_State: Expected c2.Wait to throw AE/TCE"); } catch (Exception ex) { @@ -237,7 +237,7 @@ public static void RunContinueWithPreCancelTests_State() try { c4.Wait(); - Assert.Fail(string.Format("RunContinueWithPreCancelTests_State: Expected c4.Wait to throw AE/TCE")); + Assert.Fail("RunContinueWithPreCancelTests_State: Expected c4.Wait to throw AE/TCE"); } catch (Exception ex) { @@ -318,7 +318,7 @@ public static void RunContinueWithOnDisposedTaskTest_State() } catch { - Assert.Fail(string.Format("RunContinueWithOnDisposedTaskTest_State: > FAILED! should NOT have seen an exception.")); + Assert.Fail("RunContinueWithOnDisposedTaskTest_State: > FAILED! should NOT have seen an exception."); } } @@ -355,20 +355,20 @@ public static void RunContinueWithParamsTest_State_Cancellation() if (c1b.Status != TaskStatus.Canceled) { - Assert.Fail(string.Format("RunContinueWithParamsTest_State > FAILED. Continuation task w/NotOnCanceled should have been canceled when antecedent was canceled.")); + Assert.Fail("RunContinueWithParamsTest_State > FAILED. Continuation task w/NotOnCanceled should have been canceled when antecedent was canceled."); } if (c1c.Status != TaskStatus.RanToCompletion) { - Assert.Fail(string.Format("RunContinueWithParamsTest_State > FAILED. Continuation task w/ canceled antecedent should have run to completion.")); + Assert.Fail("RunContinueWithParamsTest_State > FAILED. Continuation task w/ canceled antecedent should have run to completion."); } if (c2b.Status != TaskStatus.Canceled) { - Assert.Fail(string.Format("RunContinueWithParamsTest_State > FAILED. Continuation task w/NotOnRanToCompletion should have been canceled when antecedent completed.")); + Assert.Fail("RunContinueWithParamsTest_State > FAILED. Continuation task w/NotOnRanToCompletion should have been canceled when antecedent completed."); } c2c.Wait(); if (c2c.Status != TaskStatus.RanToCompletion) { - Assert.Fail(string.Format("RunContinueWithParamsTest_State > FAILED. Continuation task w/ completed antecedent should have run to completion.")); + Assert.Fail("RunContinueWithParamsTest_State > FAILED. Continuation task w/ completed antecedent should have run to completion."); } } @@ -381,14 +381,14 @@ public static void RunContinueWithParamsTest_State_IllegalParameters() try { Task t2 = t1.ContinueWith((ooo, obj) => { }, stateParam, (TaskContinuationOptions)0x1000000); - Assert.Fail(string.Format("RunContinueWithParamsTest_State > FAILED. Should have seen exception from illegal continuation options.")); + Assert.Fail("RunContinueWithParamsTest_State > FAILED. Should have seen exception from illegal continuation options."); } catch { } try { Task t2 = t1.ContinueWith((ooo, obj) => { }, stateParam, TaskContinuationOptions.LongRunning | TaskContinuationOptions.ExecuteSynchronously); - Assert.Fail(string.Format("RunContinueWithParamsTest_State > FAILED. Should have seen exception when combining LongRunning and ExecuteSynchronously")); + Assert.Fail("RunContinueWithParamsTest_State > FAILED. Should have seen exception when combining LongRunning and ExecuteSynchronously"); } catch { } @@ -398,7 +398,7 @@ public static void RunContinueWithParamsTest_State_IllegalParameters() TaskContinuationOptions.NotOnRanToCompletion | TaskContinuationOptions.NotOnFaulted | TaskContinuationOptions.NotOnCanceled); - Assert.Fail(string.Format("RunContinueWithParamsTest_State > FAILED. Should have seen exception from illegal NotOnAny continuation options.")); + Assert.Fail("RunContinueWithParamsTest_State > FAILED. Should have seen exception from illegal NotOnAny continuation options."); } catch (Exception) { diff --git a/src/libraries/System.Runtime/tests/System.Threading.Tasks.Tests/Task/TaskCreateTest.cs b/src/libraries/System.Runtime/tests/System.Threading.Tasks.Tests/Task/TaskCreateTest.cs index dc978a88d9c01e..1b18aa70827f7e 100644 --- a/src/libraries/System.Runtime/tests/System.Threading.Tasks.Tests/Task/TaskCreateTest.cs +++ b/src/libraries/System.Runtime/tests/System.Threading.Tasks.Tests/Task/TaskCreateTest.cs @@ -935,7 +935,7 @@ internal void CreateTask() _cts.Cancel(); if (!_task.IsCanceled || _task.Status != TaskStatus.Canceled) - Assert.Fail(string.Format("Task Token doesn't matched TokenSource's Token")); + Assert.Fail("Task Token doesn't matched TokenSource's Token"); } } @@ -1246,7 +1246,7 @@ internal void ExceptionTests() { TaskCompletionSource f = new TaskCompletionSource(); f.Task.Start(); - Assert.Fail(string.Format("Able to Start a Promise, when expecting exception")); + Assert.Fail("Able to Start a Promise, when expecting exception"); } catch (System.InvalidOperationException) { @@ -1260,7 +1260,7 @@ internal void ExceptionTests() { Task t = CreateTaskHelper().ContinueWith(delegate { Work(); }); t.Start(); - Assert.Fail(string.Format("Able to start task manually on ContinueWith Task, when expecting exception")); + Assert.Fail("Able to start task manually on ContinueWith Task, when expecting exception"); } catch (InvalidOperationException) { diff --git a/src/libraries/System.Runtime/tests/System.Threading.Tasks.Tests/Task/TaskFromAsyncTest.cs b/src/libraries/System.Runtime/tests/System.Threading.Tasks.Tests/Task/TaskFromAsyncTest.cs index b29c2c2ed7596c..db61aa033712fa 100644 --- a/src/libraries/System.Runtime/tests/System.Threading.Tasks.Tests/Task/TaskFromAsyncTest.cs +++ b/src/libraries/System.Runtime/tests/System.Threading.Tasks.Tests/Task/TaskFromAsyncTest.cs @@ -71,7 +71,7 @@ internal void RealRun() //In case of error conditions we except the method to throw exception RunAPMTest(); - Assert.Fail(string.Format("Failed to catch ArgumentNullException")); + Assert.Fail("Failed to catch ArgumentNullException"); } catch (ArgumentNullException) { @@ -96,7 +96,7 @@ internal void RealRun() } else { - Assert.Fail(string.Format("Failed to catch AggregateException")); + Assert.Fail("Failed to catch AggregateException"); } } else @@ -117,18 +117,18 @@ internal void RealRun() expectedOption = TestOption; if (_task.CreationOptions != expectedOption) - Assert.Fail(string.Format("task is not created with expected TestOption")); + Assert.Fail("task is not created with expected TestOption"); if (((TaskOptionAndScheduler)(work.ObservedState)).Option != expectedOption) - Assert.Fail(string.Format("state verification failed on Option")); + Assert.Fail("state verification failed on Option"); TaskScheduler expectedScheduler = TaskScheduler.Default; if (work.ObservedTaskScheduler != expectedScheduler) - Assert.Fail(string.Format("task is not running under expected TestOption")); + Assert.Fail("task is not running under expected TestOption"); if (((TaskOptionAndScheduler)(work.ObservedState)).Scheduler != expectedScheduler) - Assert.Fail(string.Format("state verification failed on Scheduler")); + Assert.Fail("state verification failed on Scheduler"); } } diff --git a/src/libraries/System.Runtime/tests/System.Threading.Tasks.Tests/Task/TaskRtTests.cs b/src/libraries/System.Runtime/tests/System.Threading.Tasks.Tests/Task/TaskRtTests.cs index c9657d3e5d5dfc..2219c58c6b795c 100644 --- a/src/libraries/System.Runtime/tests/System.Threading.Tasks.Tests/Task/TaskRtTests.cs +++ b/src/libraries/System.Runtime/tests/System.Threading.Tasks.Tests/Task/TaskRtTests.cs @@ -201,7 +201,7 @@ public static void RunRunTests_FastPathTests() try { fastPath1.Wait(); - Assert.Fail(string.Format("RunRunTests: > FAILURE: Expected proxy for already-faulted Task to throw on Wait()")); + Assert.Fail("RunRunTests: > FAILURE: Expected proxy for already-faulted Task to throw on Wait()"); } catch { } Assert.True(fastPath1.Status == TaskStatus.Faulted, "Expected proxy for already-faulted task to be in Faulted status"); @@ -210,7 +210,7 @@ public static void RunRunTests_FastPathTests() try { fastPath1.Wait(); - Assert.Fail(string.Format("RunRunTests: > FAILURE: Expected proxy for already-canceled Task to throw on Wait()")); + Assert.Fail("RunRunTests: > FAILURE: Expected proxy for already-canceled Task to throw on Wait()"); } catch { } Assert.True(fastPath1.Status == TaskStatus.Canceled, "RunRunTests: Expected proxy for already-canceled task to be in Canceled status"); @@ -238,7 +238,7 @@ public static void RunRunTests_FastPathTests() try { fastPath1.Wait(); - Assert.Fail(string.Format("RunRunTests: > FAILURE: Expected proxy for already-faulted future to throw on Wait()")); + Assert.Fail("RunRunTests: > FAILURE: Expected proxy for already-faulted future to throw on Wait()"); } catch { } Assert.True(fastPath1.Status == TaskStatus.Faulted, "Expected proxy for already-faulted future to be in Faulted status"); @@ -247,7 +247,7 @@ public static void RunRunTests_FastPathTests() try { fastPath1.Wait(); - Assert.Fail(string.Format("RunRunTests: > FAILURE: Expected proxy for already-canceled future to throw on Wait()")); + Assert.Fail("RunRunTests: > FAILURE: Expected proxy for already-canceled future to throw on Wait()"); } catch { } Assert.True(fastPath1.Status == TaskStatus.Canceled, "RunRunTests: Expected proxy for already-canceled future to be in Canceled status"); diff --git a/src/libraries/System.Runtime/tests/System.Threading.Tasks.Tests/Task/TaskRtTests_Core.cs b/src/libraries/System.Runtime/tests/System.Threading.Tasks.Tests/Task/TaskRtTests_Core.cs index 1225ca6433a291..d133ae78a57d11 100644 --- a/src/libraries/System.Runtime/tests/System.Threading.Tasks.Tests/Task/TaskRtTests_Core.cs +++ b/src/libraries/System.Runtime/tests/System.Threading.Tasks.Tests/Task/TaskRtTests_Core.cs @@ -256,32 +256,32 @@ public static void RunTaskCompletionSourceTests_SetException() } if (tcs.TrySetResult(15)) { - Assert.Fail(string.Format("RunTaskCompletionSourceTests: > Error! Set exception, canceled, TrySetResult succeeded")); + Assert.Fail("RunTaskCompletionSourceTests: > Error! Set exception, canceled, TrySetResult succeeded"); } if (tcs.TrySetException(new Exception("blah"))) { - Assert.Fail(string.Format("RunTaskCompletionSourceTests: > Error! Set exception, canceled, TrySetException succeeded")); + Assert.Fail("RunTaskCompletionSourceTests: > Error! Set exception, canceled, TrySetException succeeded"); } if (tcs.TrySetCanceled()) { - Assert.Fail(string.Format("RunTaskCompletionSourceTests: > Error! Set exception, canceled, TrySetCanceled succeeded")); + Assert.Fail("RunTaskCompletionSourceTests: > Error! Set exception, canceled, TrySetCanceled succeeded"); } try { tcs.SetResult(10); - Assert.Fail(string.Format("RunTaskCompletionSourceTests: > Error! Set exception, Canceled, no exception on setting result")); + Assert.Fail("RunTaskCompletionSourceTests: > Error! Set exception, Canceled, no exception on setting result"); } catch { } try { tcs.SetException(new Exception("bar")); - Assert.Fail(string.Format("RunTaskCompletionSourceTests: > Error! Set exception, Canceled, no exception on re-setting exception")); + Assert.Fail("RunTaskCompletionSourceTests: > Error! Set exception, Canceled, no exception on re-setting exception"); } catch { } try { tcs.SetCanceled(); - Assert.Fail(string.Format("RunTaskCompletionSourceTests: > Error! Set exception, Canceled, no exception on Cancel")); + Assert.Fail("RunTaskCompletionSourceTests: > Error! Set exception, Canceled, no exception on Cancel"); } catch { } if (tcs.Task.Status != TaskStatus.Faulted) @@ -291,7 +291,7 @@ public static void RunTaskCompletionSourceTests_SetException() try { tcs.Task.Wait(); - Assert.Fail(string.Format("RunTaskCompletionSourceTests: > Error! Set exception, Wait()-ed, expected exception, got none.")); + Assert.Fail("RunTaskCompletionSourceTests: > Error! Set exception, Wait()-ed, expected exception, got none."); } catch { } } @@ -303,7 +303,7 @@ public static void RunTaskCompletionSourceTests_SetException() tcs.TrySetException(new Exception[] { new Exception("Exception A"), new Exception("Exception B") }); if (!succeeded) { - Assert.Fail(string.Format("RunTaskCompletionSourceTests: > Error! TrySetException() attempt did not succeed")); + Assert.Fail("RunTaskCompletionSourceTests: > Error! TrySetException() attempt did not succeed"); } if (tcs.Task.Status != TaskStatus.Faulted) { @@ -329,7 +329,7 @@ public static void RunTaskCompletionSourceTests_SetException() try { tcs.TrySetException(new Exception[] { new Exception("Exception A"), null }); - Assert.Fail(string.Format("RunTaskCompletionSourceTests: > Error! TrySetException() with null array element should have thrown an exception")); + Assert.Fail("RunTaskCompletionSourceTests: > Error! TrySetException() with null array element should have thrown an exception"); } catch (ArgumentException) { } catch (Exception e) @@ -341,7 +341,7 @@ public static void RunTaskCompletionSourceTests_SetException() try { tcs.TrySetException((IEnumerable)null); - Assert.Fail(string.Format("RunTaskCompletionSourceTests: > Error! TrySetException() with null IEnumerable should have thrown an exception")); + Assert.Fail("RunTaskCompletionSourceTests: > Error! TrySetException() with null IEnumerable should have thrown an exception"); } catch (ArgumentNullException) { } catch (Exception e) @@ -353,7 +353,7 @@ public static void RunTaskCompletionSourceTests_SetException() try { tcs.TrySetException(new Exception[0]); - Assert.Fail(string.Format("RunTaskCompletionSourceTests: > Error! TrySetException() with no elements should have thrown an exception")); + Assert.Fail("RunTaskCompletionSourceTests: > Error! TrySetException() with no elements should have thrown an exception"); } catch (ArgumentException) { } catch (Exception e) @@ -366,7 +366,7 @@ public static void RunTaskCompletionSourceTests_SetException() try { tcs.TrySetException((Exception)null); - Assert.Fail(string.Format("RunTaskCompletionSourceTests: > Error! TrySetException() with null Exception should have thrown an exception")); + Assert.Fail("RunTaskCompletionSourceTests: > Error! TrySetException() with null Exception should have thrown an exception"); } catch (ArgumentNullException) { } catch (Exception e) @@ -378,7 +378,7 @@ public static void RunTaskCompletionSourceTests_SetException() try { tcs.SetException((Exception)null); - Assert.Fail(string.Format("RunTaskCompletionSourceTests: > Error! SetException() with null Exception should have thrown an exception")); + Assert.Fail("RunTaskCompletionSourceTests: > Error! SetException() with null Exception should have thrown an exception"); } catch (ArgumentNullException) { } catch (Exception e) @@ -418,7 +418,7 @@ public static void RunTaskCompletionSourceTests_CancellationTests() if (tcs.Task.Status == TaskStatus.Canceled) { - Assert.Fail(string.Format("RunTaskCompletionSourceTests: > Error! Task Canceled, Should not have seen status = Canceled, did")); + Assert.Fail("RunTaskCompletionSourceTests: > Error! Task Canceled, Should not have seen status = Canceled, did"); } tcs.SetCanceled(); // cancel it for real if (tcs.Task.Status != TaskStatus.Canceled) @@ -427,38 +427,38 @@ public static void RunTaskCompletionSourceTests_CancellationTests() } if (tcs.TrySetException(new Exception("spam"))) { - Assert.Fail(string.Format("RunTaskCompletionSourceTests: > Error! Canceled, TrySetException succeeded")); + Assert.Fail("RunTaskCompletionSourceTests: > Error! Canceled, TrySetException succeeded"); } if (tcs.TrySetResult(10)) { - Assert.Fail(string.Format("RunTaskCompletionSourceTests: > Error! Canceled, TrySetResult succeeded")); + Assert.Fail("RunTaskCompletionSourceTests: > Error! Canceled, TrySetResult succeeded"); } if (tcs.TrySetCanceled()) { - Assert.Fail(string.Format("RunTaskCompletionSourceTests: > Error! Canceled, TrySetCanceled succeeded")); + Assert.Fail("RunTaskCompletionSourceTests: > Error! Canceled, TrySetCanceled succeeded"); } try { tcs.SetResult(15); - Assert.Fail(string.Format("RunTaskCompletionSourceTests: > Error! Canceled, no exception on setting Result")); + Assert.Fail("RunTaskCompletionSourceTests: > Error! Canceled, no exception on setting Result"); } catch { } try { tcs.SetException(new Exception("yet another exception")); - Assert.Fail(string.Format("RunTaskCompletionSourceTests: > Error! Canceled, no exception on setting Exception")); + Assert.Fail("RunTaskCompletionSourceTests: > Error! Canceled, no exception on setting Exception"); } catch { } try { tcs.SetCanceled(); - Assert.Fail(string.Format("RunTaskCompletionSourceTests: > Error! Canceled, no exception on re-Cancel")); + Assert.Fail("RunTaskCompletionSourceTests: > Error! Canceled, no exception on re-Cancel"); } catch { } try { int i = tcs.Task.Result; - Assert.Fail(string.Format("RunTaskCompletionSourceTests: > Error! Canceled, but get-Result threw no exception")); + Assert.Fail("RunTaskCompletionSourceTests: > Error! Canceled, but get-Result threw no exception"); } catch { } @@ -475,7 +475,7 @@ public static void RunTaskCreateTests() try { Task t = new Task(delegate { }, (TaskCreationOptions)0x100); - Assert.Fail(string.Format("RunTaskCreateTests: > FAILED! Failed to throw exception on use of internal TCO")); + Assert.Fail("RunTaskCreateTests: > FAILED! Failed to throw exception on use of internal TCO"); } catch { } } @@ -765,44 +765,44 @@ public static void RunBasicFutureTest() TaskCompletionSource tcs = new TaskCompletionSource(); if (((IAsyncResult)tcs.Task).AsyncState != null) { - Assert.Fail(string.Format("RunBasicFutureTest - TaskCompletionSource: > FAILED! non-null state when not spec'd in empty tcs ctor")); + Assert.Fail("RunBasicFutureTest - TaskCompletionSource: > FAILED! non-null state when not spec'd in empty tcs ctor"); } if (tcs.Task.CreationOptions != TaskCreationOptions.None) { - Assert.Fail(string.Format("RunBasicFutureTest - TaskCompletionSource: > FAILED! non-None TCO in tcs ctor when not spec'd in empty ctor")); + Assert.Fail("RunBasicFutureTest - TaskCompletionSource: > FAILED! non-None TCO in tcs ctor when not spec'd in empty ctor"); } tcs.SetResult(10); tcs = new TaskCompletionSource(testOptions); if (tcs.Task.CreationOptions != testOptions) { - Assert.Fail(string.Format("RunBasicFutureTest - TaskCompletionSource: > FAILED! TCO in tcs ctor not persistent")); + Assert.Fail("RunBasicFutureTest - TaskCompletionSource: > FAILED! TCO in tcs ctor not persistent"); } if (((IAsyncResult)tcs.Task).AsyncState != null) { - Assert.Fail(string.Format("RunBasicFutureTest - TaskCompletionSource: > FAILED! non-null state when not spec'd in tcs ctor")); + Assert.Fail("RunBasicFutureTest - TaskCompletionSource: > FAILED! non-null state when not spec'd in tcs ctor"); } tcs.SetResult(10); tcs = new TaskCompletionSource(testState); if (((IAsyncResult)tcs.Task).AsyncState != testState) { - Assert.Fail(string.Format("RunBasicFutureTest - TaskCompletionSource: > FAILED! state in tcs ctor not persistent")); + Assert.Fail("RunBasicFutureTest - TaskCompletionSource: > FAILED! state in tcs ctor not persistent"); } if (tcs.Task.CreationOptions != TaskCreationOptions.None) { - Assert.Fail(string.Format("RunBasicFutureTest - TaskCompletionSource: > FAILED! non-None TCO in tcs ctor when not spec'd in ctor")); + Assert.Fail("RunBasicFutureTest - TaskCompletionSource: > FAILED! non-None TCO in tcs ctor when not spec'd in ctor"); } tcs.SetResult(10); tcs = new TaskCompletionSource(testState, testOptions); if (tcs.Task.CreationOptions != testOptions) { - Assert.Fail(string.Format("RunBasicFutureTest - TaskCompletionSource: > FAILED! TCO with state in tcs ctor not persistent")); + Assert.Fail("RunBasicFutureTest - TaskCompletionSource: > FAILED! TCO with state in tcs ctor not persistent"); } if (((IAsyncResult)tcs.Task).AsyncState != testState) { - Assert.Fail(string.Format("RunBasicFutureTest - TaskCompletionSource: > FAILED! state with options in tcs ctor not persistent")); + Assert.Fail("RunBasicFutureTest - TaskCompletionSource: > FAILED! state with options in tcs ctor not persistent"); } tcs.SetResult(10); } @@ -872,24 +872,24 @@ public static void RunBasicFutureTest_PromiseTestsAndCancellation() if (promise2.Task.Result != 5678) { - Assert.Fail(string.Format("RunBasicFutureTest - Promise Test: > error: Promise value unblocked, but wrong value was read")); + Assert.Fail("RunBasicFutureTest - Promise Test: > error: Promise value unblocked, but wrong value was read"); } if (cancellationExceptionReceived == false || someotherExceptionReceived == true) { - Assert.Fail(string.Format("RunBasicFutureTest - Promise Test: > error: Cancel()ed promise didn't throw TaskCanceledException on value accessor")); + Assert.Fail("RunBasicFutureTest - Promise Test: > error: Cancel()ed promise didn't throw TaskCanceledException on value accessor"); } if (unexpectedStateObserved) { - Assert.Fail(string.Format("RunBasicFutureTest - Promise Test: > error: unexpected state observed in Promise test")); + Assert.Fail("RunBasicFutureTest - Promise Test: > error: unexpected state observed in Promise test"); } // Creating a TCS with a promise-style constructor that only allows TaskCreationOptions.AttachedToParent try { TaskCompletionSource tcs = new TaskCompletionSource(TaskCreationOptions.PreferFairness); - Assert.Fail(string.Format("RunBasicFutureTest - TaskCompletionSource: > FAILED! illegal tcs ctor TCO did not cause exception")); + Assert.Fail("RunBasicFutureTest - TaskCompletionSource: > FAILED! illegal tcs ctor TCO did not cause exception"); } catch (ArgumentOutOfRangeException) { @@ -915,7 +915,7 @@ public static void RunSynchronouslyTest() try { t1.RunSynchronously(); - Assert.Fail(string.Format("RunSynchronouslyTest: > error: Should have thrown an exception")); + Assert.Fail("RunSynchronouslyTest: > error: Should have thrown an exception"); } catch (InvalidOperationException) { @@ -933,7 +933,7 @@ public static void RunSynchronouslyTest() try { t2.RunSynchronously(); - Assert.Fail(string.Format("RunSynchronouslyTest - continuation task: > error: Should have thrown an exception")); + Assert.Fail("RunSynchronouslyTest - continuation task: > error: Should have thrown an exception"); } catch (InvalidOperationException) { @@ -951,7 +951,7 @@ public static void RunSynchronouslyTest() try { f1.RunSynchronously(); - Assert.Fail(string.Format("RunSynchronouslyTest - promise-style Task: > error: Should have thrown an exception")); + Assert.Fail("RunSynchronouslyTest - promise-style Task: > error: Should have thrown an exception"); } catch (InvalidOperationException) { @@ -981,12 +981,12 @@ public static void CoreRunSynchronouslyTest() t.RunSynchronously(); if (!bExecuted || t.Status != TaskStatus.RanToCompletion) { - Assert.Fail(string.Format("CoreRunSynchronouslyTest: > error: task invoked through RunSynchronously() didn't execute or ended up in wrong state")); + Assert.Fail("CoreRunSynchronouslyTest: > error: task invoked through RunSynchronously() didn't execute or ended up in wrong state"); } if (observedTaskscheduler != TaskScheduler.Current) { - Assert.Fail(string.Format("CoreRunSynchronouslyTest: > error: task invoked through RunSynchronously() didn't observe correct TaskScheduler.Current")); + Assert.Fail("CoreRunSynchronouslyTest: > error: task invoked through RunSynchronously() didn't observe correct TaskScheduler.Current"); } // Wait() should work on a task that was RunSynchronously() @@ -994,12 +994,12 @@ public static void CoreRunSynchronouslyTest() { if (!t.Wait(500)) { - Assert.Fail(string.Format("CoreRunSynchronouslyTest: > error: Wait timed out on a task which was previously RunSynchronously()")); + Assert.Fail("CoreRunSynchronouslyTest: > error: Wait timed out on a task which was previously RunSynchronously()"); } } catch { - Assert.Fail(string.Format("CoreRunSynchronouslyTest: > error: Wait threw on a task which was previously RunSynchronously()")); + Assert.Fail("CoreRunSynchronouslyTest: > error: Wait threw on a task which was previously RunSynchronously()"); } } @@ -1019,7 +1019,7 @@ public static void CoreRunSynchronouslyTest_NegativeTests() try { t.Start(); - Assert.Fail(string.Format("CoreRunSynchronouslyTest: > error: Start() should have thrown on a task which was previously RunSynchronously()")); + Assert.Fail("CoreRunSynchronouslyTest: > error: Start() should have thrown on a task which was previously RunSynchronously()"); } catch { } @@ -1028,7 +1028,7 @@ public static void CoreRunSynchronouslyTest_NegativeTests() try { t.RunSynchronously(); - Assert.Fail(string.Format("CoreRunSynchronouslyTest: > error: RunSynchronously() should have thrown on a task which was previously started")); + Assert.Fail("CoreRunSynchronouslyTest: > error: RunSynchronously() should have thrown on a task which was previously started"); } catch { } @@ -1043,14 +1043,14 @@ public static void CoreRunSynchronouslyTest_NegativeTests() } catch { - Assert.Fail(string.Format("CoreRunSynchronouslyTest: > error: RunSynchronously() should not have thrown itself on exceptional task")); + Assert.Fail("CoreRunSynchronouslyTest: > error: RunSynchronously() should not have thrown itself on exceptional task"); } try { t.Wait(); - Assert.Fail(string.Format("CoreRunSynchronouslyTest: > error: Wait() should not have thrown on exceptional task invoked through RunSynchronously()")); + Assert.Fail("CoreRunSynchronouslyTest: > error: Wait() should not have thrown on exceptional task invoked through RunSynchronously()"); } catch { } @@ -1067,12 +1067,12 @@ public static void RunTaskExceptionTest() var e2 = t.Exception; if (e2 != null) { - Assert.Fail(string.Format("RunTaskExceptionTest: > error: non-null Exception from cleanly completed task.")); + Assert.Fail("RunTaskExceptionTest: > error: non-null Exception from cleanly completed task."); } } catch { - Assert.Fail(string.Format("RunTaskExceptionTest: > error: exception thrown when trying to retrieve Exception from cleanly completed task.")); + Assert.Fail("RunTaskExceptionTest: > error: exception thrown when trying to retrieve Exception from cleanly completed task."); } ManualResetEvent mre = new ManualResetEvent(false); ManualResetEvent mre2 = new ManualResetEvent(false); @@ -1092,7 +1092,7 @@ public static void RunTaskExceptionTest() if (outer.Exception != null) { - Assert.Fail(string.Format("RunTaskExceptionTest: > FAILED. Task.Exception seen before task completes")); + Assert.Fail("RunTaskExceptionTest: > FAILED. Task.Exception seen before task completes"); } mre.Set(); // Allow inner to finish try { outer.Wait(); } @@ -1111,7 +1111,7 @@ public static void RunTaskExceptionTest() return; } - Assert.Fail(string.Format("RunTaskExceptionTest: > error: expected an AggregateException w/ a single InnerException to be thrown")); + Assert.Fail("RunTaskExceptionTest: > error: expected an AggregateException w/ a single InnerException to be thrown"); } private static int NestedLevels(Exception e) @@ -1167,7 +1167,7 @@ public static void RunTaskWaitAnyTests() if (Task.WaitAny(t2, t1, t3, t4) != 1) { - Assert.Fail(string.Format("RunTaskWaitAnyTests: > FAILED pre-completed task test. Wrong index returned.")); + Assert.Fail("RunTaskWaitAnyTests: > FAILED pre-completed task test. Wrong index returned."); } } @@ -1236,14 +1236,14 @@ private static void CoreWaitAnyTest(int fillerTasks, bool[] finishMeFirst, int n { Debug.WriteLine("CoreWaitAnyTest: Testing WaitAny with {0} tasks, expected winner = {1}", fillerTasks + finishMeFirst.Length, nExpectedReturnCode); - Assert.Fail(string.Format("CoreWaitAnyTest: > error: WaitAny() return code not matching expected.")); + Assert.Fail("CoreWaitAnyTest: > error: WaitAny() return code not matching expected."); } if (staRetCode != nExpectedReturnCode) { Debug.WriteLine("CoreWaitAnyTest: Testing WaitAny with {0} tasks, expected winner = {1}", fillerTasks + finishMeFirst.Length, nExpectedReturnCode); - Assert.Fail(string.Format("CoreWaitAnyTest: > error: WaitAny() return code not matching expected for STA Thread.")); + Assert.Fail("CoreWaitAnyTest: > error: WaitAny() return code not matching expected for STA Thread."); } } @@ -1609,7 +1609,7 @@ public static void RunLongRunningTaskTests() int count = cde.CurrentCount; int initialCount = cde.InitialCount; Debug.WriteLine("Wait failed. CDE.CurrentCount: {0}, CDE.Initial Count: {1}", count, initialCount); - Assert.Fail(string.Format("RunLongRunningTaskTests - TaskCreationOptions.LongRunning: > FAILED. Timed out waiting for tasks to start.")); + Assert.Fail("RunLongRunningTaskTests - TaskCreationOptions.LongRunning: > FAILED. Timed out waiting for tasks to start."); } mre.Set(); @@ -1628,52 +1628,52 @@ public static void RunRefactoringTests() Task f; if (t.Status != TaskStatus.Created) { - Assert.Fail(string.Format("RunRefactoringTests - new Task(action): > FAILED. Status after ctor != Created.")); + Assert.Fail("RunRefactoringTests - new Task(action): > FAILED. Status after ctor != Created."); } t.Start(); t.Wait(); if (temp != 1) { - Assert.Fail(string.Format("RunRefactoringTests - new Task(action): > FAILED. Delegate failed to execute.")); + Assert.Fail("RunRefactoringTests - new Task(action): > FAILED. Delegate failed to execute."); } temp = 0; t = new Task(delegate { temp = 1; }, TaskCreationOptions.None); if (t.Status != TaskStatus.Created) { - Assert.Fail(string.Format("RunRefactoringTests - new Task(action, options): > FAILED. Status after ctor != Created.")); + Assert.Fail("RunRefactoringTests - new Task(action, options): > FAILED. Status after ctor != Created."); } t.Start(); t.Wait(); if (temp != 1) { - Assert.Fail(string.Format("RunRefactoringTests - new Task(action, options): > FAILED. Delegate failed to execute.")); + Assert.Fail("RunRefactoringTests - new Task(action, options): > FAILED. Delegate failed to execute."); } temp = 0; t = new Task(delegate (object i) { temp = (int)i; }, 1); if (t.Status != TaskStatus.Created) { - Assert.Fail(string.Format("RunRefactoringTests - new Task(action, object): > FAILED. Status after ctor != Created.")); + Assert.Fail("RunRefactoringTests - new Task(action, object): > FAILED. Status after ctor != Created."); } t.Start(); t.Wait(); if (temp != 1) { - Assert.Fail(string.Format("RunRefactoringTests - new Task(action, object): > FAILED. Delegate failed to execute.")); + Assert.Fail("RunRefactoringTests - new Task(action, object): > FAILED. Delegate failed to execute."); } temp = 0; t = new Task(delegate (object i) { temp = (int)i; }, 1, CancellationToken.None, TaskCreationOptions.None); if (t.Status != TaskStatus.Created) { - Assert.Fail(string.Format("RunRefactoringTests - new Task(action, object, options): > FAILED. Status after ctor != Created.")); + Assert.Fail("RunRefactoringTests - new Task(action, object, options): > FAILED. Status after ctor != Created."); } t.Start(); t.Wait(); if (temp != 1) { - Assert.Fail(string.Format("RunRefactoringTests - new Task(action, object, options): > FAILED. Delegate failed to execute.")); + Assert.Fail("RunRefactoringTests - new Task(action, object, options): > FAILED. Delegate failed to execute."); } temp = 0; @@ -1681,7 +1681,7 @@ public static void RunRefactoringTests() t.Wait(); if (temp != 1) { - Assert.Fail(string.Format("RunRefactoringTests - Task.Factory.StartNew(action): > FAILED. Delegate failed to execute.")); + Assert.Fail("RunRefactoringTests - Task.Factory.StartNew(action): > FAILED. Delegate failed to execute."); } temp = 0; @@ -1689,7 +1689,7 @@ public static void RunRefactoringTests() t.Wait(); if (temp != 1) { - Assert.Fail(string.Format("RunRefactoringTests - Task.Factory.StartNew(action, options): > FAILED. Delegate failed to execute.")); + Assert.Fail("RunRefactoringTests - Task.Factory.StartNew(action, options): > FAILED. Delegate failed to execute."); } temp = 0; @@ -1697,7 +1697,7 @@ public static void RunRefactoringTests() t.Wait(); if (temp != 1) { - Assert.Fail(string.Format("RunRefactoringTests - Task.Factory.StartNew(action, CT, options, TaskScheduler): > FAILED. Delegate failed to execute.")); + Assert.Fail("RunRefactoringTests - Task.Factory.StartNew(action, CT, options, TaskScheduler): > FAILED. Delegate failed to execute."); } temp = 0; @@ -1705,7 +1705,7 @@ public static void RunRefactoringTests() t.Wait(); if (temp != 1) { - Assert.Fail(string.Format("RunRefactoringTests - Task.Factory.StartNew(action, object): > FAILED. Delegate failed to execute.")); + Assert.Fail("RunRefactoringTests - Task.Factory.StartNew(action, object): > FAILED. Delegate failed to execute."); } temp = 0; @@ -1713,7 +1713,7 @@ public static void RunRefactoringTests() t.Wait(); if (temp != 1) { - Assert.Fail(string.Format("RunRefactoringTests - Task.Factory.StartNew(action, object, options): > FAILED. Delegate failed to execute.")); + Assert.Fail("RunRefactoringTests - Task.Factory.StartNew(action, object, options): > FAILED. Delegate failed to execute."); } temp = 0; @@ -1721,72 +1721,72 @@ public static void RunRefactoringTests() t.Wait(); if (temp != 1) { - Assert.Fail(string.Format("RunRefactoringTests - Task.Factory.StartNew(action, object, CT, options, TaskScheduler): > FAILED. Delegate failed to execute.")); + Assert.Fail("RunRefactoringTests - Task.Factory.StartNew(action, object, CT, options, TaskScheduler): > FAILED. Delegate failed to execute."); } temp = 0; TaskCompletionSource tr = new TaskCompletionSource(); if (tr.Task.Status != TaskStatus.WaitingForActivation) { - Assert.Fail(string.Format("RunRefactoringTests - new TaskCompletionSource(): > FAILED. Status after ctor != WaitingForActivation.")); + Assert.Fail("RunRefactoringTests - new TaskCompletionSource(): > FAILED. Status after ctor != WaitingForActivation."); } tr.SetResult(1); temp = tr.Task.Result; if (temp != 1) { - Assert.Fail(string.Format("RunRefactoringTests - new TaskCompletionSource(): > FAILED. Delegate failed to execute.")); + Assert.Fail("RunRefactoringTests - new TaskCompletionSource(): > FAILED. Delegate failed to execute."); } temp = 0; f = new Task(delegate () { return 1; }); if (f.Status != TaskStatus.Created) { - Assert.Fail(string.Format("RunRefactoringTests - new Task(Func): > FAILED. Status after ctor != Created.")); + Assert.Fail("RunRefactoringTests - new Task(Func): > FAILED. Status after ctor != Created."); } f.Start(); temp = f.Result; if (temp != 1) { - Assert.Fail(string.Format("RunRefactoringTests - new Task(Func): > FAILED. Delegate failed to execute.")); + Assert.Fail("RunRefactoringTests - new Task(Func): > FAILED. Delegate failed to execute."); } temp = 0; f = new Task(delegate () { return 1; }, TaskCreationOptions.None); if (f.Status != TaskStatus.Created) { - Assert.Fail(string.Format("RunRefactoringTests - new Task(Func, options): > FAILED. Status after ctor != Created.")); + Assert.Fail("RunRefactoringTests - new Task(Func, options): > FAILED. Status after ctor != Created."); } f.Start(); temp = f.Result; if (temp != 1) { - Assert.Fail(string.Format("RunRefactoringTests - new Task(Func, options): > FAILED. Delegate failed to execute.")); + Assert.Fail("RunRefactoringTests - new Task(Func, options): > FAILED. Delegate failed to execute."); } temp = 0; f = new Task(delegate (object i) { return (int)i; }, 1); if (f.Status != TaskStatus.Created) { - Assert.Fail(string.Format("RunRefactoringTests - new Task(Func, object): > FAILED. Status after ctor != Created.")); + Assert.Fail("RunRefactoringTests - new Task(Func, object): > FAILED. Status after ctor != Created."); } f.Start(); temp = f.Result; if (temp != 1) { - Assert.Fail(string.Format("RunRefactoringTests - new Task(Func, object) > FAILED. Delegate failed to execute.")); + Assert.Fail("RunRefactoringTests - new Task(Func, object) > FAILED. Delegate failed to execute."); } temp = 0; f = new Task(delegate (object i) { return (int)i; }, 1, CancellationToken.None, TaskCreationOptions.None); if (f.Status != TaskStatus.Created) { - Assert.Fail(string.Format("RunRefactoringTests - Task(Func, object, options): > FAILED. Status after ctor != Created.")); + Assert.Fail("RunRefactoringTests - Task(Func, object, options): > FAILED. Status after ctor != Created."); } f.Start(); temp = f.Result; if (temp != 1) { - Assert.Fail(string.Format("RunRefactoringTests - Task(Func, object, options): > FAILED. Delegate failed to execute.")); + Assert.Fail("RunRefactoringTests - Task(Func, object, options): > FAILED. Delegate failed to execute."); } temp = 0; @@ -1794,7 +1794,7 @@ public static void RunRefactoringTests() temp = f.Result; if (temp != 1) { - Assert.Fail(string.Format("RunRefactoringTests - Task.Factory.StartNew(Func): > FAILED. Delegate failed to execute.")); + Assert.Fail("RunRefactoringTests - Task.Factory.StartNew(Func): > FAILED. Delegate failed to execute."); } temp = 0; @@ -1802,7 +1802,7 @@ public static void RunRefactoringTests() temp = f.Result; if (temp != 1) { - Assert.Fail(string.Format("RunRefactoringTests - Task.Factory.StartNew(Func, options): > FAILED. Delegate failed to execute.")); + Assert.Fail("RunRefactoringTests - Task.Factory.StartNew(Func, options): > FAILED. Delegate failed to execute."); } temp = 0; @@ -1810,7 +1810,7 @@ public static void RunRefactoringTests() temp = f.Result; if (temp != 1) { - Assert.Fail(string.Format("RunRefactoringTests - Task.Factory.StartNew(Func, CT, options, TaskScheduler): > FAILED. Delegate failed to execute.")); + Assert.Fail("RunRefactoringTests - Task.Factory.StartNew(Func, CT, options, TaskScheduler): > FAILED. Delegate failed to execute."); } temp = 0; @@ -1818,7 +1818,7 @@ public static void RunRefactoringTests() temp = f.Result; if (temp != 1) { - Assert.Fail(string.Format("RunRefactoringTests - Task.Factory.StartNew(Func, object): > FAILED. Delegate failed to execute.")); + Assert.Fail("RunRefactoringTests - Task.Factory.StartNew(Func, object): > FAILED. Delegate failed to execute."); } temp = 0; @@ -1826,7 +1826,7 @@ public static void RunRefactoringTests() temp = f.Result; if (temp != 1) { - Assert.Fail(string.Format("RunRefactoringTests - Task.Factory.StartNew(Func, object, options): > FAILED. Delegate failed to execute.")); + Assert.Fail("RunRefactoringTests - Task.Factory.StartNew(Func, object, options): > FAILED. Delegate failed to execute."); } temp = 0; @@ -1834,7 +1834,7 @@ public static void RunRefactoringTests() temp = f.Result; if (temp != 1) { - Assert.Fail(string.Format("RunRefactoringTests - Task.Factory.StartNew(Func, object, CT, options, TaskScheduler): > FAILED. Delegate failed to execute.")); + Assert.Fail("RunRefactoringTests - Task.Factory.StartNew(Func, object, CT, options, TaskScheduler): > FAILED. Delegate failed to execute."); } temp = 0; @@ -1842,7 +1842,7 @@ public static void RunRefactoringTests() temp = f.Result; if (temp != 1) { - Assert.Fail(string.Format("RunRefactoringTests - Task.Factory.StartNew(Func): > FAILED. Delegate failed to execute.")); + Assert.Fail("RunRefactoringTests - Task.Factory.StartNew(Func): > FAILED. Delegate failed to execute."); } temp = 0; @@ -1850,7 +1850,7 @@ public static void RunRefactoringTests() temp = f.Result; if (temp != 1) { - Assert.Fail(string.Format("RunRefactoringTests - Task.Factory.StartNew(Func, options): > FAILED. Delegate failed to execute.")); + Assert.Fail("RunRefactoringTests - Task.Factory.StartNew(Func, options): > FAILED. Delegate failed to execute."); } temp = 0; @@ -1858,7 +1858,7 @@ public static void RunRefactoringTests() temp = f.Result; if (temp != 1) { - Assert.Fail(string.Format("RunRefactoringTests - Task.Factory.StartNew(Func, CT, options, TaskScheduler, options): > FAILED. Delegate failed to execute.")); + Assert.Fail("RunRefactoringTests - Task.Factory.StartNew(Func, CT, options, TaskScheduler, options): > FAILED. Delegate failed to execute."); } temp = 0; @@ -1867,7 +1867,7 @@ public static void RunRefactoringTests() temp = f.Result; if (temp != 1) { - Assert.Fail(string.Format("RunRefactoringTests - Task.Factory.StartNew(Func, object) > FAILED. Delegate failed to execute.")); + Assert.Fail("RunRefactoringTests - Task.Factory.StartNew(Func, object) > FAILED. Delegate failed to execute."); } temp = 0; @@ -1875,7 +1875,7 @@ public static void RunRefactoringTests() temp = f.Result; if (temp != 1) { - Assert.Fail(string.Format("RunRefactoringTests - Task.Factory.StartNew(Func, object, options). > FAILED. Delegate failed to execute.")); + Assert.Fail("RunRefactoringTests - Task.Factory.StartNew(Func, object, options). > FAILED. Delegate failed to execute."); } temp = 0; @@ -1906,14 +1906,14 @@ public static void RunRefactoringTests_NegativeTests() temp = f.Result; if (temp != 1) { - Assert.Fail(string.Format("RunRefactoringTests - Task.Factory.StartNew(Func, object, CT, options, TaskScheduler). > FAILED. Delegate failed to execute.")); + Assert.Fail("RunRefactoringTests - Task.Factory.StartNew(Func, object, CT, options, TaskScheduler). > FAILED. Delegate failed to execute."); } f = new TaskCompletionSource().Task; try { f.Start(); - Assert.Fail(string.Format("RunRefactoringTests - TaskCompletionSource.Task (should throw exception): > FAILED. No exception thrown.")); + Assert.Fail("RunRefactoringTests - TaskCompletionSource.Task (should throw exception): > FAILED. No exception thrown."); } catch (Exception) { @@ -1925,7 +1925,7 @@ public static void RunRefactoringTests_NegativeTests() try { t.Start(); - Assert.Fail(string.Format("RunRefactoringTests - Restarting Task: > FAILED. No exception thrown, when there should be.")); + Assert.Fail("RunRefactoringTests - Restarting Task: > FAILED. No exception thrown, when there should be."); } catch (Exception) { @@ -1939,21 +1939,21 @@ public static void RunRefactoringTests_NegativeTests() try { t = new Task(delegate { temp = 100; }, (TaskCreationOptions)10000); - Assert.Fail(string.Format("RunRefactoringTests - Illegal Options CTor Task: > FAILED. No exception thrown, when there should be.")); + Assert.Fail("RunRefactoringTests - Illegal Options CTor Task: > FAILED. No exception thrown, when there should be."); } catch (Exception) { } try { t = new Task(null); - Assert.Fail(string.Format("RunRefactoringTests - Task ctor w/ null action: > FAILED. No exception thrown.")); + Assert.Fail("RunRefactoringTests - Task ctor w/ null action: > FAILED. No exception thrown."); } catch (Exception) { } try { t = Task.Factory.StartNew(null); - Assert.Fail(string.Format("RunRefactoringTests - Task.Factory.StartNew() w/ Null Action: > FAILED. No exception thrown.")); + Assert.Fail("RunRefactoringTests - Task.Factory.StartNew() w/ Null Action: > FAILED. No exception thrown."); } catch (Exception) { } @@ -1962,7 +1962,7 @@ public static void RunRefactoringTests_NegativeTests() try { t2.Start(); - Assert.Fail(string.Format("RunRefactoringTests - Task.Start() on Continuation Task: > FAILED. No exception thrown.")); + Assert.Fail("RunRefactoringTests - Task.Start() on Continuation Task: > FAILED. No exception thrown."); } catch (Exception) { } @@ -1970,7 +1970,7 @@ public static void RunRefactoringTests_NegativeTests() try { t.Start(null); - Assert.Fail(string.Format("RunRefactoringTests - Task.Start() with null taskScheduler: > FAILED. No exception thrown.")); + Assert.Fail("RunRefactoringTests - Task.Start() with null taskScheduler: > FAILED. No exception thrown."); } catch (Exception) { } @@ -1978,7 +1978,7 @@ public static void RunRefactoringTests_NegativeTests() try { t = Task.Factory.StartNew(delegate { }, CancellationToken.None, TaskCreationOptions.None, (TaskScheduler)null); - Assert.Fail(string.Format("RunRefactoringTests - Task.Factory.StartNew() with null taskScheduler: > FAILED. No exception thrown.")); + Assert.Fail("RunRefactoringTests - Task.Factory.StartNew() with null taskScheduler: > FAILED. No exception thrown."); } catch (Exception) { } @@ -1987,7 +1987,7 @@ public static void RunRefactoringTests_NegativeTests() try { tr.SetResult(5); - Assert.Fail(string.Format("RunRefactoringTests - TaskCompletionSource set Result after setting Exception: > FAILED. No exception thrown.")); + Assert.Fail("RunRefactoringTests - TaskCompletionSource set Result after setting Exception: > FAILED. No exception thrown."); } catch (Exception) { } @@ -2002,7 +2002,7 @@ public static void RunRefactoringTests_NegativeTests() try { tr.SetException(new Exception("some exception")); - Assert.Fail(string.Format("RunRefactoringTests - TaskCompletionSource set Exception after setting Result > FAILED. No exception thrown.")); + Assert.Fail("RunRefactoringTests - TaskCompletionSource set Exception after setting Result > FAILED. No exception thrown."); } catch (Exception) { } @@ -2034,7 +2034,7 @@ public static void RunTaskStatusTests() } if (t.IsCompleted) { - Assert.Fail(string.Format("RunTaskStatusTests - TaskStatus.Create: > FAILED. Expected IsCompleted to be false.")); + Assert.Fail("RunTaskStatusTests - TaskStatus.Create: > FAILED. Expected IsCompleted to be false."); } } @@ -2050,7 +2050,7 @@ public static void RunTaskStatusTests() } if (ct.IsCompleted) { - Assert.Fail(string.Format("RunTaskStatusTests - TaskStatus.WaitingForActivation: > FAILED. Expected IsCompleted to be false.")); + Assert.Fail("RunTaskStatusTests - TaskStatus.WaitingForActivation: > FAILED. Expected IsCompleted to be false."); } TaskCompletionSource tcs = new TaskCompletionSource(); @@ -2061,7 +2061,7 @@ public static void RunTaskStatusTests() } if (tcs.Task.IsCompleted) { - Assert.Fail(string.Format("RunTaskStatusTests - TaskStatus.WaitingForActivation: > FAILED. Expected IsCompleted to be false.")); + Assert.Fail("RunTaskStatusTests - TaskStatus.WaitingForActivation: > FAILED. Expected IsCompleted to be false."); } tcs.TrySetCanceled(); } @@ -2120,7 +2120,7 @@ public static void RunTaskStatusTests() } if (!t.IsCompleted) { - Assert.Fail(string.Format("RunTaskStatusTests - Internal Cancellation: > FAILED. Expected IsCompleted to be true.")); + Assert.Fail("RunTaskStatusTests - Internal Cancellation: > FAILED. Expected IsCompleted to be true."); } } @@ -2140,7 +2140,7 @@ public static void RunTaskStatusTests() } if (t.IsCompleted) { - Assert.Fail(string.Format("RunTaskStatusTests - TaskStatus.Running: > FAILED. Expected IsCompleted to be false.")); + Assert.Fail("RunTaskStatusTests - TaskStatus.Running: > FAILED. Expected IsCompleted to be false."); } // Causes previously created task to finish @@ -2170,7 +2170,7 @@ public static void RunTaskStatusTests() } if (t.IsCompleted) { - Assert.Fail(string.Format("RunTaskStatusTests - TaskStatus.WaitingForChildrenToComplete: > FAILED. Expected IsCompleted to be false.")); + Assert.Fail("RunTaskStatusTests - TaskStatus.WaitingForChildrenToComplete: > FAILED. Expected IsCompleted to be false."); } // Causes previously created Task(s) to finish @@ -2191,7 +2191,7 @@ public static void RunTaskStatusTests() } if (!t.IsCompleted) { - Assert.Fail(string.Format("RunTaskStatusTests - TaskStatus.RanToCompletion: > FAILED. Expected IsCompleted to be true.")); + Assert.Fail("RunTaskStatusTests - TaskStatus.RanToCompletion: > FAILED. Expected IsCompleted to be true."); } } } @@ -2230,7 +2230,7 @@ public static void RunTaskStatusTests_NegativeTests() } if (!t.IsCompleted) { - Assert.Fail(string.Format("RunTaskStatusTests - TaskStatus.Canceled: > FAILED. Expected IsCompleted to be true.")); + Assert.Fail("RunTaskStatusTests - TaskStatus.Canceled: > FAILED. Expected IsCompleted to be true."); } } @@ -2285,11 +2285,11 @@ public static void RunTaskStatusTests_NegativeTests() } if (tCanceled.IsCanceled) { - Assert.Fail(string.Format("RunTaskStatusTests - TaskStatus.WaitingForChildrenToComplete: > canceledTask FAILED. IsFaulted is true before children have completed.")); + Assert.Fail("RunTaskStatusTests - TaskStatus.WaitingForChildrenToComplete: > canceledTask FAILED. IsFaulted is true before children have completed."); } if (tCanceled.IsCompleted) { - Assert.Fail(string.Format("RunTaskStatusTests - TaskStatus.WaitingForChildrenToComplete: > canceledTask FAILED. IsCompleted is true before children have completed.")); + Assert.Fail("RunTaskStatusTests - TaskStatus.WaitingForChildrenToComplete: > canceledTask FAILED. IsCompleted is true before children have completed."); } mreFaulted.Set(); @@ -2317,7 +2317,7 @@ public static void RunTaskStatusTests_NegativeTests() } if (!t.IsCompleted) { - Assert.Fail(string.Format("RunTaskStatusTests - TaskStatus.Faulted: > FAILED. Expected IsCompleted to be true.")); + Assert.Fail("RunTaskStatusTests - TaskStatus.Faulted: > FAILED. Expected IsCompleted to be true."); } } @@ -2346,11 +2346,11 @@ public static void RunTaskStatusTests_NegativeTests() } if (tFaulted.IsFaulted) { - Assert.Fail(string.Format("RunTaskStatusTests - TaskStatus.WaitingForChildrenToComplete: > faultedTask FAILED. IsFaulted is true before children have completed.")); + Assert.Fail("RunTaskStatusTests - TaskStatus.WaitingForChildrenToComplete: > faultedTask FAILED. IsFaulted is true before children have completed."); } if (tFaulted.IsCompleted) { - Assert.Fail(string.Format("RunTaskStatusTests - TaskStatus.WaitingForChildrenToComplete: > faultedTask FAILED. IsCompleted is true before children have completed.")); + Assert.Fail("RunTaskStatusTests - TaskStatus.WaitingForChildrenToComplete: > faultedTask FAILED. IsCompleted is true before children have completed."); } mreFaulted.Set(); @@ -2377,7 +2377,7 @@ public static void RunTaskStatusTests_NegativeTests() ts = t.Status; if (ts != TaskStatus.Faulted) { - Assert.Fail(string.Format("RunTaskStatusTests - TaskStatus.Faulted trumps Cancelled: > FAILED. Expected Faulted to trump Canceled")); + Assert.Fail("RunTaskStatusTests - TaskStatus.Faulted trumps Cancelled: > FAILED. Expected Faulted to trump Canceled"); } } } @@ -2392,7 +2392,7 @@ public static void RunTaskWaitTest() if (!t.IsCompleted) { - Assert.Fail(string.Format("RunTaskWaitTest: > error: task reported back !IsCompleted")); + Assert.Fail("RunTaskWaitTest: > error: task reported back !IsCompleted"); } // wait on non-exceptional delay started task @@ -2407,7 +2407,7 @@ public static void RunTaskWaitTest() if (!t.IsCompleted) { - Assert.Fail(string.Format("RunTaskWaitTest: > error: constructed task reported back !IsCompleted")); + Assert.Fail("RunTaskWaitTest: > error: constructed task reported back !IsCompleted"); } // This keeps a reference to the Timer so that it does not get GC'd @@ -2426,7 +2426,7 @@ public static void RunTaskWaitTest() t.Wait(); if (!cntEv.IsSet) { - Assert.Fail(string.Format("RunTaskWaitTest: > error: Wait on a task with attached children returned before all children completed.")); + Assert.Fail("RunTaskWaitTest: > error: Wait on a task with attached children returned before all children completed."); } } @@ -2461,7 +2461,7 @@ public static void RunTaskWaitTest_NegativeTests() try { t.Wait(); - Assert.Fail(string.Format("RunTaskWaitTest: > error: Wait on exceptional task show have thrown.")); + Assert.Fail("RunTaskWaitTest: > error: Wait on exceptional task show have thrown."); } catch (Exception e) { @@ -2469,7 +2469,7 @@ public static void RunTaskWaitTest_NegativeTests() ((AggregateException)e).InnerExceptions.Count != 1 || !(((AggregateException)e).InnerExceptions[0] is TaskCanceledException)) { - Assert.Fail(string.Format("RunTaskWaitTest: > error: Wait on exceptional task threw wrong exception.")); + Assert.Fail("RunTaskWaitTest: > error: Wait on exceptional task threw wrong exception."); } } @@ -2478,7 +2478,7 @@ public static void RunTaskWaitTest_NegativeTests() try { t.Wait(); - Assert.Fail(string.Format("RunTaskWaitTest: > error: Wait on exceptional task show have thrown.")); + Assert.Fail("RunTaskWaitTest: > error: Wait on exceptional task show have thrown."); } catch (Exception e) { @@ -2486,7 +2486,7 @@ public static void RunTaskWaitTest_NegativeTests() ((AggregateException)e).InnerExceptions.Count != 1 || ((AggregateException)e).InnerExceptions[0].Message != exceptionMsg) { - Assert.Fail(string.Format("RunTaskWaitTest: > error: Wait on exceptional task threw wrong exception.")); + Assert.Fail("RunTaskWaitTest: > error: Wait on exceptional task threw wrong exception."); } } @@ -2500,7 +2500,7 @@ public static void RunTaskWaitTest_NegativeTests() try { t.Wait(); - Assert.Fail(string.Format("RunTaskWaitTest: > error: Wait on a task with an exceptional child should have thrown.")); + Assert.Fail("RunTaskWaitTest: > error: Wait on a task with an exceptional child should have thrown."); } catch (Exception e) { @@ -2511,7 +2511,7 @@ public static void RunTaskWaitTest_NegativeTests() outerAggExp.InnerExceptions.Count != 1 || !(outerAggExp.InnerExceptions[0] is AggregateException)) { - Assert.Fail(string.Format("RunTaskWaitTest: > error: Wait on task with exceptional child threw an exception other than AggExp(AggExp(childsException)).")); + Assert.Fail("RunTaskWaitTest: > error: Wait on task with exceptional child threw an exception other than AggExp(AggExp(childsException))."); } innerAggExp = outerAggExp.InnerExceptions[0] as AggregateException; @@ -2519,7 +2519,7 @@ public static void RunTaskWaitTest_NegativeTests() if (innerAggExp.InnerExceptions.Count != 1 || innerAggExp.InnerExceptions[0].Message != exceptionMsg) { - Assert.Fail(string.Format("RunTaskWaitTest: > error: Wait on task with exceptional child threw AggExp(AggExp(childsException)), but contained wrong child exception.")); + Assert.Fail("RunTaskWaitTest: > error: Wait on task with exceptional child threw AggExp(AggExp(childsException)), but contained wrong child exception."); } } } @@ -2538,12 +2538,12 @@ public static void RunTaskRecursiveWaitTest() if (!t.IsCompleted) { - Assert.Fail(string.Format("RunTaskRecursiveWaitTest: > error: task reported back !t.IsCompleted")); + Assert.Fail("RunTaskRecursiveWaitTest: > error: task reported back !t.IsCompleted"); } if (!t2.IsCompleted) { - Assert.Fail(string.Format("RunTaskRecursiveWaitTest: > error: task reported back !t2.IsCompleted")); + Assert.Fail("RunTaskRecursiveWaitTest: > error: task reported back !t2.IsCompleted"); } t2 = null; @@ -2558,12 +2558,12 @@ public static void RunTaskRecursiveWaitTest() if (!t.IsCompleted) { - Assert.Fail(string.Format("RunTaskRecursiveWaitTest: > error: constructed task reported back !t.IsCompleted")); + Assert.Fail("RunTaskRecursiveWaitTest: > error: constructed task reported back !t.IsCompleted"); } if (!t2.IsCompleted) { - Assert.Fail(string.Format("RunTaskRecursiveWaitTest: > error: constructed task reported back !t2.IsCompleted")); + Assert.Fail("RunTaskRecursiveWaitTest: > error: constructed task reported back !t2.IsCompleted"); } } @@ -2577,7 +2577,7 @@ public static void RunTaskWaitTimeoutTest() if (t.IsCompleted) { - Assert.Fail(string.Format("RunTaskWaitTimeoutTest: > error: task reported back IsCompleted")); + Assert.Fail("RunTaskWaitTimeoutTest: > error: task reported back IsCompleted"); } mre.Set(); @@ -2585,7 +2585,7 @@ public static void RunTaskWaitTimeoutTest() if (!t.IsCompleted) { - Assert.Fail(string.Format("RunTaskWaitTimeoutTest: > error: task reported back !IsCompleted")); + Assert.Fail("RunTaskWaitTimeoutTest: > error: task reported back !IsCompleted"); } } @@ -2611,12 +2611,12 @@ public static void RunTaskRecursiveWaitTimeoutTest() if (t.IsCompleted) { - Assert.Fail(string.Format("RunTaskRecursiveWaitTimeoutTest: > error: task reported back t.IsCompleted")); + Assert.Fail("RunTaskRecursiveWaitTimeoutTest: > error: task reported back t.IsCompleted"); } if (t2.IsCompleted) { - Assert.Fail(string.Format("RunTaskRecursiveWaitTimeoutTest: > error: task reported back t2.IsCompleted")); + Assert.Fail("RunTaskRecursiveWaitTimeoutTest: > error: task reported back t2.IsCompleted"); } mre.Set(); @@ -2624,12 +2624,12 @@ public static void RunTaskRecursiveWaitTimeoutTest() if (!t.IsCompleted) { - Assert.Fail(string.Format("RunTaskRecursiveWaitTimeoutTest: > error: task reported back !t.IsCompleted")); + Assert.Fail("RunTaskRecursiveWaitTimeoutTest: > error: task reported back !t.IsCompleted"); } if (!t2.IsCompleted) { - Assert.Fail(string.Format("RunTaskRecursiveWaitTimeoutTest: > error: task reported back !t2.IsCompleted")); + Assert.Fail("RunTaskRecursiveWaitTimeoutTest: > error: task reported back !t2.IsCompleted"); } mre.Reset(); @@ -2652,12 +2652,12 @@ public static void RunTaskRecursiveWaitTimeoutTest() if (t.IsCompleted) { - Assert.Fail(string.Format("RunTaskRecursiveWaitTimeoutTest: > error: constructed task reported back t.IsCompleted")); + Assert.Fail("RunTaskRecursiveWaitTimeoutTest: > error: constructed task reported back t.IsCompleted"); } if (t2.IsCompleted) { - Assert.Fail(string.Format("RunTaskRecursiveWaitTimeoutTest: > error: constructed task reported back t2.IsCompleted")); + Assert.Fail("RunTaskRecursiveWaitTimeoutTest: > error: constructed task reported back t2.IsCompleted"); } mre.Set(); @@ -2665,12 +2665,12 @@ public static void RunTaskRecursiveWaitTimeoutTest() if (!t.IsCompleted) { - Assert.Fail(string.Format("RunTaskRecursiveWaitTimeoutTest: > error: constructed task reported back !t.IsCompleted")); + Assert.Fail("RunTaskRecursiveWaitTimeoutTest: > error: constructed task reported back !t.IsCompleted"); } if (!t2.IsCompleted) { - Assert.Fail(string.Format("RunTaskRecursiveWaitTimeoutTest: > error: constructed task reported back !t2.IsCompleted")); + Assert.Fail("RunTaskRecursiveWaitTimeoutTest: > error: constructed task reported back !t2.IsCompleted"); } } diff --git a/src/libraries/System.Runtime/tests/System.Threading.Tasks.Tests/Task/TaskRunSyncTests.cs b/src/libraries/System.Runtime/tests/System.Threading.Tasks.Tests/Task/TaskRunSyncTests.cs index 8dceb6adf3f88d..913ef2ec0ddc5f 100644 --- a/src/libraries/System.Runtime/tests/System.Threading.Tasks.Tests/Task/TaskRunSyncTests.cs +++ b/src/libraries/System.Runtime/tests/System.Threading.Tasks.Tests/Task/TaskRunSyncTests.cs @@ -243,9 +243,9 @@ internal void RealRun() _task.RunSynchronously(ts); if (ExpectRunSyncFailure) - Assert.Fail(string.Format("Fail to throw expected InvalidOperationException")); + Assert.Fail("Fail to throw expected InvalidOperationException"); if (_taskSchedulerType == TaskSchedulerType.Null) - Assert.Fail(string.Format("Fail to throw expected ArgumentNullException")); + Assert.Fail("Fail to throw expected ArgumentNullException"); } catch (InvalidOperationException ex) { @@ -283,15 +283,15 @@ internal void RealRun() if (_workloadType == WorkloadType.ThrowException) { if (_task.Status != TaskStatus.Faulted) - Assert.Fail(string.Format("Wrong final task status on a faulty workload")); + Assert.Fail("Wrong final task status on a faulty workload"); CheckExpectedAggregateException(_task.Exception); - //Assert.Fail(string.Format("Fail to record the test exception in Task.Exception")); + //Assert.Fail("Fail to record the test exception in Task.Exception"); } else { if (_task.Status != TaskStatus.RanToCompletion) - Assert.Fail(string.Format("Wrong final task status on a regular workload")); + Assert.Fail("Wrong final task status on a regular workload"); } // @@ -302,7 +302,7 @@ internal void RealRun() _taskSchedulerType == TaskSchedulerType.CustomWithoutInlineExecution) { if (((TaskRunSyncTaskScheduler)ts).RunSyncCalledCount <= 0) - Assert.Fail(string.Format("Task wasn't RunSynchronously with TaskScheduler specified")); + Assert.Fail("Task wasn't RunSynchronously with TaskScheduler specified"); } // Stage 5 - follow with the post-action @@ -314,7 +314,7 @@ internal void RealRun() if (_postRunSyncAction == PostRunSyncAction.Wait) _task.Wait(0); if (_workloadType == WorkloadType.ThrowException) - Assert.Fail(string.Format("expected failure is not propagated out of Wait")); + Assert.Fail("expected failure is not propagated out of Wait"); } catch (AggregateException ae) { diff --git a/src/libraries/System.Runtime/tests/System.Threading.Tasks.Tests/Task/TaskStatusTest.cs b/src/libraries/System.Runtime/tests/System.Threading.Tasks.Tests/Task/TaskStatusTest.cs index 72c04df33ecf78..f8d8c11f8d5f18 100644 --- a/src/libraries/System.Runtime/tests/System.Threading.Tasks.Tests/Task/TaskStatusTest.cs +++ b/src/libraries/System.Runtime/tests/System.Threading.Tasks.Tests/Task/TaskStatusTest.cs @@ -261,11 +261,11 @@ internal void RealRun() // if (_task != null && _task.Status == TaskStatus.Canceled && _task.IsCanceled != true) { - Assert.Fail(string.Format("Task final Status is Canceled, expecting IsCanceled property to be True as well")); + Assert.Fail("Task final Status is Canceled, expecting IsCanceled property to be True as well"); } if (_childTask != null && _childTask.Status == TaskStatus.Canceled && _childTask.IsCanceled != true) { - Assert.Fail(string.Format("Child Task final Status is Canceled, expecting IsCanceled property to be True as well")); + Assert.Fail("Child Task final Status is Canceled, expecting IsCanceled property to be True as well"); } // @@ -280,7 +280,7 @@ internal void RealRun() AggregateException exp = _promise.Task.Exception; if (!_promise.Task.IsFaulted || exp == null) { - Assert.Fail(string.Format("No Exception found on promise")); + Assert.Fail("No Exception found on promise"); } else if (exp.Flatten().InnerException.GetType() == typeof(StatusTestException)) { diff --git a/src/libraries/System.Runtime/tests/System.Threading.Tasks.Tests/TaskScheduler/TaskSchedulerTests.cs b/src/libraries/System.Runtime/tests/System.Threading.Tasks.Tests/TaskScheduler/TaskSchedulerTests.cs index 0d659d7cd03b84..7af868d9081e65 100644 --- a/src/libraries/System.Runtime/tests/System.Threading.Tasks.Tests/TaskScheduler/TaskSchedulerTests.cs +++ b/src/libraries/System.Runtime/tests/System.Threading.Tasks.Tests/TaskScheduler/TaskSchedulerTests.cs @@ -66,7 +66,7 @@ public static void RunBuggySchedulerTests() try { t1.Start(bts); - Assert.Fail(string.Format(" > FAILED. No exception thrown.")); + Assert.Fail(" > FAILED. No exception thrown."); } catch (TaskSchedulerException) { @@ -86,7 +86,7 @@ public static void RunBuggySchedulerTests() try { t1.Wait(); - Assert.Fail(string.Format(" > FAILED. No exception thrown from Wait().")); + Assert.Fail(" > FAILED. No exception thrown from Wait()."); } catch (AggregateException ae) { @@ -103,7 +103,7 @@ public static void RunBuggySchedulerTests() try { t2.RunSynchronously(bts); - Assert.Fail(string.Format(" > FAILED. No exception thrown.")); + Assert.Fail(" > FAILED. No exception thrown."); } catch (TaskSchedulerException) { } catch (Exception e) @@ -120,7 +120,7 @@ public static void RunBuggySchedulerTests() try { t2.Wait(); - Assert.Fail(string.Format(" > FAILED. No exception thrown from Wait().")); + Assert.Fail(" > FAILED. No exception thrown from Wait()."); } catch (AggregateException ae) { @@ -137,7 +137,7 @@ public static void RunBuggySchedulerTests() try { Task t3 = Task.Factory.StartNew(delegate { }, CancellationToken.None, TaskCreationOptions.None, bts); - Assert.Fail(string.Format(" > FAILED. No exception thrown.")); + Assert.Fail(" > FAILED. No exception thrown."); } catch (TaskSchedulerException) { } catch (Exception e) @@ -158,7 +158,7 @@ public static void RunBuggySchedulerTests() try { tc1.Wait(); - Assert.Fail(string.Format(" > FAILED. No exception thrown (sync).")); + Assert.Fail(" > FAILED. No exception thrown (sync)."); } catch (AggregateException ae) { @@ -178,7 +178,7 @@ public static void RunBuggySchedulerTests() try { tc2.Wait(); - Assert.Fail(string.Format(" > FAILED. No exception thrown (async).")); + Assert.Fail(" > FAILED. No exception thrown (async)."); } catch (AggregateException ae) { @@ -200,7 +200,7 @@ public static void RunBuggySchedulerTests() try { t4.Wait(); - Assert.Fail(string.Format(" > FAILED. Expected inlining exception")); + Assert.Fail(" > FAILED. Expected inlining exception"); } catch (TaskSchedulerException) { } catch (Exception e) diff --git a/src/libraries/System.Threading.Tasks.Parallel/tests/ParallelStateTest.cs b/src/libraries/System.Threading.Tasks.Parallel/tests/ParallelStateTest.cs index e5894ec6afeff9..8d305cec3ce3eb 100644 --- a/src/libraries/System.Threading.Tasks.Parallel/tests/ParallelStateTest.cs +++ b/src/libraries/System.Threading.Tasks.Parallel/tests/ParallelStateTest.cs @@ -628,7 +628,7 @@ private void ExceptionalAction(long i, ParallelLoopState state) Assert.False(_isExceptional != state.IsExceptional, string.Format("IsExceptional is expected to be {0} while getting {1}", _isExceptional, state.IsExceptional)); // Previous iteration throws exception, the Parallel should stop it's work - Assert.False(_isExceptional && !state.ShouldExitCurrentIteration, string.Format("Expecting ShouldExitCurrentIteration to be true, since Exception was thrown on previous iterations")); + Assert.False(_isExceptional && !state.ShouldExitCurrentIteration, "Expecting ShouldExitCurrentIteration to be true, since Exception was thrown on previous iterations"); try { @@ -672,7 +672,7 @@ private void MultipleExceptionAction(long i, ParallelLoopState state) // Previous iteration throws exception, the Parallel should stop it's work Assert.False(state.IsExceptional && !state.ShouldExitCurrentIteration, - string.Format("Expecting ShouldExitCurrentIteration to be true, since Exception was thrown on previous iterations")); + "Expecting ShouldExitCurrentIteration to be true, since Exception was thrown on previous iterations"); } } #endregion