ps/Modules/Alkami.PowerShell.Configuration/Public/Test-IsWindowsServer.tests.ps1

49 lines
1.6 KiB
PowerShell
Raw Permalink Normal View History

2023-05-30 22:51:22 -07:00
. $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 "Test-IsWindowsServer" {
Context "CIM Results" {
It "Returns True if The OS Product Type is 2" {
Mock -CommandName Get-CimInstance -MockWith {
[PSCustomObject]@{
ProductType = 2;
}
} -ModuleName $moduleForMock
Test-IsWindowsServer | Should -BeTrue
Assert-MockCalled -ModuleName $moduleForMock -CommandName Get-CimInstance -Scope It -Exactly 1
}
It "Returns True if The OS Product Type is 3" {
Mock -CommandName Get-CimInstance -MockWith {
[PSCustomObject]@{
ProductType = 3;
}
} -ModuleName $moduleForMock
Test-IsWindowsServer | Should -BeTrue
Assert-MockCalled -ModuleName $moduleForMock -CommandName Get-CimInstance -Scope It -Exactly 1
}
It "Returns False if The OS Product Type is 1" {
Mock -CommandName Get-CimInstance -MockWith {
[PSCustomObject]@{
ProductType = 1;
}
} -ModuleName $moduleForMock
Test-IsWindowsServer | Should -BeFalse
Assert-MockCalled -ModuleName $moduleForMock -CommandName Get-CimInstance -Scope It -Exactly 1
}
}
}