public void MakingTypesAvailableExternallyPS1_ExitCodeIs0() { if (PowerShellTestsUtilities.PowerShellNotInstalled()) { Assert.Inconclusive("Powershell not installed"); } //EssentialCSharp\\src\\Chapter10.Tests\\bin\\Debug\\netcoreapp3.0 string ps1Path = Path.GetFullPath("../../../../Chapter10/Listing10.13.MakingTypesAvailableExternally.ps1", Environment.CurrentDirectory); string traceValue = "0"; string nameOfPowershellTool; if (PowerShellTestsUtilities.WindowsEnvironment()) { nameOfPowershellTool = "powershell"; } else { nameOfPowershellTool = "pwsh"; } System.Diagnostics.Process powerShell = System.Diagnostics.Process.Start(nameOfPowershellTool, $"-noprofile -command \"{ps1Path} {traceValue}\""); powerShell.WaitForExit(); Assert.AreEqual(0, powerShell.ExitCode); }
public static void ClassInitialize(TestContext testContext) { if (PowerShellNotAvailable) { Assert.Inconclusive("Powershell not installed"); return; } if (PowerShellTestsUtilities.WindowsEnvironment()) { PowershellEnvironmentVariableName = "powershell"; } else { PowershellEnvironmentVariableName = "pwsh"; } string testStatus = "create"; Process powershell = Process.Start(PowershellEnvironmentVariableName, $"-noprofile -command \"{Ps1Path} 0 null {testStatus}\""); powershell.WaitForExit(); }