. $PSScriptRoot\..\..\Load-PesterModules.ps1 $here = Split-Path -Parent $MyInvocation.MyCommand.Path $sut = (Split-Path -Leaf $MyInvocation.MyCommand.Path) -replace '\.tests\.', '.' $functionPath = Join-Path -Path $here -ChildPath $sut Write-Host "Overriding SUT: $functionPath" Import-Module $functionPath -Force $moduleForMock = "" #region Start-ServicesInParallel Describe "Start-ServicesInParallel" { $testServiceNames = @("TestService1" , "TestService2") Context "Parameter Validation" { Mock -CommandName Start-Job -MockWith { return $null } -ModuleName $moduleForMock Mock -CommandName Start-Service -MockWith { } -ModuleName $moduleForMock It "Should Not Throw if maxParallel is 0" { # Zero is pure CPU throttling. { Start-ServicesInParallel -serviceNamestoStart $testServiceNames -maxParallel 0 } | Should -Not -Throw } It "Should Throw if maxParallel is less 1" { { Start-ServicesInParallel -serviceNamestoStart $testServiceNames -maxParallel -1 } | Should -Throw } It "Does Not Throw if maxParallel is greater than or equal to 1" { { Start-ServicesInParallel -serviceNamestoStart $testServiceNames -maxParallel 1 } | Should -Not -Throw { Start-ServicesInParallel -serviceNamestoStart $testServiceNames -maxParallel 50 } | Should -Not -Throw } # Should ideally test that the runspace is created with the specified job ceiling, but cannot at present without abstraction } } #endregion Start-ServicesInParallel