Skip to content

Commit 025947b

Browse files
committed
Adding notes
1 parent 02d5dc0 commit 025947b

File tree

1 file changed

+28
-12
lines changed

1 file changed

+28
-12
lines changed

UiTests/Common/UiTestHelpers.cs

+28-12
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,7 @@ public static bool StartAndVerifyProcessesAreRunning(List<ProcessStartOptions> p
414414
return true;
415415
}
416416

417-
static void RestartProcesses(Dictionary<string, Process> processes, List<ProcessStartOptions> processDataEntries)
417+
private static void RestartProcesses(Dictionary<string, Process> processes, List<ProcessStartOptions> processDataEntries)
418418
{
419419
//attempt to restart failed processes
420420
foreach (KeyValuePair<string, Process> processEntry in processes)
@@ -434,6 +434,12 @@ static void RestartProcesses(Dictionary<string, Process> processes, List<Process
434434
}
435435
}
436436
}
437+
438+
/// <summary>
439+
/// Returns a string representation of the running processes
440+
/// </summary>
441+
/// <param name="processes">Dict of running processes</param>
442+
/// <returns>A string of all processes from the give dict</returns>
437443
public static string GetRunningProcessAsString(Dictionary<string, Process>? processes)
438444
{
439445
StringBuilder runningProcesses = new StringBuilder();
@@ -469,8 +475,11 @@ private static void SwapFiles(string path1, string path2)
469475
Console.WriteLine("File contents swapped successfully.");
470476
}
471477

472-
473-
private static void RebuildSolution(string solutionPath)
478+
/// <summary>
479+
/// Builds the solution at the given path.
480+
/// </summary>
481+
/// <param name="solutionPath">Absolute path to the sln file to be built</param>
482+
private static void BuildSolution(string solutionPath)
474483
{
475484
ProcessStartInfo startInfo = new ProcessStartInfo
476485
{
@@ -479,7 +488,7 @@ private static void RebuildSolution(string solutionPath)
479488
RedirectStandardOutput = true,
480489
RedirectStandardError = true,
481490
UseShellExecute = false,
482-
CreateNoWindow = false
491+
CreateNoWindow = true
483492
};
484493

485494
using (Process process = new Process())
@@ -497,22 +506,29 @@ private static void RebuildSolution(string solutionPath)
497506
Console.WriteLine("Solution rebuild initiated.");
498507
}
499508

509+
/// <summary>
510+
/// Replaces existing appsettings.json file with a test appsettings file, builds the solution, and then swaps the files back.
511+
/// </summary>
512+
/// <param name="testAssemblyLocation">Absolute path to the current test's working directory</param>
513+
/// <param name="sampleRelPath">Relative path to the sample app to build starting at the repo's root, does not include appsettings filename</param>
514+
/// <param name="testAppsettingsRelPath">Relative path to the test appsettings file starting at the repo's root, includes appsettings filename</param>
515+
/// <param name="solutionFileName">Filename for the sln file to build</param>
500516
public static void BuildSampleWithTestAppsettings(
501517
string testAssemblyLocation,
502-
string appLocation,
503-
string testAppsettingsPathFromRepoRoot,
518+
string sampleRelPath,
519+
string testAppsettingsRelPath,
504520
string solutionFileName
505521
)
506522
{
507-
string appsettingsDirectory = GetAppsettingsDirectory(testAssemblyLocation, appLocation);
508-
string appsettingsPath = Path.Combine(appsettingsDirectory, TestConstants.AppSetttingsDotJson);
509-
string testAppsettingsPath = GetAppsettingsDirectory(testAssemblyLocation, testAppsettingsPathFromRepoRoot);
523+
string appsettingsDirectory = GetAppsettingsDirectory(testAssemblyLocation, sampleRelPath);
524+
string appsettingsAbsPath = Path.Combine(appsettingsDirectory, TestConstants.AppSetttingsDotJson);
525+
string testAppsettingsAbsPath = GetAppsettingsDirectory(testAssemblyLocation, testAppsettingsRelPath);
510526

511-
SwapFiles(appsettingsPath, testAppsettingsPath);
527+
SwapFiles(appsettingsAbsPath, testAppsettingsAbsPath);
512528

513-
try { RebuildSolution(appsettingsDirectory + solutionFileName); }
529+
try { BuildSolution(appsettingsDirectory + solutionFileName); }
514530
catch (Exception) { throw; }
515-
finally { SwapFiles(appsettingsPath, testAppsettingsPath); }
531+
finally { SwapFiles(appsettingsAbsPath, testAppsettingsAbsPath); }
516532
}
517533
}
518534

0 commit comments

Comments
 (0)