ps/Modules/Alkami.PowerShell.ServerManagement/Public/Get-RequiredServerFeaturesAndRoles.tests.ps1
2023-05-30 22:51:22 -07:00

51 lines
2.2 KiB
PowerShell

. $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 "Get-RequiredServerFeaturesAndRoles" {
Mock -ModuleName $moduleForMock -CommandName Get-LogLeadName -MockWith { return "Get-RequiredServerFeaturesAndRoles.tests" }
Context "Results" {
It "Returns Windows-Identity-Foundation on Windows Server" {
Mock -CommandName Test-IsWindowsServerCore -ModuleName $moduleForMock -MockWith { return $false }
( Get-RequiredServerFeaturesAndRoles ).Features | Should -Contain 'Windows-Identity-Foundation'
Assert-MockCalled -ModuleName $moduleForMock -CommandName Test-IsWindowsServerCore -Scope It -Exactly 1
}
It "Returns Web-Lgcy-Mgmt-Console on Windows Server" {
Mock -CommandName Test-IsWindowsServerCore -ModuleName $moduleForMock -MockWith { return $false }
( Get-RequiredServerFeaturesAndRoles ).Features | Should -Contain 'Web-Lgcy-Mgmt-Console'
Assert-MockCalled -ModuleName $moduleForMock -CommandName Test-IsWindowsServerCore -Scope It -Exactly 1
}
It "Does Not Return Windows-Identity-Foundation on Windows Server Core" {
Mock -CommandName Test-IsWindowsServerCore -ModuleName $moduleForMock -MockWith { return $true }
( Get-RequiredServerFeaturesAndRoles ).Features | Should -Not -Contain 'Windows-Identity-Foundation'
Assert-MockCalled -ModuleName $moduleForMock -CommandName Test-IsWindowsServerCore -Scope It -Exactly 1
}
It "Does Not Return Web-Lgcy-Mgmt-Console on Windows Server Core" {
Mock -CommandName Test-IsWindowsServerCore -ModuleName $moduleForMock -MockWith { return $true }
( Get-RequiredServerFeaturesAndRoles ).Features | Should -Not -Contain 'Web-Lgcy-Mgmt-Console'
Assert-MockCalled -ModuleName $moduleForMock -CommandName Test-IsWindowsServerCore -Scope It -Exactly 1
}
}
}