ps/Modules/Alkami.PowerShell.Services/Public/Enable-Radium.Tests.ps1
2023-05-30 22:51:22 -07:00

26 lines
1.1 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 "Enable-Radium" -Tag 'Unit' {
Context "Logic" {
Mock -CommandName Enable-Service -MockWith {} -ModuleName $moduleForMock
Mock -CommandName "Get-Service" {
New-MockObject -Type System.ServiceProcess.ServiceController
} -ModuleName $moduleForMock
It "Calls Enable-Service with 'Alkami Radium Scheduler Service'" {
Enable-Radium
Assert-MockCalled -ModuleName $moduleForMock -CommandName Enable-Service -ParameterFilter { $service } -Scope It -Exactly 1
}
It "does nothing if Radium not found" {
Mock -CommandName "Get-Service" {return $null} -ModuleName $moduleForMock
Enable-Radium
Assert-MockCalled -ModuleName $moduleForMock -CommandName Enable-Service -ParameterFilter { $service } -Scope It -Exactly 0
}
}
}