Formatting/ScriptCop.Test.Output.format.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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
[OutputType('ScriptCop.Test.Output')]
param()
$testOutput = $_
$in = $_
$writeColor = 
    if ($testOutput.Passed) {
        if (-not $host.UI.SupportsVirtualTerminal) { "DarkGreen" } else { "Success" }
    } else {
        if (-not $host.UI.SupportsVirtualTerminal) { "Red" } else { "Error" }
    }
$testStatus = 
    if ($testOutput.Passed) {
        "+"
    } else {
        ""
    }

@(if (-not ($Request -and $response)) {

    $msg = " [$testStatus] $($testOutput.TestCase)"
    if (-not $host.UI.SupportsVirtualTerminal) {
        Write-Host $msg -ForegroundColor $writeColor

        if ($test.Errors) {
            Write-Host "$($testOutput.Errors |Out-String)" -ForegroundColor $writeColor
        }
        ''

    } else {
        . $SetOutputStyle -foregroundColor $writeColor
        $msg
        #[Environment]::NewLine
        if ($testOutput.Errors) {
            
            $testOutput.Errors | Out-String -Width $host.UI.RawUI.BufferSize.Width
        }
        . $clearOutputStyle
    }
} else {
"
<div style='float:left;width:80%;font-size:1.11em'>
    <h4>
        $($testOutput.TestCase)
    </h4>
    $(if ($testOutput.Errors) {
"<pre>
$($testOutput.Errors | Out-String)
</pre>"
    })
</div>
<div style='float:right;width:20%;font-size:1.11em;text-align:right'>
    <span style='font-size:1.11em'>$testStatus</span>
</div>
<br style='clear:both' />
"

}) -join ''