Last active
May 25, 2016 00:50
-
-
Save nohwnd/007a0dc22a59a1a4c0753dd899ccbac2 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