From c553fa071ffe5e44fb86aab9f44f0f55d42d4cae Mon Sep 17 00:00:00 2001 From: Oleg Tokar Date: Wed, 20 May 2026 10:50:26 +0300 Subject: [PATCH 1/2] [238] Get-IshDocumentObjData does not trim long FTITLE on PS 5.1 and when no trailing slash for FolderPath is provided - reduced MaximumFilePathSize --- .../GetIshDocumentObjData.Tests.ps1 | 162 +++++++++--------- .../HelperClasses/FileNameHelper.cs | 2 +- 2 files changed, 86 insertions(+), 78 deletions(-) diff --git a/Source/ISHRemote/Trisoft.ISHRemote/Cmdlets/DocumentObj/GetIshDocumentObjData.Tests.ps1 b/Source/ISHRemote/Trisoft.ISHRemote/Cmdlets/DocumentObj/GetIshDocumentObjData.Tests.ps1 index 61c80cd7..7476b835 100644 --- a/Source/ISHRemote/Trisoft.ISHRemote/Cmdlets/DocumentObj/GetIshDocumentObjData.Tests.ps1 +++ b/Source/ISHRemote/Trisoft.ISHRemote/Cmdlets/DocumentObj/GetIshDocumentObjData.Tests.ps1 @@ -1,89 +1,97 @@ BeforeAll { - $cmdletName = "Get-IshDocumentObjData" - Write-Host ("`r`nLoading ISHRemote.PesterSetup.ps1 on PSVersion[" + $psversionTable.PSVersion + "] over BeforeAll-block for MyCommand[" + $cmdletName + "]...") - . (Join-Path (Split-Path -Parent $PSCommandPath) "\..\..\ISHRemote.PesterSetup.ps1") +$cmdletName = "Get-IshDocumentObjData" +Write-Host ("`r`nLoading ISHRemote.PesterSetup.ps1 on PSVersion[" + $psversionTable.PSVersion + "] over BeforeAll-block for MyCommand[" + $cmdletName + "]...") +. (Join-Path (Split-Path -Parent $PSCommandPath) "\..\..\ISHRemote.PesterSetup.ps1") - Write-Host ("Running "+$cmdletName+" Test Data and Variables initialization") - $tempFolder = [System.IO.Path]::GetTempPath() +Write-Host ("Running "+$cmdletName+" Test Data and Variables initialization") +$tempFolder = [System.IO.Path]::GetTempPath() } Describe "Get-IshDocumentObjData" -Tags "Read" { - BeforeAll { - $requestedMetadata = Set-IshRequestedMetadataField -IshSession $ishSession -Name "FNAME" | - Set-IshRequestedMetadataField -IshSession $ishSession -Name "FDOCUMENTTYPE" | - Set-IshRequestedMetadataField -IshSession $ishSession -Name "READ-ACCESS" -ValueType Element | - Set-IshRequestedMetadataField -IshSession $ishSession -Name "FUSERGROUP" -ValueType Element - $ishFolderTestRootOriginal = Get-IshFolder -IShSession $ishSession -FolderPath $folderTestRootPath -RequestedMetadata $requestedMetadata - $folderIdTestRootOriginal = $ishFolderTestRootOriginal.IshFolderRef - $folderTypeTestRootOriginal = $ishFolderTestRootOriginal.IshFolderType - Write-Debug ("folderIdTestRootOriginal[" + $folderIdTestRootOriginal + "] folderTypeTestRootOriginal[" + $folderTypeTestRootOriginal + "]") - $ownedByTestRootOriginal = Get-IshMetadataField -IshSession $ishSession -Name "FUSERGROUP" -ValueType Element -IshField $ishFolderTestRootOriginal.IshField - $readAccessTestRootOriginal = (Get-IshMetadataField -IshSession $ishSession -Name "READ-ACCESS" -ValueType Element -IshField $ishFolderTestRootOriginal.IshField).Split($ishSession.Separator) +BeforeAll { +$requestedMetadata = Set-IshRequestedMetadataField -IshSession $ishSession -Name "FNAME" | +Set-IshRequestedMetadataField -IshSession $ishSession -Name "FDOCUMENTTYPE" | +Set-IshRequestedMetadataField -IshSession $ishSession -Name "READ-ACCESS" -ValueType Element | +Set-IshRequestedMetadataField -IshSession $ishSession -Name "FUSERGROUP" -ValueType Element +$ishFolderTestRootOriginal = Get-IshFolder -IShSession $ishSession -FolderPath $folderTestRootPath -RequestedMetadata $requestedMetadata +$folderIdTestRootOriginal = $ishFolderTestRootOriginal.IshFolderRef +$folderTypeTestRootOriginal = $ishFolderTestRootOriginal.IshFolderType +Write-Debug ("folderIdTestRootOriginal[" + $folderIdTestRootOriginal + "] folderTypeTestRootOriginal[" + $folderTypeTestRootOriginal + "]") +$ownedByTestRootOriginal = Get-IshMetadataField -IshSession $ishSession -Name "FUSERGROUP" -ValueType Element -IshField $ishFolderTestRootOriginal.IshField +$readAccessTestRootOriginal = (Get-IshMetadataField -IshSession $ishSession -Name "READ-ACCESS" -ValueType Element -IshField $ishFolderTestRootOriginal.IshField).Split($ishSession.Separator) - $global:ishFolderCmdlet = Add-IshFolder -IShSession $ishSession -ParentFolderId $folderIdTestRootOriginal -FolderType $folderTypeTestRootOriginal -FolderName $cmdletName -OwnedBy $ownedByTestRootOriginal -ReadAccess $readAccessTestRootOriginal - $ishFolderTopic = Add-IshFolder -IshSession $ishSession -ParentFolderId ($global:ishFolderCmdlet.IshFolderRef) -FolderType ISHModule -FolderName "Topic" -OwnedBy $ownedByTestRootOriginal -ReadAccess $readAccessTestRootOriginal - $ishFolderLib = Add-IshFolder -IshSession $ishSession -ParentFolderId ($global:ishFolderCmdlet.IshFolderRef) -FolderType ISHLibrary -FolderName "Library" -OwnedBy $ownedByTestRootOriginal -ReadAccess $readAccessTestRootOriginal +$global:ishFolderCmdlet = Add-IshFolder -IShSession $ishSession -ParentFolderId $folderIdTestRootOriginal -FolderType $folderTypeTestRootOriginal -FolderName $cmdletName -OwnedBy $ownedByTestRootOriginal -ReadAccess $readAccessTestRootOriginal +$ishFolderTopic = Add-IshFolder -IshSession $ishSession -ParentFolderId ($global:ishFolderCmdlet.IshFolderRef) -FolderType ISHModule -FolderName "Topic" -OwnedBy $ownedByTestRootOriginal -ReadAccess $readAccessTestRootOriginal +$ishFolderLib = Add-IshFolder -IshSession $ishSession -ParentFolderId ($global:ishFolderCmdlet.IshFolderRef) -FolderType ISHLibrary -FolderName "Library" -OwnedBy $ownedByTestRootOriginal -ReadAccess $readAccessTestRootOriginal - $ishTopicMetadata = Set-IshMetadataField -IshSession $ishSession -Name "FTITLE" -Level Logical -Value "Topic $timestamp" | - Set-IshMetadataField -IshSession $ishSession -Name "FAUTHOR" -Level Lng -ValueType Element -Value $ishUserAuthor | - Set-IshMetadataField -IshSession $ishSession -Name "FSTATUS" -Level Lng -ValueType Element -Value $ishStatusDraft - $ishObjectTopicA = Add-IshDocumentObj -IshSession $ishSession -FolderId $ishFolderTopic.IshFolderRef -IshType ISHModule -Lng $ishLng -Metadata $ishTopicMetadata -FileContent $ditaTopicFileContent - $ishObjectLibraryA = Add-IshDocumentObj -IshSession $ishSession -FolderId $ishFolderLib.IshFolderRef -IshType ISHLibrary -Lng $ishLng -Metadata $ishTopicMetadata -FileContent $ditaTopicFileContent - } - Context "Get-IshDocumentObjData FolderPathGroup" { - It "Parameter IshSession/IshObject invalid" { - { Get-IshDocumentObjData -IShSession "INVALIDISHSESSION" -IshObject "INVALIDISHOBJECT" } | Should -Throw - } - It "FileInfo.Name contains 4 = signs" { - $fileInfo = Get-IshDocumentObjData -IshSession $ishSession -IshObject $ishObjectTopicA -FolderPath (Join-Path $tempFolder $cmdletName) - $fileInfo.GetType().Name | Should -BeExactly "FileInfo" - $fileInfo.Name -like "*=*=*=*=*.*" | Should -Be $true - } - It "Parameter IshFeature matching features (so everything equals source file)" { - $ishFeatures = Set-IshFeature -Name "ISHRemoteStringCond" -Value "StringOne" | - Set-IshFeature -Name "ISHRemoteVersionCond" -Value "12.0.1" - $fileInfo = Get-IshDocumentObjData -IshSession $ishSession -IshObject $ishObjectTopicA -FolderPath (Join-Path $tempFolder $cmdletName) -IshFeature $ishFeatures - $fileContent = Get-Content $fileInfo -Raw - Write-Debug ("fileContent.Length[" + $fileContent.Length + "] fileContent.GetType()[" + $fileContent.GetType() + "] fileContent[" +$fileContent+"]") - ($fileContent -like "*ISHRemoteStringCond*") | Should -Be $true - } - It "Parameter IshFeature not matching features (so everything filtered away)" { - $ishFeatures = Set-IshFeature -Name "INVALIDFEATURE" -Value "INVALIDVALUE" - $fileInfo = Get-IshDocumentObjData -IshSession $ishSession -IshObject $ishObjectTopicA -FolderPath (Join-Path $tempFolder $cmdletName) -IshFeature $ishFeatures - $fileContent = Get-Content $fileInfo -Raw - Write-Debug ("fileContent.Length[" + $fileContent.Length + "] fileContent.GetType()[" + $fileContent.GetType() + "] fileContent[" +$fileContent+"]") - $fileContent -notlike "*ISHRemoteStringCond*" | Should -Be $true - } - } - Context "Get-IshDocumentObjData IshObjectGroup" { - It "GetType().Name" { - $ishobjects = Get-IshDocumentObjData -IshSession $ishSession -IshObject @($ishObjectTopicA,$ishObjectLibraryA) - $ishobjects.GetType().Name | Should -BeExactly "Object[]" - } - It "Parameter IshObject Single with implicit IshSession" { - $ishobjects = Get-IshDocumentObjData -IshObject $ishObjectTopicA - $ishobjects.Count | Should -Be 1 - } - It "Parameter IshObject Multiple with implicit IshSession" { - $ishobjects = Get-IshDocumentObjData -IshObject @($ishObjectTopicA,$ishObjectLibraryA) - $ishobjects.Count | Should -Be 2 - } - It "Pipeline IshObject Single" { - $ishobjects = $ishObjectTopicA | Get-IshDocumentObjData -IshSession $ishSession - $ishobjects.Count | Should -Be 1 - } - It "Pipeline IshObject Multiple" { - $ishobjects = @($ishObjectTopicA,$ishObjectLibraryA) | Get-IshDocumentObjData -IshSession $ishSession - $ishobjects.Count | Should -Be 2 - } - } +$ishTopicMetadata = Set-IshMetadataField -IshSession $ishSession -Name "FTITLE" -Level Logical -Value "Topic $timestamp" | +Set-IshMetadataField -IshSession $ishSession -Name "FAUTHOR" -Level Lng -ValueType Element -Value $ishUserAuthor | +Set-IshMetadataField -IshSession $ishSession -Name "FSTATUS" -Level Lng -ValueType Element -Value $ishStatusDraft +$ishObjectTopicA = Add-IshDocumentObj -IshSession $ishSession -FolderId $ishFolderTopic.IshFolderRef -IshType ISHModule -Lng $ishLng -Metadata $ishTopicMetadata -FileContent $ditaTopicFileContent +$ishObjectLibraryA = Add-IshDocumentObj -IshSession $ishSession -FolderId $ishFolderLib.IshFolderRef -IshType ISHLibrary -Lng $ishLng -Metadata $ishTopicMetadata -FileContent $ditaTopicFileContent +$ishLongTitleMetadata = Set-IshMetadataField -IshSession $ishSession -Name "FTITLE" -Level Logical -Value ("LongTitle" + ("A" * 250)) | +Set-IshMetadataField -IshSession $ishSession -Name "FAUTHOR" -Level Lng -ValueType Element -Value $ishUserAuthor | +Set-IshMetadataField -IshSession $ishSession -Name "FSTATUS" -Level Lng -ValueType Element -Value $ishStatusDraft +$ishObjectLongTitleTopic = Add-IshDocumentObj -IshSession $ishSession -FolderId $ishFolderTopic.IshFolderRef -IshType ISHModule -Lng $ishLng -Metadata $ishLongTitleMetadata -FileContent $ditaTopicFileContent +} +Context "Get-IshDocumentObjData FolderPathGroup" { +It "Parameter IshSession/IshObject invalid" { +{ Get-IshDocumentObjData -IShSession "INVALIDISHSESSION" -IshObject "INVALIDISHOBJECT" } | Should -Throw +} +It "FileInfo.Name contains 4 = signs" { +$fileInfo = Get-IshDocumentObjData -IshSession $ishSession -IshObject $ishObjectTopicA -FolderPath (Join-Path $tempFolder $cmdletName) +$fileInfo.GetType().Name | Should -BeExactly "FileInfo" +$fileInfo.Name -like "*=*=*=*=*.*" | Should -Be $true +} +It "Parameter IshFeature matching features (so everything equals source file)" { +$ishFeatures = Set-IshFeature -Name "ISHRemoteStringCond" -Value "StringOne" | + Set-IshFeature -Name "ISHRemoteVersionCond" -Value "12.0.1" +$fileInfo = Get-IshDocumentObjData -IshSession $ishSession -IshObject $ishObjectTopicA -FolderPath (Join-Path $tempFolder $cmdletName) -IshFeature $ishFeatures +$fileContent = Get-Content $fileInfo -Raw +Write-Debug ("fileContent.Length[" + $fileContent.Length + "] fileContent.GetType()[" + $fileContent.GetType() + "] fileContent[" +$fileContent+"]") +($fileContent -like "*ISHRemoteStringCond*") | Should -Be $true +} +It "Parameter IshFeature not matching features (so everything filtered away)" { +$ishFeatures = Set-IshFeature -Name "INVALIDFEATURE" -Value "INVALIDVALUE" +$fileInfo = Get-IshDocumentObjData -IshSession $ishSession -IshObject $ishObjectTopicA -FolderPath (Join-Path $tempFolder $cmdletName) -IshFeature $ishFeatures +$fileContent = Get-Content $fileInfo -Raw +Write-Debug ("fileContent.Length[" + $fileContent.Length + "] fileContent.GetType()[" + $fileContent.GetType() + "] fileContent[" +$fileContent+"]") +$fileContent -notlike "*ISHRemoteStringCond*" | Should -Be $true +} +It "FolderPath with long FTITLE returns FileInfo without PathTooLongException" { +$fileInfo = Get-IshDocumentObjData -IshSession $ishSession -IshObject $ishObjectLongTitleTopic -FolderPath (Join-Path $tempFolder $cmdletName) +$fileInfo.GetType().Name | Should -BeExactly "FileInfo" +} +} +Context "Get-IshDocumentObjData IshObjectGroup" { +It "GetType().Name" { +$ishobjects = Get-IshDocumentObjData -IshSession $ishSession -IshObject @($ishObjectTopicA,$ishObjectLibraryA) +$ishobjects.GetType().Name | Should -BeExactly "Object[]" +} +It "Parameter IshObject Single with implicit IshSession" { +$ishobjects = Get-IshDocumentObjData -IshObject $ishObjectTopicA +$ishobjects.Count | Should -Be 1 +} +It "Parameter IshObject Multiple with implicit IshSession" { +$ishobjects = Get-IshDocumentObjData -IshObject @($ishObjectTopicA,$ishObjectLibraryA) +$ishobjects.Count | Should -Be 2 +} +It "Pipeline IshObject Single" { +$ishobjects = $ishObjectTopicA | Get-IshDocumentObjData -IshSession $ishSession +$ishobjects.Count | Should -Be 1 +} +It "Pipeline IshObject Multiple" { +$ishobjects = @($ishObjectTopicA,$ishObjectLibraryA) | Get-IshDocumentObjData -IshSession $ishSession +$ishobjects.Count | Should -Be 2 +} +} } AfterAll { - Write-Host ("Running "+$cmdletName+" Test Data and Variables cleanup") - $folderCmdletRootPath = (Join-Path $folderTestRootPath $cmdletName) - try { Get-IshFolder -IshSession $ishSession -FolderPath $folderCmdletRootPath -Recurse | Get-IshFolderContent -IshSession $ishSession | Remove-IshDocumentObj -IshSession $ishSession -Force } catch { } - try { Remove-IshFolder -IshSession $ishSession -FolderPath $folderCmdletRootPath -Recurse } catch { } - try { Remove-Item (Join-Path $tempFolder $cmdletName) -Recurse -Force } catch { } +Write-Host ("Running "+$cmdletName+" Test Data and Variables cleanup") +$folderCmdletRootPath = (Join-Path $folderTestRootPath $cmdletName) +try { Get-IshFolder -IshSession $ishSession -FolderPath $folderCmdletRootPath -Recurse | Get-IshFolderContent -IshSession $ishSession | Remove-IshDocumentObj -IshSession $ishSession -Force } catch { } +try { Remove-IshFolder -IshSession $ishSession -FolderPath $folderCmdletRootPath -Recurse } catch { } +try { Remove-Item (Join-Path $tempFolder $cmdletName) -Recurse -Force } catch { } } diff --git a/Source/ISHRemote/Trisoft.ISHRemote/HelperClasses/FileNameHelper.cs b/Source/ISHRemote/Trisoft.ISHRemote/HelperClasses/FileNameHelper.cs index a55bfa2a..619013da 100644 --- a/Source/ISHRemote/Trisoft.ISHRemote/HelperClasses/FileNameHelper.cs +++ b/Source/ISHRemote/Trisoft.ISHRemote/HelperClasses/FileNameHelper.cs @@ -29,7 +29,7 @@ namespace Trisoft.ISHRemote.HelperClasses internal static class FileNameHelper { private const int MaximumFolderPathSize = 248; - private const int MaximumFilePathSize = 260; + private const int MaximumFilePathSize = 259; private const int MaximumFileNameSize = 120; From 6b8092664da909b351228d4164e2a61ab2372e42 Mon Sep 17 00:00:00 2001 From: OlegTokar Date: Wed, 20 May 2026 11:22:02 +0300 Subject: [PATCH 2/2] [238] fix formatting --- .../GetIshDocumentObjData.Tests.ps1 | 171 +++++++++--------- 1 file changed, 86 insertions(+), 85 deletions(-) diff --git a/Source/ISHRemote/Trisoft.ISHRemote/Cmdlets/DocumentObj/GetIshDocumentObjData.Tests.ps1 b/Source/ISHRemote/Trisoft.ISHRemote/Cmdlets/DocumentObj/GetIshDocumentObjData.Tests.ps1 index 7476b835..4a834e80 100644 --- a/Source/ISHRemote/Trisoft.ISHRemote/Cmdlets/DocumentObj/GetIshDocumentObjData.Tests.ps1 +++ b/Source/ISHRemote/Trisoft.ISHRemote/Cmdlets/DocumentObj/GetIshDocumentObjData.Tests.ps1 @@ -1,97 +1,98 @@ BeforeAll { -$cmdletName = "Get-IshDocumentObjData" -Write-Host ("`r`nLoading ISHRemote.PesterSetup.ps1 on PSVersion[" + $psversionTable.PSVersion + "] over BeforeAll-block for MyCommand[" + $cmdletName + "]...") -. (Join-Path (Split-Path -Parent $PSCommandPath) "\..\..\ISHRemote.PesterSetup.ps1") + $cmdletName = "Get-IshDocumentObjData" + Write-Host ("`r`nLoading ISHRemote.PesterSetup.ps1 on PSVersion[" + $psversionTable.PSVersion + "] over BeforeAll-block for MyCommand[" + $cmdletName + "]...") + . (Join-Path (Split-Path -Parent $PSCommandPath) "\..\..\ISHRemote.PesterSetup.ps1") -Write-Host ("Running "+$cmdletName+" Test Data and Variables initialization") -$tempFolder = [System.IO.Path]::GetTempPath() + Write-Host ("Running "+$cmdletName+" Test Data and Variables initialization") + $tempFolder = [System.IO.Path]::GetTempPath() } Describe "Get-IshDocumentObjData" -Tags "Read" { -BeforeAll { -$requestedMetadata = Set-IshRequestedMetadataField -IshSession $ishSession -Name "FNAME" | -Set-IshRequestedMetadataField -IshSession $ishSession -Name "FDOCUMENTTYPE" | -Set-IshRequestedMetadataField -IshSession $ishSession -Name "READ-ACCESS" -ValueType Element | -Set-IshRequestedMetadataField -IshSession $ishSession -Name "FUSERGROUP" -ValueType Element -$ishFolderTestRootOriginal = Get-IshFolder -IShSession $ishSession -FolderPath $folderTestRootPath -RequestedMetadata $requestedMetadata -$folderIdTestRootOriginal = $ishFolderTestRootOriginal.IshFolderRef -$folderTypeTestRootOriginal = $ishFolderTestRootOriginal.IshFolderType -Write-Debug ("folderIdTestRootOriginal[" + $folderIdTestRootOriginal + "] folderTypeTestRootOriginal[" + $folderTypeTestRootOriginal + "]") -$ownedByTestRootOriginal = Get-IshMetadataField -IshSession $ishSession -Name "FUSERGROUP" -ValueType Element -IshField $ishFolderTestRootOriginal.IshField -$readAccessTestRootOriginal = (Get-IshMetadataField -IshSession $ishSession -Name "READ-ACCESS" -ValueType Element -IshField $ishFolderTestRootOriginal.IshField).Split($ishSession.Separator) + BeforeAll { + $requestedMetadata = Set-IshRequestedMetadataField -IshSession $ishSession -Name "FNAME" | + Set-IshRequestedMetadataField -IshSession $ishSession -Name "FDOCUMENTTYPE" | + Set-IshRequestedMetadataField -IshSession $ishSession -Name "READ-ACCESS" -ValueType Element | + Set-IshRequestedMetadataField -IshSession $ishSession -Name "FUSERGROUP" -ValueType Element + $ishFolderTestRootOriginal = Get-IshFolder -IShSession $ishSession -FolderPath $folderTestRootPath -RequestedMetadata $requestedMetadata + $folderIdTestRootOriginal = $ishFolderTestRootOriginal.IshFolderRef + $folderTypeTestRootOriginal = $ishFolderTestRootOriginal.IshFolderType + Write-Debug ("folderIdTestRootOriginal[" + $folderIdTestRootOriginal + "] folderTypeTestRootOriginal[" + $folderTypeTestRootOriginal + "]") + $ownedByTestRootOriginal = Get-IshMetadataField -IshSession $ishSession -Name "FUSERGROUP" -ValueType Element -IshField $ishFolderTestRootOriginal.IshField + $readAccessTestRootOriginal = (Get-IshMetadataField -IshSession $ishSession -Name "READ-ACCESS" -ValueType Element -IshField $ishFolderTestRootOriginal.IshField).Split($ishSession.Separator) -$global:ishFolderCmdlet = Add-IshFolder -IShSession $ishSession -ParentFolderId $folderIdTestRootOriginal -FolderType $folderTypeTestRootOriginal -FolderName $cmdletName -OwnedBy $ownedByTestRootOriginal -ReadAccess $readAccessTestRootOriginal -$ishFolderTopic = Add-IshFolder -IshSession $ishSession -ParentFolderId ($global:ishFolderCmdlet.IshFolderRef) -FolderType ISHModule -FolderName "Topic" -OwnedBy $ownedByTestRootOriginal -ReadAccess $readAccessTestRootOriginal -$ishFolderLib = Add-IshFolder -IshSession $ishSession -ParentFolderId ($global:ishFolderCmdlet.IshFolderRef) -FolderType ISHLibrary -FolderName "Library" -OwnedBy $ownedByTestRootOriginal -ReadAccess $readAccessTestRootOriginal + $global:ishFolderCmdlet = Add-IshFolder -IShSession $ishSession -ParentFolderId $folderIdTestRootOriginal -FolderType $folderTypeTestRootOriginal -FolderName $cmdletName -OwnedBy $ownedByTestRootOriginal -ReadAccess $readAccessTestRootOriginal + $ishFolderTopic = Add-IshFolder -IshSession $ishSession -ParentFolderId ($global:ishFolderCmdlet.IshFolderRef) -FolderType ISHModule -FolderName "Topic" -OwnedBy $ownedByTestRootOriginal -ReadAccess $readAccessTestRootOriginal + $ishFolderLib = Add-IshFolder -IshSession $ishSession -ParentFolderId ($global:ishFolderCmdlet.IshFolderRef) -FolderType ISHLibrary -FolderName "Library" -OwnedBy $ownedByTestRootOriginal -ReadAccess $readAccessTestRootOriginal -$ishTopicMetadata = Set-IshMetadataField -IshSession $ishSession -Name "FTITLE" -Level Logical -Value "Topic $timestamp" | -Set-IshMetadataField -IshSession $ishSession -Name "FAUTHOR" -Level Lng -ValueType Element -Value $ishUserAuthor | -Set-IshMetadataField -IshSession $ishSession -Name "FSTATUS" -Level Lng -ValueType Element -Value $ishStatusDraft -$ishObjectTopicA = Add-IshDocumentObj -IshSession $ishSession -FolderId $ishFolderTopic.IshFolderRef -IshType ISHModule -Lng $ishLng -Metadata $ishTopicMetadata -FileContent $ditaTopicFileContent -$ishObjectLibraryA = Add-IshDocumentObj -IshSession $ishSession -FolderId $ishFolderLib.IshFolderRef -IshType ISHLibrary -Lng $ishLng -Metadata $ishTopicMetadata -FileContent $ditaTopicFileContent -$ishLongTitleMetadata = Set-IshMetadataField -IshSession $ishSession -Name "FTITLE" -Level Logical -Value ("LongTitle" + ("A" * 250)) | -Set-IshMetadataField -IshSession $ishSession -Name "FAUTHOR" -Level Lng -ValueType Element -Value $ishUserAuthor | -Set-IshMetadataField -IshSession $ishSession -Name "FSTATUS" -Level Lng -ValueType Element -Value $ishStatusDraft -$ishObjectLongTitleTopic = Add-IshDocumentObj -IshSession $ishSession -FolderId $ishFolderTopic.IshFolderRef -IshType ISHModule -Lng $ishLng -Metadata $ishLongTitleMetadata -FileContent $ditaTopicFileContent -} -Context "Get-IshDocumentObjData FolderPathGroup" { -It "Parameter IshSession/IshObject invalid" { -{ Get-IshDocumentObjData -IShSession "INVALIDISHSESSION" -IshObject "INVALIDISHOBJECT" } | Should -Throw -} -It "FileInfo.Name contains 4 = signs" { -$fileInfo = Get-IshDocumentObjData -IshSession $ishSession -IshObject $ishObjectTopicA -FolderPath (Join-Path $tempFolder $cmdletName) -$fileInfo.GetType().Name | Should -BeExactly "FileInfo" -$fileInfo.Name -like "*=*=*=*=*.*" | Should -Be $true -} -It "Parameter IshFeature matching features (so everything equals source file)" { -$ishFeatures = Set-IshFeature -Name "ISHRemoteStringCond" -Value "StringOne" | - Set-IshFeature -Name "ISHRemoteVersionCond" -Value "12.0.1" -$fileInfo = Get-IshDocumentObjData -IshSession $ishSession -IshObject $ishObjectTopicA -FolderPath (Join-Path $tempFolder $cmdletName) -IshFeature $ishFeatures -$fileContent = Get-Content $fileInfo -Raw -Write-Debug ("fileContent.Length[" + $fileContent.Length + "] fileContent.GetType()[" + $fileContent.GetType() + "] fileContent[" +$fileContent+"]") -($fileContent -like "*ISHRemoteStringCond*") | Should -Be $true -} -It "Parameter IshFeature not matching features (so everything filtered away)" { -$ishFeatures = Set-IshFeature -Name "INVALIDFEATURE" -Value "INVALIDVALUE" -$fileInfo = Get-IshDocumentObjData -IshSession $ishSession -IshObject $ishObjectTopicA -FolderPath (Join-Path $tempFolder $cmdletName) -IshFeature $ishFeatures -$fileContent = Get-Content $fileInfo -Raw -Write-Debug ("fileContent.Length[" + $fileContent.Length + "] fileContent.GetType()[" + $fileContent.GetType() + "] fileContent[" +$fileContent+"]") -$fileContent -notlike "*ISHRemoteStringCond*" | Should -Be $true -} -It "FolderPath with long FTITLE returns FileInfo without PathTooLongException" { -$fileInfo = Get-IshDocumentObjData -IshSession $ishSession -IshObject $ishObjectLongTitleTopic -FolderPath (Join-Path $tempFolder $cmdletName) -$fileInfo.GetType().Name | Should -BeExactly "FileInfo" -} -} -Context "Get-IshDocumentObjData IshObjectGroup" { -It "GetType().Name" { -$ishobjects = Get-IshDocumentObjData -IshSession $ishSession -IshObject @($ishObjectTopicA,$ishObjectLibraryA) -$ishobjects.GetType().Name | Should -BeExactly "Object[]" -} -It "Parameter IshObject Single with implicit IshSession" { -$ishobjects = Get-IshDocumentObjData -IshObject $ishObjectTopicA -$ishobjects.Count | Should -Be 1 -} -It "Parameter IshObject Multiple with implicit IshSession" { -$ishobjects = Get-IshDocumentObjData -IshObject @($ishObjectTopicA,$ishObjectLibraryA) -$ishobjects.Count | Should -Be 2 -} -It "Pipeline IshObject Single" { -$ishobjects = $ishObjectTopicA | Get-IshDocumentObjData -IshSession $ishSession -$ishobjects.Count | Should -Be 1 -} -It "Pipeline IshObject Multiple" { -$ishobjects = @($ishObjectTopicA,$ishObjectLibraryA) | Get-IshDocumentObjData -IshSession $ishSession -$ishobjects.Count | Should -Be 2 -} -} + $ishTopicMetadata = Set-IshMetadataField -IshSession $ishSession -Name "FTITLE" -Level Logical -Value "Topic $timestamp" | + Set-IshMetadataField -IshSession $ishSession -Name "FAUTHOR" -Level Lng -ValueType Element -Value $ishUserAuthor | + Set-IshMetadataField -IshSession $ishSession -Name "FSTATUS" -Level Lng -ValueType Element -Value $ishStatusDraft + $ishObjectTopicA = Add-IshDocumentObj -IshSession $ishSession -FolderId $ishFolderTopic.IshFolderRef -IshType ISHModule -Lng $ishLng -Metadata $ishTopicMetadata -FileContent $ditaTopicFileContent + $ishObjectLibraryA = Add-IshDocumentObj -IshSession $ishSession -FolderId $ishFolderLib.IshFolderRef -IshType ISHLibrary -Lng $ishLng -Metadata $ishTopicMetadata -FileContent $ditaTopicFileContent + + $ishLongTitleMetadata = Set-IshMetadataField -IshSession $ishSession -Name "FTITLE" -Level Logical -Value ("LongTitle" + ("A" * 250)) | + Set-IshMetadataField -IshSession $ishSession -Name "FAUTHOR" -Level Lng -ValueType Element -Value $ishUserAuthor | + Set-IshMetadataField -IshSession $ishSession -Name "FSTATUS" -Level Lng -ValueType Element -Value $ishStatusDraft + $ishObjectLongTitleTopic = Add-IshDocumentObj -IshSession $ishSession -FolderId $ishFolderTopic.IshFolderRef -IshType ISHModule -Lng $ishLng -Metadata $ishLongTitleMetadata -FileContent $ditaTopicFileContent + } + Context "Get-IshDocumentObjData FolderPathGroup" { + It "Parameter IshSession/IshObject invalid" { + { Get-IshDocumentObjData -IShSession "INVALIDISHSESSION" -IshObject "INVALIDISHOBJECT" } | Should -Throw + } + It "FileInfo.Name contains 4 = signs" { + $fileInfo = Get-IshDocumentObjData -IshSession $ishSession -IshObject $ishObjectTopicA -FolderPath (Join-Path $tempFolder $cmdletName) + $fileInfo.GetType().Name | Should -BeExactly "FileInfo" + $fileInfo.Name -like "*=*=*=*=*.*" | Should -Be $true + } + It "Parameter IshFeature matching features (so everything equals source file)" { + $ishFeatures = Set-IshFeature -Name "ISHRemoteStringCond" -Value "StringOne" | + Set-IshFeature -Name "ISHRemoteVersionCond" -Value "12.0.1" + $fileInfo = Get-IshDocumentObjData -IshSession $ishSession -IshObject $ishObjectTopicA -FolderPath (Join-Path $tempFolder $cmdletName) -IshFeature $ishFeatures + $fileContent = Get-Content $fileInfo -Raw + Write-Debug ("fileContent.Length[" + $fileContent.Length + "] fileContent.GetType()[" + $fileContent.GetType() + "] fileContent[" +$fileContent+"]") + ($fileContent -like "*ISHRemoteStringCond*") | Should -Be $true + } + It "Parameter IshFeature not matching features (so everything filtered away)" { + $ishFeatures = Set-IshFeature -Name "INVALIDFEATURE" -Value "INVALIDVALUE" + $fileInfo = Get-IshDocumentObjData -IshSession $ishSession -IshObject $ishObjectTopicA -FolderPath (Join-Path $tempFolder $cmdletName) -IshFeature $ishFeatures + $fileContent = Get-Content $fileInfo -Raw + Write-Debug ("fileContent.Length[" + $fileContent.Length + "] fileContent.GetType()[" + $fileContent.GetType() + "] fileContent[" +$fileContent+"]") + $fileContent -notlike "*ISHRemoteStringCond*" | Should -Be $true + } + It "FolderPath with long FTITLE returns FileInfo without PathTooLongException" { + $fileInfo = Get-IshDocumentObjData -IshSession $ishSession -IshObject $ishObjectLongTitleTopic -FolderPath (Join-Path $tempFolder $cmdletName) + $fileInfo.GetType().Name | Should -BeExactly "FileInfo" + } + } + Context "Get-IshDocumentObjData IshObjectGroup" { + It "GetType().Name" { + $ishobjects = Get-IshDocumentObjData -IshSession $ishSession -IshObject @($ishObjectTopicA,$ishObjectLibraryA) + $ishobjects.GetType().Name | Should -BeExactly "Object[]" + } + It "Parameter IshObject Single with implicit IshSession" { + $ishobjects = Get-IshDocumentObjData -IshObject $ishObjectTopicA + $ishobjects.Count | Should -Be 1 + } + It "Parameter IshObject Multiple with implicit IshSession" { + $ishobjects = Get-IshDocumentObjData -IshObject @($ishObjectTopicA,$ishObjectLibraryA) + $ishobjects.Count | Should -Be 2 + } + It "Pipeline IshObject Single" { + $ishobjects = $ishObjectTopicA | Get-IshDocumentObjData -IshSession $ishSession + $ishobjects.Count | Should -Be 1 + } + It "Pipeline IshObject Multiple" { + $ishobjects = @($ishObjectTopicA,$ishObjectLibraryA) | Get-IshDocumentObjData -IshSession $ishSession + $ishobjects.Count | Should -Be 2 + } + } } AfterAll { -Write-Host ("Running "+$cmdletName+" Test Data and Variables cleanup") -$folderCmdletRootPath = (Join-Path $folderTestRootPath $cmdletName) -try { Get-IshFolder -IshSession $ishSession -FolderPath $folderCmdletRootPath -Recurse | Get-IshFolderContent -IshSession $ishSession | Remove-IshDocumentObj -IshSession $ishSession -Force } catch { } -try { Remove-IshFolder -IshSession $ishSession -FolderPath $folderCmdletRootPath -Recurse } catch { } -try { Remove-Item (Join-Path $tempFolder $cmdletName) -Recurse -Force } catch { } + Write-Host ("Running "+$cmdletName+" Test Data and Variables cleanup") + $folderCmdletRootPath = (Join-Path $folderTestRootPath $cmdletName) + try { Get-IshFolder -IshSession $ishSession -FolderPath $folderCmdletRootPath -Recurse | Get-IshFolderContent -IshSession $ishSession | Remove-IshDocumentObj -IshSession $ishSession -Force } catch { } + try { Remove-IshFolder -IshSession $ishSession -FolderPath $folderCmdletRootPath -Recurse } catch { } + try { Remove-Item (Join-Path $tempFolder $cmdletName) -Recurse -Force } catch { } }