-
-
Save gerane/03557127aa13486270109029c9171633 to your computer and use it in GitHub Desktop.
Testing start service
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function EnsureServiceStarted { | |
param($Name) | |
Start-Service -name $name | |
$service = Get-Service -Name $name | |
$service.Status -eq [ServiceProcess.ServiceControllerStatus]::Running | |
} | |
Describe "Ensure service is started" { | |
It "Started service returns true" { | |
mock start-service {} | |
mock Get-Service { [pscustomObject]@{ Status = "Running" }} | |
EnsureServiceStarted "dummyName" | should be $true | |
} | |
It "Stopped service returns false" { | |
mock start-service {} | |
mock Get-Service { [pscustomObject]@{ Status = "Stopped" }} | |
EnsureServiceStarted "dummyName" | should be $false | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment