Tests/Unit/Public/ErrorHandling/Get-ErrorMessageFromErrorString.Tests.ps1
# Module: Orbit.Tools # Function: Test # Author: David Eberhardt # Updated: 03-JUN 2023 # Script Analyzer Exceptions #[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUserDeclaredVarsMoreThanAssignments', '', Justification = 'Context Boundaries')] # Unit Tests Describe -Tags ('Unit', 'Acceptance') "Function '$(((Split-Path -Leaf $PsCommandPath) -replace '\.Tests\.', '.') -replace '\.ps1', '')'" { InModuleScope -ModuleName 'Orbit.Tools' { BeforeAll { # Mocking basic connection commands to avoid connectivity related errors Mock Assert-GraphConnection -MockWith { $true } Mock Test-GraphConnection -MockWith { $true } Mock Assert-MicrosoftTeamsConnection -MockWith { $true } Mock Test-MicrosoftTeamsConnection -MockWith { $true } # Splatting Parameters $Params = @{ WarningAction = 'SilentlyContinue' InformationAction = 'SilentlyContinue' } # Dot Sourcing Mock Objects . "$(Split-Path -Parent ((Split-Path -Parent $PsScriptRoot) -split 'Tests')[0])\Orbit\Tests\Testing-MockedObjects.ps1" } Context 'Input' { # Pipeline, Position, etc. } Context 'Execution' { # Code Logic } Context 'Output' { #Properties, Values, Types it 'should return a string' { $ErrorString = @' REST API output is a multi-line String With ErrorMessage buried here Return Displaying only row 3 as message '@ $Output = Get-ErrorMessageFromErrorString -Exception $ErrorString $Output | Should -BeOfType [String] # $Output | Should -Be 'Return' # Unknown how to get \r out of there } } } } |