Tests/Unit/Private/ConvertFrom-SIAResponse.Tests.ps1
|
BeforeAll { $moduleRoot = (Resolve-Path (Join-Path $PSScriptRoot '../../..')).Path Import-Module (Join-Path $moduleRoot 'psSIA.psd1') -Force } Describe 'ConvertFrom-SIAResponse' { It 'stamps the requested type name onto a single object' { InModuleScope psSIA { $result = [pscustomobject]@{ id = '1' } | ConvertFrom-SIAResponse -TypeName 'psSIA.Connector' $result.PSObject.TypeNames | Should -Contain 'psSIA.Connector' } } It 'stamps the type name onto every object passed through the pipeline' { InModuleScope psSIA { $results = @([pscustomobject]@{ id = '1' }, [pscustomobject]@{ id = '2' }) | ConvertFrom-SIAResponse -TypeName 'psSIA.Connector' $results | ForEach-Object { $_.PSObject.TypeNames | Should -Contain 'psSIA.Connector' } } } It 'does not modify properties' { InModuleScope psSIA { $result = [pscustomobject]@{ id = '1'; status = 'Active' } | ConvertFrom-SIAResponse -TypeName 'psSIA.Connector' $result.id | Should -Be '1' $result.status | Should -Be 'Active' } } It 'passes objects through unchanged when no type name is given' { InModuleScope psSIA { $testObject = [pscustomobject]@{ id = '1' } $result = $testObject | ConvertFrom-SIAResponse $result.PSObject.TypeNames[0] | Should -Not -Be 'psSIA.Connector' } } It 'returns nothing for a null input' { InModuleScope psSIA { $result = ConvertFrom-SIAResponse -InputObject $null -TypeName 'psSIA.Connector' $result | Should -BeNullOrEmpty } } } |