@@ -15,11 +15,10 @@ namespace Common
15
15
public static class UiTestHelpers
16
16
{
17
17
/// <summary>
18
- /// Navigates to a web page with retry logic to ensure establish a connection in case a web app needs more startup time.
18
+ /// Navigates to a web page with retry logic to more reliably connect in case a web app needs more startup time.
19
19
/// </summary>
20
20
/// <param name="uri">The uri to navigate to</param>
21
21
/// <param name="page">A page in a playwright browser</param>
22
- /// <returns></returns>
23
22
public static async Task NavigateToWebApp ( string uri , IPage page )
24
23
{
25
24
uint InitialConnectionRetryCount = 5 ;
@@ -124,13 +123,13 @@ public static async Task EnterPasswordAsync(IPage page, string password, ITestOu
124
123
await FillEntryBox ( passwordInputLocator , password ) ;
125
124
}
126
125
127
- public static async Task StaySignedIn_MicrosoftIdFlow ( IPage page , string staySignedInText , ITestOutputHelper ? output = null )
126
+ private static async Task StaySignedIn_MicrosoftIdFlow ( IPage page , string staySignedInText , ITestOutputHelper ? output = null )
128
127
{
129
128
WriteLine ( output , $ "Logging in ... Clicking { staySignedInText } on whether the browser should stay signed in.") ;
130
129
await page . GetByRole ( AriaRole . Button , new ( ) { Name = staySignedInText } ) . ClickAsync ( ) ;
131
130
}
132
131
133
- public static async Task FillEntryBox ( ILocator entryBox , string entryText )
132
+ private static async Task FillEntryBox ( ILocator entryBox , string entryText )
134
133
{
135
134
await entryBox . ClickAsync ( ) ;
136
135
await entryBox . FillAsync ( entryText ) ;
@@ -269,6 +268,10 @@ public static string GetTracePath(string testAssemblyLocation, string traceName)
269
268
) ;
270
269
}
271
270
271
+ /// <summary>
272
+ /// Goes through all processes and ends them and any child processes they spawned
273
+ /// </summary>
274
+ /// <param name="processes"></param>
272
275
public static void EndProcesses ( Dictionary < string , Process > ? processes )
273
276
{
274
277
Queue < Process > processQueue = new ( ) ;
@@ -286,7 +289,7 @@ public static void EndProcesses(Dictionary<string, Process>? processes)
286
289
/// Kills the processes in the queue and all of their children
287
290
/// </summary>
288
291
/// <param name="processQueue">queue of parent processes</param>
289
- public static void KillProcessTrees ( Queue < Process > processQueue )
292
+ private static void KillProcessTrees ( Queue < Process > processQueue )
290
293
{
291
294
#if WINDOWS
292
295
Process currentProcess ;
@@ -381,6 +384,13 @@ internal static async Task<string> GetValueFromKeyvaultWitDefaultCreds(Uri keyva
381
384
return ( await client . GetSecretAsync ( keyvaultSecretName ) ) . Value . Value ;
382
385
}
383
386
387
+ /// <summary>
388
+ /// Starts all processes in the given list and verifies that they are running
389
+ /// </summary>
390
+ /// <param name="processDataEntries">The startup options for each process to be started</param>
391
+ /// <param name="processes">A dictionary to hold the process objects once started</param>
392
+ /// <param name="numRetries">The number of times to retry starting a process</param>
393
+ /// <returns>A boolean to say whether all the processes were able to start up successfully</returns>
384
394
public static bool StartAndVerifyProcessesAreRunning ( List < ProcessStartOptions > processDataEntries , out Dictionary < string , Process > processes , uint numRetries )
385
395
{
386
396
processes = new Dictionary < string , Process > ( ) ;
@@ -469,9 +479,17 @@ private static void SwapFiles(string path1, string path2)
469
479
470
480
// Write the contents of file2 to file1
471
481
File . WriteAllText ( path1 , file2Contents ) ;
472
-
473
- // Write the contents of file1 to file2
474
- File . WriteAllText ( path2 , file1Contents ) ;
482
+ try
483
+ {
484
+ // Write the contents of file1 to file2
485
+ File . WriteAllText ( path2 , file1Contents ) ;
486
+ }
487
+ catch ( Exception )
488
+ {
489
+ // If the second write fails, revert the first write
490
+ File . WriteAllText ( path1 , file1Contents ) ;
491
+ throw ;
492
+ }
475
493
476
494
Console . WriteLine ( "File contents swapped successfully." ) ;
477
495
}
@@ -547,6 +565,9 @@ public void Dispose()
547
565
}
548
566
}
549
567
568
+ /// <summary>
569
+ /// A POCO class to hold the options for starting a process
570
+ /// </summary>
550
571
public class ProcessStartOptions
551
572
{
552
573
public string TestAssemblyLocation { get ; }
0 commit comments