Private/Extract-VestDetails.ps1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# Collect and report on Vester test details within Get-VesterTest

function Extract-VestDetails {
    [CmdletBinding()]
    param (
        $Object
    )

    Write-Verbose "[Extract-VestDetails] $($Object.Name)"

    # Create $Title/$Description/$Type/$Actual/$Fix from the test file
    . $Object.FullName
                        
    # That doesn't work to find $Desired's value, so do it here
    $Desired = ((Select-String -Path $Object.FullName -Pattern 'Desired \=').Line -split ' ')[-1]

    # Output all properties for capturing in a $Vest variable
    [PSCustomObject]@{
        # Add a custom type name for this object
        # Used with DefaultDisplayPropertySet
        PSTypeName  = 'Vester.Test'
        Name        = $Object.Name
        Scope       = $Object.Scope
        FullName    = $Object.FullName
        Title       = $Title
        Description = $Description
        Desired     = $Desired
        Type        = $Type
        Actual      = $Actual.ToString().Trim()
        Fix         = $Fix.ToString().Trim()
    }
}