fix Format-Checklist bug and example.ps1 integration test script (#23)
parent
7f675f361d
commit
d5464fbae6
12
example.ps1
12
example.ps1
|
@ -2,6 +2,8 @@
|
|||
$ErrorActionPreference = "Stop"
|
||||
Import-Module "$PSScriptRoot\Requirements.psd1" -Force
|
||||
|
||||
|
||||
|
||||
$requirements = @(
|
||||
@{
|
||||
Name = "Resource 1"
|
||||
|
@ -19,13 +21,13 @@ $requirements = @(
|
|||
Name = "Resource 3"
|
||||
Describe = "Resource 3 is present in the system"
|
||||
Test = { $mySystem -contains 3 }
|
||||
Set = { $mySystem.Add(3) | Out-Null; Start-Sleep 1 }
|
||||
Set = { throw "This should not have been reached!"; Start-Sleep 1 }
|
||||
},
|
||||
@{
|
||||
Name = "Resource 4"
|
||||
Describe = "Resource 4 is present in the system"
|
||||
Test = { $mySystem -contains 4 }
|
||||
Set = { $mySystem.Add(4) | Out-Null; Start-Sleep 1 }
|
||||
Set = { throw "This should not have been reached!"; Start-Sleep 1 }
|
||||
},
|
||||
@{
|
||||
Name = "Resource 5"
|
||||
|
@ -37,14 +39,20 @@ $requirements = @(
|
|||
|
||||
# demo using Format-Table
|
||||
$mySystem = [System.Collections.ArrayList]::new()
|
||||
$mySystem.Add(3) | Out-Null
|
||||
$mySystem.Add(4) | Out-Null
|
||||
$requirements | Invoke-Requirement | Format-Table
|
||||
|
||||
# demo using Format-Checklist
|
||||
$mySystem = [System.Collections.ArrayList]::new()
|
||||
$mySystem.Add(3) | Out-Null
|
||||
$mySystem.Add(4) | Out-Null
|
||||
$requirements | Invoke-Requirement | Format-Checklist
|
||||
|
||||
# demo using Format-CallStack
|
||||
$mySystem = [System.Collections.ArrayList]::new()
|
||||
$mySystem.Add(3) | Out-Null
|
||||
$mySystem.Add(4) | Out-Null
|
||||
$requirements | Invoke-Requirement | Format-CallStack
|
||||
|
||||
# demo using Format-Callstack with nested requirements
|
||||
|
|
|
@ -38,6 +38,18 @@ function Format-Checklist {
|
|||
Write-Host $message -ForegroundColor $color -NoNewline
|
||||
$lastDescription = $description
|
||||
}
|
||||
"Stop" {
|
||||
switch ($result) {
|
||||
$true {
|
||||
$symbol = [char]8730
|
||||
$color = "Green"
|
||||
$message = "$timestamp [ $symbol ] $description"
|
||||
Write-Host "`r$(' ' * $lastDescription.Length)" -NoNewline
|
||||
Write-Host "`r$message" -ForegroundColor $color
|
||||
$lastDescription = $description
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
"Validate" {
|
||||
|
|
Loading…
Reference in New Issue