. $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 = "" Describe "Start-IISAndServices" { Context "Parameter Validation" { It "Uses the Supplied Max Parallel Parameter" { Mock -ModuleName $moduleForMock -CommandName Start-Sleep -MockWith { } Mock -ModuleName $moduleForMock -CommandName Start-ServicesOnly -MockWith { } $maxParallelTestValue = 20 Start-IISAndServices -maxParallel $maxParallelTestValue Assert-MockCalled -CommandName Start-ServicesOnly -Times 1 -Exactly -Scope It ` -ModuleName $moduleForMock -ParameterFilter { $maxParallel -eq $maxParallelTestValue } } It "Writes to Host if a Non-Default Max Parallel Param is Used" { Mock -ModuleName $moduleForMock -CommandName Start-Sleep -MockWith { } Mock -ModuleName $moduleForMock -CommandName Start-ServicesOnly -MockWith { } Mock -ModuleName $moduleForMock -CommandName Write-Host -MockWith { } $maxParallelTestValue = 20 Start-IISAndServices -maxParallel $maxParallelTestValue Assert-MockCalled -CommandName Write-Host -Times 1 -Exactly -Scope It ` -ModuleName $moduleForMock -ParameterFilter { $Object -match "Service start parallelism set to $maxParallelTestValue" } } } }