microsoft/hve-core
Publicmirrored from https://github.com/microsoft/hve-coreAvailable
scripts/tests/Mocks/AnalyzerFixtures.psm1
38lines · modecode
| 1 | # Copyright (c) Microsoft Corporation. |
| 2 | # SPDX-License-Identifier: MIT |
| 3 | |
| 4 | # AnalyzerFixtures.psm1 |
| 5 | # |
| 6 | # Purpose: Reusable mock-object factories for PSScriptAnalyzer-related Pester tests. |
| 7 | # Author: HVE Core Team |
| 8 | # |
| 9 | |
| 10 | function New-MockAnalyzerIssue { |
| 11 | <# |
| 12 | .SYNOPSIS |
| 13 | Builds a PSScriptAnalyzer-shaped diagnostic record for use as a mock return value. |
| 14 | #> |
| 15 | [CmdletBinding()] |
| 16 | [OutputType([pscustomobject])] |
| 17 | param( |
| 18 | [string]$ScriptPath = 'test.ps1', |
| 19 | [ValidateRange(1, [int]::MaxValue)] |
| 20 | [int]$Line = 1, |
| 21 | [ValidateRange(1, [int]::MaxValue)] |
| 22 | [int]$Column = 1, |
| 23 | [string]$RuleName = 'TestRule', |
| 24 | [ValidateSet('ParseError', 'Error', 'Warning', 'Information')] |
| 25 | [string]$Severity = 'Warning', |
| 26 | [string]$Message = 'Test message' |
| 27 | ) |
| 28 | [PSCustomObject]@{ |
| 29 | ScriptPath = $ScriptPath |
| 30 | Line = $Line |
| 31 | Column = $Column |
| 32 | RuleName = $RuleName |
| 33 | Severity = $Severity |
| 34 | Message = $Message |
| 35 | } |
| 36 | } |
| 37 | |
| 38 | Export-ModuleMember -Function New-MockAnalyzerIssue |
| 39 | |