mirror of
https://github.com/PowerShell/PowerShell
synced 2026-06-08 12:12:50 +00:00
migrated tests run clean on all platforms (locally)
This commit is contained in:
committed by
James Truher
parent
0261372bae
commit
ce4303b873
+225
-210
@@ -4,33 +4,40 @@
|
||||
# used for validating Microsoft.PowerShell.Archive module.
|
||||
############################################################################################>
|
||||
$script:TestSourceRoot = $PSScriptRoot
|
||||
Describe "Test suite for Microsoft.PowerShell.Archive module" -Tags "BVT" {
|
||||
Describe "Test suite for Microsoft.PowerShell.Archive module" -Tags "CI" {
|
||||
|
||||
AfterAll {
|
||||
$global:ProgressPreference = $_progressPreference
|
||||
}
|
||||
BeforeAll {
|
||||
# Write-Progress not supported yet on Core
|
||||
$_progressPreference = $ProgressPreference
|
||||
if ( $IsCore ) { $global:ProgressPreference = "SilentlyContinue" }
|
||||
|
||||
Setup -d SourceDir
|
||||
Setup -d SourceDir/ChildDir-1
|
||||
Setup -d SourceDir/ChildDir-2
|
||||
Setup -d SourceDir/ChildEmptyDir
|
||||
|
||||
New-Item $TestDrive\SourceDir -Type Directory | Out-Null
|
||||
New-Item $TestDrive\SourceDir\ChildDir-1 -Type Directory | Out-Null
|
||||
New-Item $TestDrive\SourceDir\ChildDir-2 -Type Directory | Out-Null
|
||||
New-Item $TestDrive\SourceDir\ChildEmptyDir -Type Directory | Out-Null
|
||||
|
||||
$content = "Some Data"
|
||||
$content | Out-File -FilePath $TestDrive\SourceDir\Sample-1.txt
|
||||
$content | Out-File -FilePath $TestDrive\SourceDir\Sample-2.txt
|
||||
$content | Out-File -FilePath $TestDrive\SourceDir\ChildDir-1\Sample-3.txt
|
||||
$content | Out-File -FilePath $TestDrive\SourceDir\ChildDir-1\Sample-4.txt
|
||||
$content | Out-File -FilePath $TestDrive\SourceDir\ChildDir-2\Sample-5.txt
|
||||
$content | Out-File -FilePath $TestDrive\SourceDir\ChildDir-2\Sample-6.txt
|
||||
|
||||
"Some Text" > $TestDrive\Sample.unzip
|
||||
"Some Text" > $TestDrive\Sample.cab
|
||||
$Files = ( [io.path]::Combine("SourceDir","Sample-1.txt")), ([io.path]::Combine("SourceDir","Sample-2.txt")),
|
||||
([io.path]::Combine("SourceDir","ChildDir-1","Sample-3.txt")), ([io.path]::Combine("SourceDir","ChildDir-1","Sample-4.txt")),
|
||||
([io.path]::Combine("SourceDir","ChildDir-2","Sample-5.txt")), ([io.path]::Combine("SourceDir","ChildDir-2","Sample-6.txt"))
|
||||
|
||||
foreach($file in $files ) {
|
||||
Setup -f $file -content $content
|
||||
}
|
||||
|
||||
Setup -f Sample.unzip -content "Some Text"
|
||||
Setup -f Sample.cab -content "Some Text"
|
||||
|
||||
$preCreatedArchivePath = Join-Path $script:TestSourceRoot "SamplePreCreatedArchive.archive"
|
||||
Copy-Item $preCreatedArchivePath $TestDrive\SamplePreCreatedArchive.zip -Force
|
||||
Copy-Item $preCreatedArchivePath $TestDrive/SamplePreCreatedArchive.zip -Force
|
||||
}
|
||||
|
||||
function Add-CompressionAssemblies {
|
||||
Add-Type -AssemblyName System.IO.Compression
|
||||
if ($psedition -eq "Core")
|
||||
if (($psedition -eq "Core") -or $IsCore )
|
||||
{
|
||||
Add-Type -AssemblyName System.IO.Compression.ZipFile
|
||||
}
|
||||
@@ -155,7 +162,7 @@ Describe "Test suite for Microsoft.PowerShell.Archive module" -Tags "BVT" {
|
||||
Add-CompressionAssemblies
|
||||
try
|
||||
{
|
||||
$destFile = "$TestDrive\ExpandedFile"+([System.Guid]::NewGuid().ToString())+".txt"
|
||||
$destFile = "$TestDrive/ExpandedFile"+([System.Guid]::NewGuid().ToString())+".txt"
|
||||
|
||||
$archiveFileStreamArgs = @($path, [System.IO.FileMode]::Open)
|
||||
$archiveFileStream = New-Object -TypeName System.IO.FileStream -ArgumentList $archiveFileStreamArgs
|
||||
@@ -223,8 +230,8 @@ Describe "Test suite for Microsoft.PowerShell.Archive module" -Tags "BVT" {
|
||||
Context "Compress-Archive - Parameter validation test cases" {
|
||||
|
||||
It "Validate errors from Compress-Archive with NULL & EMPTY values for Path, LiteralPath, DestinationPath, CompressionLevel parameters" {
|
||||
$sourcePath = "$TestDrive\SourceDir"
|
||||
$destinationPath = "$TestDrive\SampleSingleFile.zip"
|
||||
$sourcePath = "$TestDrive/SourceDir"
|
||||
$destinationPath = "$TestDrive/SampleSingleFile.zip"
|
||||
|
||||
CompressArchivePathParameterSetValidator $null $destinationPath
|
||||
CompressArchivePathParameterSetValidator $sourcePath $null
|
||||
@@ -251,26 +258,30 @@ Describe "Test suite for Microsoft.PowerShell.Archive module" -Tags "BVT" {
|
||||
}
|
||||
|
||||
It "Validate errors from Compress-Archive when invalid path (non-existing path / non-filesystem path) is supplied for Path or LiteralPath parameters" {
|
||||
CompressArchiveInValidPathValidator "$TestDrive\InvalidPath" $TestDrive "$TestDrive\InvalidPath" "ArchiveCmdletPathNotFound,Compress-Archive"
|
||||
CompressArchiveInValidPathValidator "HKLM:\SOFTWARE" $TestDrive "HKLM:\SOFTWARE" "PathNotFound,Compress-Archive"
|
||||
CompressArchiveInValidPathValidator "$TestDrive" "$TestDrive\NonExistingDirectory\sample.zip" "$TestDrive\NonExistingDirectory\sample.zip" "ArchiveCmdletPathNotFound,Compress-Archive"
|
||||
CompressArchiveInValidPathValidator "$TestDrive/InvalidPath" $TestDrive "$TestDrive/InvalidPath" "ArchiveCmdletPathNotFound,Compress-Archive"
|
||||
if ( ! $IsCore ) {
|
||||
CompressArchiveInValidPathValidator "HKLM:/SOFTWARE" $TestDrive "HKLM:/SOFTWARE" "PathNotFound,Compress-Archive"
|
||||
}
|
||||
CompressArchiveInValidPathValidator "$TestDrive" "$TestDrive/NonExistingDirectory/sample.zip" "$TestDrive/NonExistingDirectory/sample.zip" "ArchiveCmdletPathNotFound,Compress-Archive"
|
||||
|
||||
$path = @("$TestDrive", "$TestDrive\InvalidPath")
|
||||
CompressArchiveInValidPathValidator $path $TestDrive "$TestDrive\InvalidPath" "ArchiveCmdletPathNotFound,Compress-Archive"
|
||||
$path = @("$TestDrive", "$TestDrive/InvalidPath")
|
||||
CompressArchiveInValidPathValidator $path $TestDrive "$TestDrive/InvalidPath" "ArchiveCmdletPathNotFound,Compress-Archive"
|
||||
|
||||
$path = @("$TestDrive", "HKLM:\SOFTWARE")
|
||||
CompressArchiveInValidPathValidator $path $TestDrive "HKLM:\SOFTWARE" "PathNotFound,Compress-Archive"
|
||||
if ( ! $IsCore ) {
|
||||
$path = @("$TestDrive", "HKLM:/SOFTWARE")
|
||||
CompressArchiveInValidPathValidator $path $TestDrive "HKLM:/SOFTWARE" "PathNotFound,Compress-Archive"
|
||||
}
|
||||
|
||||
$invalidUnZipFileFormat = "$TestDrive\Sample.unzip"
|
||||
$invalidUnZipFileFormat = "$TestDrive/Sample.unzip"
|
||||
CompressArchiveInValidArchiveFileExtensionValidator $TestDrive "$invalidUnZipFileFormat" ".unzip"
|
||||
|
||||
$invalidcabZipFileFormat = "$TestDrive\Sample.cab"
|
||||
$invalidcabZipFileFormat = "$TestDrive/Sample.cab"
|
||||
CompressArchiveInValidArchiveFileExtensionValidator $TestDrive "$invalidcabZipFileFormat" ".cab"
|
||||
}
|
||||
|
||||
It "Validate error from Compress-Archive when archive file already exists and -Update parameter is not specified" {
|
||||
$sourcePath = "$TestDrive\SourceDir"
|
||||
$destinationPath = "$TestDrive\ValidateErrorWhenUpdateNotSpecified.zip"
|
||||
$sourcePath = "$TestDrive/SourceDir"
|
||||
$destinationPath = "$TestDrive/ValidateErrorWhenUpdateNotSpecified.zip"
|
||||
|
||||
try
|
||||
{
|
||||
@@ -286,9 +297,9 @@ Describe "Test suite for Microsoft.PowerShell.Archive module" -Tags "BVT" {
|
||||
|
||||
It "Validate error from Compress-Archive when duplicate paths are supplied as input to Path parameter" {
|
||||
$sourcePath = @(
|
||||
"$TestDrive\SourceDir\Sample-1.txt",
|
||||
"$TestDrive\SourceDir\Sample-1.txt")
|
||||
$destinationPath = "$TestDrive\DuplicatePaths.zip"
|
||||
"$TestDrive/SourceDir/Sample-1.txt",
|
||||
"$TestDrive/SourceDir/Sample-1.txt")
|
||||
$destinationPath = "$TestDrive/DuplicatePaths.zip"
|
||||
|
||||
try
|
||||
{
|
||||
@@ -303,9 +314,9 @@ Describe "Test suite for Microsoft.PowerShell.Archive module" -Tags "BVT" {
|
||||
|
||||
It "Validate error from Compress-Archive when duplicate paths are supplied as input to LiteralPath parameter" {
|
||||
$sourcePath = @(
|
||||
"$TestDrive\SourceDir\Sample-1.txt",
|
||||
"$TestDrive\SourceDir\Sample-1.txt")
|
||||
$destinationPath = "$TestDrive\DuplicatePaths.zip"
|
||||
"$TestDrive/SourceDir/Sample-1.txt",
|
||||
"$TestDrive/SourceDir/Sample-1.txt")
|
||||
$destinationPath = "$TestDrive/DuplicatePaths.zip"
|
||||
|
||||
try
|
||||
{
|
||||
@@ -317,20 +328,57 @@ Describe "Test suite for Microsoft.PowerShell.Archive module" -Tags "BVT" {
|
||||
$_.FullyQualifiedErrorId | Should Be "DuplicatePathFound,Compress-Archive"
|
||||
}
|
||||
}
|
||||
|
||||
It "Validate that relative path can be specified as Path parameter of Compress-Archive cmdlet" {
|
||||
$sourcePath = "./SourceDir"
|
||||
$destinationPath = "RelativePathForPathParameter.zip"
|
||||
try {
|
||||
push-location $TESTDRIVE
|
||||
Compress-Archive -Path $sourcePath -DestinationPath $destinationPath
|
||||
Test-Path $destinationPath | Should Be $true
|
||||
}
|
||||
finally {
|
||||
Pop-Location
|
||||
}
|
||||
}
|
||||
It "Validate that relative path can be specified as LiteralPath parameter of Compress-Archive cmdlet" {
|
||||
$sourcePath = "./SourceDir"
|
||||
$destinationPath = "RelativePathForLiteralPathParameter.zip"
|
||||
try {
|
||||
push-location $TESTDRIVE
|
||||
Compress-Archive -LiteralPath $sourcePath -DestinationPath $destinationPath
|
||||
Test-Path $destinationPath | Should Be $true
|
||||
}
|
||||
finally {
|
||||
Pop-Location
|
||||
}
|
||||
}
|
||||
It "Validate that relative path can be specified as DestinationPath parameter of Compress-Archive cmdlet" {
|
||||
$sourcePath = "$TestDrive/SourceDir"
|
||||
$destinationPath = "./RelativePathForDestinationPathParameter.zip"
|
||||
try {
|
||||
push-location $TESTDRIVE
|
||||
Compress-Archive -Path $sourcePath -DestinationPath $destinationPath
|
||||
Test-Path $destinationPath | Should Be $true
|
||||
}
|
||||
finally {
|
||||
Pop-Location
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Context "Compress-Archive - functional test cases" {
|
||||
It "Validate that a single file can be compressed using Compress-Archive cmdlet" {
|
||||
$sourcePath = "$TestDrive\SourceDir\ChildDir-1\Sample-3.txt"
|
||||
$destinationPath = "$TestDrive\SampleSingleFile.zip"
|
||||
$sourcePath = [io.path]::Combine("$TestDrive","SourceDir","ChildDir-1","Sample-3.txt")
|
||||
$destinationPath = [io.path]::Combine("$TestDrive","SampleSingleFile.zip")
|
||||
Compress-Archive -Path $sourcePath -DestinationPath $destinationPath
|
||||
$destinationPath | Should Exist
|
||||
}
|
||||
# This test requires a fix in PS5 to support reading paths with square bracket
|
||||
It "Validate that Compress-Archive cmdlet can accept LiteralPath parameter with Special Characters" -skip:($PSVersionTable.psversion -lt "5.0") {
|
||||
$sourcePath = "$TestDrive\SourceDir\ChildDir-1\Sample[]File.txt"
|
||||
$sourcePath = "$TestDrive/SourceDir/ChildDir-1/Sample[]File.txt"
|
||||
"Some Random Content" | Out-File -LiteralPath $sourcePath
|
||||
$destinationPath = "$TestDrive\SampleSingleFileWithSpecialCharacters.zip"
|
||||
$destinationPath = "$TestDrive/SampleSingleFileWithSpecialCharacters.zip"
|
||||
try
|
||||
{
|
||||
Compress-Archive -LiteralPath $sourcePath -DestinationPath $destinationPath
|
||||
@@ -343,12 +391,12 @@ Describe "Test suite for Microsoft.PowerShell.Archive module" -Tags "BVT" {
|
||||
}
|
||||
It "Validate that Compress-Archive cmdlet errors out when DestinationPath resolves to multiple locations" {
|
||||
|
||||
New-Item $TestDrive\SampleDir\Child-1 -Type Directory -Force | Out-Null
|
||||
New-Item $TestDrive\SampleDir\Child-2 -Type Directory -Force | Out-Null
|
||||
New-Item $TestDrive\SampleDir\Test.txt -Type File -Force | Out-Null
|
||||
New-Item $TestDrive/SampleDir/Child-1 -Type Directory -Force | Out-Null
|
||||
New-Item $TestDrive/SampleDir/Child-2 -Type Directory -Force | Out-Null
|
||||
New-Item $TestDrive/SampleDir/Test.txt -Type File -Force | Out-Null
|
||||
|
||||
$destinationPath = "$TestDrive\SampleDir\Child-*\SampleChidArchive.zip"
|
||||
$sourcePath = "$TestDrive\SampleDir\Test.txt"
|
||||
$destinationPath = "$TestDrive/SampleDir/Child-*/SampleChidArchive.zip"
|
||||
$sourcePath = "$TestDrive/SampleDir/Test.txt"
|
||||
try
|
||||
{
|
||||
Compress-Archive -Path $sourcePath -DestinationPath $destinationPath
|
||||
@@ -360,16 +408,16 @@ Describe "Test suite for Microsoft.PowerShell.Archive module" -Tags "BVT" {
|
||||
}
|
||||
finally
|
||||
{
|
||||
Remove-Item -LiteralPath $TestDrive\SampleDir -Force -Recurse
|
||||
Remove-Item -LiteralPath $TestDrive/SampleDir -Force -Recurse
|
||||
}
|
||||
}
|
||||
It "Validate that Compress-Archive cmdlet works when DestinationPath has wild card pattern and resolves to a single valid path" {
|
||||
|
||||
New-Item $TestDrive\SampleDir\Child-1 -Type Directory -Force | Out-Null
|
||||
New-Item $TestDrive\SampleDir\Test.txt -Type File -Force | Out-Null
|
||||
New-Item $TestDrive/SampleDir/Child-1 -Type Directory -Force | Out-Null
|
||||
New-Item $TestDrive/SampleDir/Test.txt -Type File -Force | Out-Null
|
||||
|
||||
$destinationPath = "$TestDrive\SampleDir\Child-*\SampleChidArchive.zip"
|
||||
$sourcePath = "$TestDrive\SampleDir\Test.txt"
|
||||
$destinationPath = "$TestDrive/SampleDir/Child-*/SampleChidArchive.zip"
|
||||
$sourcePath = "$TestDrive/SampleDir/Test.txt"
|
||||
try
|
||||
{
|
||||
Compress-Archive -Path $sourcePath -DestinationPath $destinationPath
|
||||
@@ -377,15 +425,15 @@ Describe "Test suite for Microsoft.PowerShell.Archive module" -Tags "BVT" {
|
||||
}
|
||||
finally
|
||||
{
|
||||
Remove-Item -LiteralPath $TestDrive\SampleDir -Force -Recurse
|
||||
Remove-Item -LiteralPath $TestDrive/SampleDir -Force -Recurse
|
||||
}
|
||||
}
|
||||
# This test requires a fix in PS5 to support reading paths with square bracket
|
||||
It "Validate that Compress-Archive cmdlet can accept LiteralPath parameter for a directory with Special Characters in the directory name" -skip:($PSVersionTable.psversion -lt "5.0") {
|
||||
$sourcePath = "$TestDrive\Source[]Dir\ChildDir[]-1"
|
||||
$sourcePath = "$TestDrive/Source[]Dir/ChildDir[]-1"
|
||||
New-Item $sourcePath -Type Directory | Out-Null
|
||||
"Some Random Content" | Out-File -LiteralPath "$sourcePath\Sample[]File.txt"
|
||||
$destinationPath = "$TestDrive\SampleDirWithSpecialCharacters.zip"
|
||||
"Some Random Content" | Out-File -LiteralPath "$sourcePath/Sample[]File.txt"
|
||||
$destinationPath = "$TestDrive/SampleDirWithSpecialCharacters.zip"
|
||||
try
|
||||
{
|
||||
Compress-Archive -LiteralPath $sourcePath -DestinationPath $destinationPath
|
||||
@@ -397,8 +445,8 @@ Describe "Test suite for Microsoft.PowerShell.Archive module" -Tags "BVT" {
|
||||
}
|
||||
}
|
||||
It "Validate that Compress-Archive cmdlet can accept DestinationPath parameter with Special Characters" {
|
||||
$sourcePath = "$TestDrive\SourceDir\ChildDir-1\Sample-3.txt"
|
||||
$destinationPath = "$TestDrive\Sample[]SingleFile.zip"
|
||||
$sourcePath = "$TestDrive/SourceDir/ChildDir-1/Sample-3.txt"
|
||||
$destinationPath = "$TestDrive/Sample[]SingleFile.zip"
|
||||
try
|
||||
{
|
||||
Compress-Archive -Path $sourcePath -DestinationPath $destinationPath
|
||||
@@ -409,11 +457,11 @@ Describe "Test suite for Microsoft.PowerShell.Archive module" -Tags "BVT" {
|
||||
Remove-Item -LiteralPath $destinationPath -Force
|
||||
}
|
||||
}
|
||||
It "Validate that Source Path can be at SystemDrive location" {
|
||||
$sourcePath = "$env:SystemDrive\SourceDir"
|
||||
$destinationPath = "$TestDrive\SampleFromSystemDrive.zip"
|
||||
It "Validate that Source Path can be at SystemDrive location" -skip:($IsCore) {
|
||||
$sourcePath = "$env:SystemDrive/SourceDir"
|
||||
$destinationPath = "$TestDrive/SampleFromSystemDrive.zip"
|
||||
New-Item $sourcePath -Type Directory | Out-Null
|
||||
"Some Data" | Out-File -FilePath $sourcePath\SampleSourceFileForArchive.txt
|
||||
"Some Data" | Out-File -FilePath $sourcePath/SampleSourceFileForArchive.txt
|
||||
try
|
||||
{
|
||||
Compress-Archive -Path $sourcePath -DestinationPath $destinationPath
|
||||
@@ -421,145 +469,104 @@ Describe "Test suite for Microsoft.PowerShell.Archive module" -Tags "BVT" {
|
||||
}
|
||||
finally
|
||||
{
|
||||
del "$sourcePath" -Force -Recurse -ErrorAction SilentlyContinue
|
||||
remove-item "$sourcePath" -Force -Recurse -ErrorAction SilentlyContinue
|
||||
}
|
||||
}
|
||||
It "Validate that multiple files can be compressed using Compress-Archive cmdlet" {
|
||||
$sourcePath = @(
|
||||
"$TestDrive\SourceDir\ChildDir-1\Sample-3.txt",
|
||||
"$TestDrive\SourceDir\ChildDir-1\Sample-4.txt",
|
||||
"$TestDrive\SourceDir\ChildDir-2\Sample-5.txt",
|
||||
"$TestDrive\SourceDir\ChildDir-2\Sample-6.txt")
|
||||
$destinationPath = "$TestDrive\SampleMultipleFiles.zip"
|
||||
"$TestDrive/SourceDir/ChildDir-1/Sample-3.txt",
|
||||
"$TestDrive/SourceDir/ChildDir-1/Sample-4.txt",
|
||||
"$TestDrive/SourceDir/ChildDir-2/Sample-5.txt",
|
||||
"$TestDrive/SourceDir/ChildDir-2/Sample-6.txt")
|
||||
$destinationPath = "$TestDrive/SampleMultipleFiles.zip"
|
||||
Compress-Archive -Path $sourcePath -DestinationPath $destinationPath
|
||||
Test-Path $destinationPath | Should Be $true
|
||||
}
|
||||
It "Validate that multiple files and directories can be compressed using Compress-Archive cmdlet" {
|
||||
$sourcePath = @(
|
||||
"$TestDrive\SourceDir\Sample-1.txt",
|
||||
"$TestDrive\SourceDir\Sample-2.txt",
|
||||
"$TestDrive\SourceDir\ChildDir-1",
|
||||
"$TestDrive\SourceDir\ChildDir-2")
|
||||
$destinationPath = "$TestDrive\SampleMultipleFilesAndDirs.zip"
|
||||
"$TestDrive/SourceDir/Sample-1.txt",
|
||||
"$TestDrive/SourceDir/Sample-2.txt",
|
||||
"$TestDrive/SourceDir/ChildDir-1",
|
||||
"$TestDrive/SourceDir/ChildDir-2")
|
||||
$destinationPath = "$TestDrive/SampleMultipleFilesAndDirs.zip"
|
||||
Compress-Archive -Path $sourcePath -DestinationPath $destinationPath
|
||||
Test-Path $destinationPath | Should Be $true
|
||||
}
|
||||
It "Validate that a single directory can be compressed using Compress-Archive cmdlet" {
|
||||
$sourcePath = @("$TestDrive\SourceDir\ChildDir-1")
|
||||
$destinationPath = "$TestDrive\SampleSingleDir.zip"
|
||||
$sourcePath = @("$TestDrive/SourceDir/ChildDir-1")
|
||||
$destinationPath = "$TestDrive/SampleSingleDir.zip"
|
||||
Compress-Archive -Path $sourcePath -DestinationPath $destinationPath
|
||||
Test-Path $destinationPath | Should Be $true
|
||||
}
|
||||
It "Validate that a single directory with multiple files and subdirectories can be compressed using Compress-Archive cmdlet" {
|
||||
$sourcePath = @("$TestDrive\SourceDir")
|
||||
$destinationPath = "$TestDrive\SampleSubTree.zip"
|
||||
$sourcePath = @("$TestDrive/SourceDir")
|
||||
$destinationPath = "$TestDrive/SampleSubTree.zip"
|
||||
Compress-Archive -Path $sourcePath -DestinationPath $destinationPath
|
||||
Test-Path $destinationPath | Should Be $true
|
||||
}
|
||||
It "Validate that a single directory & multiple files can be compressed using Compress-Archive cmdlet" {
|
||||
$sourcePath = @(
|
||||
"$TestDrive\SourceDir\ChildDir-1",
|
||||
"$TestDrive\SourceDir\Sample-1.txt",
|
||||
"$TestDrive\SourceDir\Sample-2.txt")
|
||||
$destinationPath = "$TestDrive\SampleMultipleFilesAndSingleDir.zip"
|
||||
"$TestDrive/SourceDir/ChildDir-1",
|
||||
"$TestDrive/SourceDir/Sample-1.txt",
|
||||
"$TestDrive/SourceDir/Sample-2.txt")
|
||||
$destinationPath = "$TestDrive/SampleMultipleFilesAndSingleDir.zip"
|
||||
Compress-Archive -Path $sourcePath -DestinationPath $destinationPath
|
||||
Test-Path $destinationPath | Should Be $true
|
||||
}
|
||||
|
||||
It "Validate that if .zip extension is not supplied as input to DestinationPath parameter, then .zip extension is appended" {
|
||||
$sourcePath = @("$TestDrive\SourceDir")
|
||||
$destinationPath = "$TestDrive\SampleNoExtension.zip"
|
||||
$destinationWithoutExtensionPath = "$TestDrive\SampleNoExtension"
|
||||
$sourcePath = @("$TestDrive/SourceDir")
|
||||
$destinationPath = "$TestDrive/SampleNoExtension.zip"
|
||||
$destinationWithoutExtensionPath = "$TestDrive/SampleNoExtension"
|
||||
Compress-Archive -Path $sourcePath -DestinationPath $destinationWithoutExtensionPath
|
||||
Test-Path $destinationPath | Should Be $true
|
||||
}
|
||||
It "Validate that relative path can be specified as Path parameter of Compress-Archive cmdlet" {
|
||||
$sourcePath = ".\SourceDir"
|
||||
$destinationPath = "RelativePathForPathParameter.zip"
|
||||
try
|
||||
{
|
||||
Push-Location $TestDrive
|
||||
Compress-Archive -Path $sourcePath -DestinationPath $destinationPath
|
||||
Test-Path $destinationPath | Should Be $true
|
||||
}
|
||||
finally
|
||||
{
|
||||
Pop-Location
|
||||
}
|
||||
}
|
||||
It "Validate that relative path can be specified as LiteralPath parameter of Compress-Archive cmdlet" {
|
||||
$sourcePath = ".\SourceDir"
|
||||
$destinationPath = "RelativePathForLiteralPathParameter.zip"
|
||||
try
|
||||
{
|
||||
Push-Location $TestDrive
|
||||
Compress-Archive -LiteralPath $sourcePath -DestinationPath $destinationPath
|
||||
Test-Path $destinationPath | Should Be $true
|
||||
}
|
||||
finally
|
||||
{
|
||||
Pop-Location
|
||||
}
|
||||
}
|
||||
It "Validate that relative path can be specified as DestinationPath parameter of Compress-Archive cmdlet" {
|
||||
$sourcePath = "$TestDrive\SourceDir"
|
||||
$destinationPath = ".\RelativePathForDestinationPathParameter.zip"
|
||||
try
|
||||
{
|
||||
Push-Location $TestDrive
|
||||
Compress-Archive -Path $sourcePath -DestinationPath $destinationPath
|
||||
Test-Path $destinationPath | Should Be $true
|
||||
}
|
||||
finally
|
||||
{
|
||||
Pop-Location
|
||||
}
|
||||
}
|
||||
|
||||
It "Validate that -Update parameter makes Compress-Archive to not throw an error if archive file already exists" {
|
||||
$sourcePath = @("$TestDrive\SourceDir")
|
||||
$destinationPath = "$TestDrive\SampleUpdateTest.zip"
|
||||
$sourcePath = @("$TestDrive/SourceDir")
|
||||
$destinationPath = "$TestDrive/SampleUpdateTest.zip"
|
||||
Compress-Archive -Path $sourcePath -DestinationPath $destinationPath
|
||||
Test-Path $destinationPath | Should Be $true
|
||||
Compress-Archive -Path $sourcePath -DestinationPath $destinationPath -Update
|
||||
Test-Path $destinationPath | Should Be $true
|
||||
}
|
||||
It "Validate -Update parameter by adding a new file to an existing archive file" {
|
||||
$sourcePath = @("$TestDrive\SourceDir\ChildDir-1")
|
||||
$destinationPath = "$TestDrive\SampleUpdateAdd1File.zip"
|
||||
$sourcePath = @("$TestDrive/SourceDir/ChildDir-1")
|
||||
$destinationPath = "$TestDrive/SampleUpdateAdd1File.zip"
|
||||
Compress-Archive -Path $sourcePath -DestinationPath $destinationPath
|
||||
Test-Path $destinationPath | Should Be $true
|
||||
New-Item $TestDrive\SourceDir\ChildDir-1\Sample-AddedNewFile.txt -Type File | Out-Null
|
||||
New-Item $TestDrive/SourceDir/ChildDir-1/Sample-AddedNewFile.txt -Type File | Out-Null
|
||||
Compress-Archive -Path $sourcePath -DestinationPath $destinationPath -Update
|
||||
Test-Path $destinationPath | Should Be $true
|
||||
Validate-ArchiveEntryCount -path $destinationPath -expectedEntryCount 3
|
||||
}
|
||||
|
||||
It "Validate that all CompressionLevel values can be used with Compress-Archive cmdlet" {
|
||||
$sourcePath = "$TestDrive\SourceDir\Sample-1.txt"
|
||||
$sourcePath = "$TestDrive/SourceDir/Sample-1.txt"
|
||||
|
||||
$destinationPath = "$TestDrive\FastestCompressionLevel.zip"
|
||||
$destinationPath = "$TestDrive/FastestCompressionLevel.zip"
|
||||
Compress-Archive -Path $sourcePath -DestinationPath $destinationPath -CompressionLevel Fastest
|
||||
Test-Path $destinationPath | Should Be $true
|
||||
|
||||
$destinationPath = "$TestDrive\OptimalCompressionLevel.zip"
|
||||
$destinationPath = "$TestDrive/OptimalCompressionLevel.zip"
|
||||
Compress-Archive -Path $sourcePath -DestinationPath $destinationPath -CompressionLevel Optimal
|
||||
Test-Path $destinationPath | Should Be $true
|
||||
|
||||
$destinationPath = "$TestDrive\NoCompressionCompressionLevel.zip"
|
||||
$destinationPath = "$TestDrive/NoCompressionCompressionLevel.zip"
|
||||
Compress-Archive -Path $sourcePath -DestinationPath $destinationPath -CompressionLevel NoCompression
|
||||
Test-Path $destinationPath | Should Be $true
|
||||
}
|
||||
|
||||
It "Validate that -Update parameter is modifying a file that already exists in the archive file" {
|
||||
$filePath = "$TestDrive\SourceDir\ChildDir-1\Sample-3.txt"
|
||||
$filePath = "$TestDrive/SourceDir/ChildDir-1/Sample-3.txt"
|
||||
|
||||
$initialContent = "Initial Content"
|
||||
$modifiedContent = "Modified Content"
|
||||
|
||||
$initialContent | Set-Content $filePath
|
||||
|
||||
$sourcePath = "$TestDrive\SourceDir"
|
||||
$destinationPath = "$TestDrive\UpdatingModifiedFile.zip"
|
||||
$sourcePath = "$TestDrive/SourceDir"
|
||||
$destinationPath = "$TestDrive/UpdatingModifiedFile.zip"
|
||||
|
||||
Compress-Archive -Path $sourcePath -DestinationPath $destinationPath
|
||||
Test-Path $destinationPath | Should Be $True
|
||||
@@ -569,28 +576,28 @@ Describe "Test suite for Microsoft.PowerShell.Archive module" -Tags "BVT" {
|
||||
Compress-Archive -Path $sourcePath -DestinationPath $destinationPath -Update
|
||||
Test-Path $destinationPath | Should Be $True
|
||||
|
||||
ArchiveFileEntryContentValidator "$destinationPath" "SourceDir\ChildDir-1\Sample-3.txt" $modifiedContent
|
||||
ArchiveFileEntryContentValidator "$destinationPath" ([io.path]::Combine("SourceDir","ChildDir-1","Sample-3.txt")) $modifiedContent
|
||||
}
|
||||
|
||||
It "Validate Compress-Archive cmdlet in pipleline scenario" {
|
||||
$destinationPath = "$TestDrive\CompressArchiveFromPipeline.zip"
|
||||
$destinationPath = "$TestDrive/CompressArchiveFromPipeline.zip"
|
||||
|
||||
# Piping a single file path to Compress-Archive
|
||||
dir -Path $TestDrive\SourceDir\Sample-1.txt | Compress-Archive -DestinationPath $destinationPath
|
||||
dir -Path $TestDrive/SourceDir/Sample-1.txt | Compress-Archive -DestinationPath $destinationPath
|
||||
Test-Path $destinationPath | Should Be $True
|
||||
|
||||
# Piping a string directory path to Compress-Archive
|
||||
"$TestDrive\SourceDir\ChildDir-2" | Compress-Archive -DestinationPath $destinationPath -Update
|
||||
"$TestDrive/SourceDir/ChildDir-2" | Compress-Archive -DestinationPath $destinationPath -Update
|
||||
Test-Path $destinationPath | Should Be $True
|
||||
|
||||
# Piping the output of Get-ChildItem to Compress-Archive
|
||||
dir "$TestDrive\SourceDir" -Recurse | Compress-Archive -DestinationPath $destinationPath -Update
|
||||
dir "$TestDrive/SourceDir" -Recurse | Compress-Archive -DestinationPath $destinationPath -Update
|
||||
Test-Path $destinationPath | Should Be $True
|
||||
}
|
||||
|
||||
It "Validate that Compress-Archive works on ReadOnly files" {
|
||||
$sourcePath = "$TestDrive\ReadOnlyFile.txt"
|
||||
$destinationPath = "$TestDrive\TestForReadOnlyFile.zip"
|
||||
$sourcePath = "$TestDrive/ReadOnlyFile.txt"
|
||||
$destinationPath = "$TestDrive/TestForReadOnlyFile.zip"
|
||||
|
||||
"Some Content" | Out-File -FilePath $sourcePath
|
||||
$createdItem = Get-Item $sourcePath
|
||||
@@ -601,8 +608,8 @@ Describe "Test suite for Microsoft.PowerShell.Archive module" -Tags "BVT" {
|
||||
}
|
||||
|
||||
It "Validate that Compress-Archive generates Verbose messages" {
|
||||
$sourcePath = "$TestDrive\SourceDir"
|
||||
$destinationPath = "$TestDrive\Compress-Archive generates VerboseMessages.zip"
|
||||
$sourcePath = "$TestDrive/SourceDir"
|
||||
$destinationPath = "$TestDrive/Compress-Archive generates VerboseMessages.zip"
|
||||
|
||||
try
|
||||
{
|
||||
@@ -625,8 +632,8 @@ Describe "Test suite for Microsoft.PowerShell.Archive module" -Tags "BVT" {
|
||||
|
||||
Context "Expand-Archive - Parameter validation test cases" {
|
||||
It "Validate non existing archive -Path trows expected error message" {
|
||||
$sourcePath = "$TestDrive\SourceDir"
|
||||
$destinationPath = "$TestDrive\ExpandedArchive"
|
||||
$sourcePath = "$TestDrive/SourceDir"
|
||||
$destinationPath = "$TestDrive/ExpandedArchive"
|
||||
try
|
||||
{
|
||||
Expand-Archive -Path $sourcePath -DestinationPath $destinationPath
|
||||
@@ -639,48 +646,53 @@ Describe "Test suite for Microsoft.PowerShell.Archive module" -Tags "BVT" {
|
||||
}
|
||||
|
||||
It "Validate errors from Expand-Archive with NULL & EMPTY values for Path, LiteralPath, DestinationPath parameters" {
|
||||
ExpandArchiveInvalidParameterValidator $false $null "$TestDrive\SourceDir" "ParameterArgumentValidationError,Expand-Archive"
|
||||
ExpandArchiveInvalidParameterValidator $false $null "$TestDrive/SourceDir" "ParameterArgumentValidationError,Expand-Archive"
|
||||
ExpandArchiveInvalidParameterValidator $false $null $null "ParameterArgumentValidationError,Expand-Archive"
|
||||
|
||||
ExpandArchiveInvalidParameterValidator $false "$TestDrive\SourceDir" $null "ParameterArgumentTransformationError,Expand-Archive"
|
||||
ExpandArchiveInvalidParameterValidator $false "" "$TestDrive\SourceDir" "ParameterArgumentTransformationError,Expand-Archive"
|
||||
ExpandArchiveInvalidParameterValidator $false "$TestDrive\SourceDir" "" "ParameterArgumentTransformationError,Expand-Archive"
|
||||
ExpandArchiveInvalidParameterValidator $false "$TestDrive/SourceDir" $null "ParameterArgumentTransformationError,Expand-Archive"
|
||||
ExpandArchiveInvalidParameterValidator $false "" "$TestDrive/SourceDir" "ParameterArgumentTransformationError,Expand-Archive"
|
||||
ExpandArchiveInvalidParameterValidator $false "$TestDrive/SourceDir" "" "ParameterArgumentTransformationError,Expand-Archive"
|
||||
ExpandArchiveInvalidParameterValidator $false "" "" "ParameterArgumentTransformationError,Expand-Archive"
|
||||
|
||||
ExpandArchiveInvalidParameterValidator $true $null "$TestDrive\SourceDir" "ParameterArgumentValidationError,Expand-Archive"
|
||||
ExpandArchiveInvalidParameterValidator $true $null "$TestDrive/SourceDir" "ParameterArgumentValidationError,Expand-Archive"
|
||||
ExpandArchiveInvalidParameterValidator $true $null $null "ParameterArgumentValidationError,Expand-Archive"
|
||||
|
||||
ExpandArchiveInvalidParameterValidator $true "$TestDrive\SourceDir" $null "ParameterArgumentValidationError,Expand-Archive"
|
||||
ExpandArchiveInvalidParameterValidator $true "" "$TestDrive\SourceDir" "ParameterArgumentValidationError,Expand-Archive"
|
||||
ExpandArchiveInvalidParameterValidator $true "$TestDrive\SourceDir" "" "ParameterArgumentValidationError,Expand-Archive"
|
||||
ExpandArchiveInvalidParameterValidator $true "$TestDrive/SourceDir" $null "ParameterArgumentValidationError,Expand-Archive"
|
||||
ExpandArchiveInvalidParameterValidator $true "" "$TestDrive/SourceDir" "ParameterArgumentValidationError,Expand-Archive"
|
||||
ExpandArchiveInvalidParameterValidator $true "$TestDrive/SourceDir" "" "ParameterArgumentValidationError,Expand-Archive"
|
||||
ExpandArchiveInvalidParameterValidator $true "" "" "ParameterArgumentValidationError,Expand-Archive"
|
||||
|
||||
ExpandArchiveInvalidParameterValidator $true $null "$TestDrive\SourceDir" "ParameterArgumentValidationError,Expand-Archive"
|
||||
ExpandArchiveInvalidParameterValidator $true $null "$TestDrive/SourceDir" "ParameterArgumentValidationError,Expand-Archive"
|
||||
ExpandArchiveInvalidParameterValidator $true $null $null "ParameterArgumentValidationError,Expand-Archive"
|
||||
|
||||
ExpandArchiveInvalidParameterValidator $true "$TestDrive\SourceDir" $null "ParameterArgumentValidationError,Expand-Archive"
|
||||
ExpandArchiveInvalidParameterValidator $true "" "$TestDrive\SourceDir" "ParameterArgumentValidationError,Expand-Archive"
|
||||
ExpandArchiveInvalidParameterValidator $true "$TestDrive\SourceDir" "" "ParameterArgumentValidationError,Expand-Archive"
|
||||
ExpandArchiveInvalidParameterValidator $true "$TestDrive/SourceDir" $null "ParameterArgumentValidationError,Expand-Archive"
|
||||
ExpandArchiveInvalidParameterValidator $true "" "$TestDrive/SourceDir" "ParameterArgumentValidationError,Expand-Archive"
|
||||
ExpandArchiveInvalidParameterValidator $true "$TestDrive/SourceDir" "" "ParameterArgumentValidationError,Expand-Archive"
|
||||
ExpandArchiveInvalidParameterValidator $true "" "" "ParameterArgumentValidationError,Expand-Archive"
|
||||
}
|
||||
|
||||
It "Validate errors from Expand-Archive when invalid path (non-existing path / non-filesystem path) is supplied for Path or LiteralPath parameters" {
|
||||
try { Expand-Archive -Path "$TestDrive\NonExistingArchive" -DestinationPath "$TestDrive\SourceDir"; throw "Expand-Archive did NOT throw expected error" }
|
||||
try { Expand-Archive -Path "$TestDrive/NonExistingArchive" -DestinationPath "$TestDrive/SourceDir"; throw "Expand-Archive did NOT throw expected error" }
|
||||
catch { $_.FullyQualifiedErrorId | Should Be "ArchiveCmdletPathNotFound,Expand-Archive" }
|
||||
|
||||
try { Expand-Archive -Path "HKLM:\SOFTWARE" -DestinationPath "$TestDrive\SourceDir"; throw "Expand-Archive did NOT throw expected error" }
|
||||
catch { $_.FullyQualifiedErrorId | Should Be "PathNotFound,Expand-Archive" }
|
||||
if ( ! $IsCore ) {
|
||||
try { Expand-Archive -Path "HKLM:/SOFTWARE" -DestinationPath "$TestDrive/SourceDir"; throw "Expand-Archive did NOT throw expected error" }
|
||||
catch { $_.FullyQualifiedErrorId | Should Be "PathNotFound,Expand-Archive" }
|
||||
}
|
||||
|
||||
try { Expand-Archive -LiteralPath "$TestDrive\NonExistingArchive" -DestinationPath "$TestDrive\SourceDir"; throw "Expand-Archive did NOT throw expected error" }
|
||||
try { Expand-Archive -LiteralPath "$TestDrive/NonExistingArchive" -DestinationPath "$TestDrive/SourceDir"; throw "Expand-Archive did NOT throw expected error" }
|
||||
catch { $_.FullyQualifiedErrorId | Should Be "ArchiveCmdletPathNotFound,Expand-Archive" }
|
||||
|
||||
try { Expand-Archive -LiteralPath "HKLM:\SOFTWARE" -DestinationPath "$TestDrive\SourceDir"; throw "Expand-Archive did NOT throw expected error" }
|
||||
catch { $_.FullyQualifiedErrorId | Should Be "PathNotFound,Expand-Archive" }
|
||||
if ( ! $IsCore ) {
|
||||
try { Expand-Archive -LiteralPath "HKLM:/SOFTWARE" -DestinationPath "$TestDrive/SourceDir"; throw "Expand-Archive did NOT throw expected error" }
|
||||
catch { $_.FullyQualifiedErrorId | Should Be "PathNotFound,Expand-Archive" }
|
||||
}
|
||||
}
|
||||
|
||||
It "Validate error from Expand-Archive when invalid path (non-existing path / non-filesystem path) is supplied for DestinationPath parameter" {
|
||||
$sourcePath = "$TestDrive\SamplePreCreatedArchive.zip"
|
||||
$destinationPath = "HKLM:\SOFTWARE"
|
||||
$sourcePath = "$TestDrive/SamplePreCreatedArchive.zip"
|
||||
# $destinationPath = "HKLM:/SOFTWARE"
|
||||
$destinationPath = "Variable:/"
|
||||
|
||||
try { Expand-Archive -Path $sourcePath -DestinationPath $destinationPath; throw "Expand-Archive did NOT throw expected error" }
|
||||
catch { $_.FullyQualifiedErrorId | Should Be "InvalidDirectoryPath,Expand-Archive" }
|
||||
@@ -688,14 +700,13 @@ Describe "Test suite for Microsoft.PowerShell.Archive module" -Tags "BVT" {
|
||||
}
|
||||
|
||||
Context "Expand-Archive - functional test cases" {
|
||||
|
||||
It "Validate basic Expand-Archive scenario" {
|
||||
$sourcePath = "$TestDrive\SamplePreCreatedArchive.zip"
|
||||
$sourcePath = "$TestDrive/SamplePreCreatedArchive.zip"
|
||||
$content = "Some Data"
|
||||
$destinationPath = "$TestDrive\DestDirForBasicExpand"
|
||||
$destinationPath = "$TestDrive/DestDirForBasicExpand"
|
||||
$files = @("Sample-1.txt", "Sample-2.txt")
|
||||
|
||||
# The files in "$TestDrive\SamplePreCreatedArchive.zip" are precreated.
|
||||
# The files in "$TestDrive/SamplePreCreatedArchive.zip" are precreated.
|
||||
$fileCreationTimeStamp = Get-Date -Year 2014 -Month 6 -Day 13 -Hour 15 -Minute 50 -Second 20 -Millisecond 0
|
||||
|
||||
Expand-Archive -Path $sourcePath -DestinationPath $destinationPath
|
||||
@@ -712,11 +723,13 @@ Describe "Test suite for Microsoft.PowerShell.Archive module" -Tags "BVT" {
|
||||
}
|
||||
}
|
||||
It "Validate that Expand-Archive cmdlet errors out when DestinationPath resolves to multiple locations" {
|
||||
New-Item $TestDrive\SampleDir\Child-1 -Type Directory -Force | Out-Null
|
||||
New-Item $TestDrive\SampleDir\Child-2 -Type Directory -Force | Out-Null
|
||||
$testbasename = "TargetDir"
|
||||
setup -d "$testbasename"
|
||||
setup -d "$testbasename/Child-1"
|
||||
setup -d "$testbasename/Child-2"
|
||||
|
||||
$destinationPath = "$TestDrive\SampleDir\Child-*"
|
||||
$sourcePath = "$TestDrive\SamplePreCreatedArchive.zip"
|
||||
$destinationPath = [io.path]::Combine("$TestDrive","$testbasename","Child-*")
|
||||
$sourcePath = join-path "$TestDrive" "SamplePreCreatedArchive.zip"
|
||||
try
|
||||
{
|
||||
Expand-Archive -Path $sourcePath -DestinationPath $destinationPath
|
||||
@@ -728,14 +741,16 @@ Describe "Test suite for Microsoft.PowerShell.Archive module" -Tags "BVT" {
|
||||
}
|
||||
finally
|
||||
{
|
||||
Remove-Item -LiteralPath $TestDrive\SampleDir -Force -Recurse
|
||||
Remove-Item -LiteralPath "$TestDrive/$testbasename" -Force -Recurse
|
||||
}
|
||||
}
|
||||
It "Validate that Expand-Archive cmdlet works when DestinationPath resolves has wild card pattern and resolves to a single valid path" {
|
||||
New-Item $TestDrive\SampleDir\Child-1 -Type Directory -Force | Out-Null
|
||||
$testbasename = "TargetDir"
|
||||
setup -d "$testbasename"
|
||||
setup -d "$testbasename/Child-1"
|
||||
|
||||
$destinationPath = "$TestDrive\SampleDir\Child-*"
|
||||
$sourcePath = "$TestDrive\SamplePreCreatedArchive.zip"
|
||||
$destinationPath = [io.path]::Combine("$TestDrive","$testbasename","Child-*")
|
||||
$sourcePath = "$TestDrive/SamplePreCreatedArchive.zip"
|
||||
try
|
||||
{
|
||||
Expand-Archive -Path $sourcePath -DestinationPath $destinationPath
|
||||
@@ -744,16 +759,16 @@ Describe "Test suite for Microsoft.PowerShell.Archive module" -Tags "BVT" {
|
||||
}
|
||||
finally
|
||||
{
|
||||
Remove-Item -LiteralPath $TestDrive\SampleDir -Force -Recurse
|
||||
Remove-Item -LiteralPath "$TestDrive/$testbasename" -Force -Recurse
|
||||
}
|
||||
}
|
||||
It "Validate Expand-Archive scenario where DestinationPath has Special Characters" {
|
||||
$sourcePath = "$TestDrive\SamplePreCreatedArchive.zip"
|
||||
$sourcePath = "$TestDrive/SamplePreCreatedArchive.zip"
|
||||
$content = "Some Data"
|
||||
$destinationPath = "$TestDrive\DestDir[]Expand"
|
||||
$destinationPath = "$TestDrive/DestDir[]Expand"
|
||||
$files = @("Sample-1.txt", "Sample-2.txt")
|
||||
|
||||
# The files in "$TestDrive\SamplePreCreatedArchive.zip" are precreated.
|
||||
# The files in "$TestDrive/SamplePreCreatedArchive.zip" are precreated.
|
||||
$fileCreationTimeStamp = Get-Date -Year 2014 -Month 6 -Day 13 -Hour 15 -Minute 50 -Second 20 -Millisecond 0
|
||||
|
||||
Expand-Archive -Path $sourcePath -DestinationPath $destinationPath
|
||||
@@ -770,8 +785,8 @@ Describe "Test suite for Microsoft.PowerShell.Archive module" -Tags "BVT" {
|
||||
}
|
||||
}
|
||||
It "Invoke Expand-Archive with relative path in Path parameter and -Force parameter" {
|
||||
$sourcePath = ".\SamplePreCreatedArchive.zip"
|
||||
$destinationPath = "$TestDrive\SomeOtherNonExistingDir\Path"
|
||||
$sourcePath = "./SamplePreCreatedArchive.zip"
|
||||
$destinationPath = "$TestDrive/SomeOtherNonExistingDir/Path"
|
||||
try
|
||||
{
|
||||
Push-Location $TestDrive
|
||||
@@ -787,8 +802,8 @@ Describe "Test suite for Microsoft.PowerShell.Archive module" -Tags "BVT" {
|
||||
}
|
||||
|
||||
It "Invoke Expand-Archive with relative path in LiteralPath parameter and -Force parameter" {
|
||||
$sourcePath = ".\SamplePreCreatedArchive.zip"
|
||||
$destinationPath = "$TestDrive\SomeOtherNonExistingDir\LiteralPath"
|
||||
$sourcePath = "./SamplePreCreatedArchive.zip"
|
||||
$destinationPath = "$TestDrive/SomeOtherNonExistingDir/LiteralPath"
|
||||
try
|
||||
{
|
||||
Push-Location $TestDrive
|
||||
@@ -804,8 +819,8 @@ Describe "Test suite for Microsoft.PowerShell.Archive module" -Tags "BVT" {
|
||||
}
|
||||
|
||||
It "Invoke Expand-Archive with non-existing relative directory in DestinationPath parameter and -Force parameter" {
|
||||
$sourcePath = "$TestDrive\SamplePreCreatedArchive.zip"
|
||||
$destinationPath = ".\SomeOtherNonExistingDir\DestinationPath"
|
||||
$sourcePath = "$TestDrive/SamplePreCreatedArchive.zip"
|
||||
$destinationPath = "./SomeOtherNonExistingDir/DestinationPath"
|
||||
try
|
||||
{
|
||||
Push-Location $TestDrive
|
||||
@@ -821,8 +836,8 @@ Describe "Test suite for Microsoft.PowerShell.Archive module" -Tags "BVT" {
|
||||
}
|
||||
|
||||
It "Invoke Expand-Archive with unsupported archive format" {
|
||||
$sourcePath = "$TestDrive\Sample.cab"
|
||||
$destinationPath = "$TestDrive\UnsupportedArchiveFormatDir"
|
||||
$sourcePath = "$TestDrive/Sample.cab"
|
||||
$destinationPath = "$TestDrive/UnsupportedArchiveFormatDir"
|
||||
try
|
||||
{
|
||||
Expand-Archive -Path $sourcePath -DestinationPath $destinationPath -Force
|
||||
@@ -835,9 +850,9 @@ Describe "Test suite for Microsoft.PowerShell.Archive module" -Tags "BVT" {
|
||||
}
|
||||
|
||||
It "Invoke Expand-Archive with archive file containing multiple files, directories with subdirectories and empty directories" {
|
||||
$sourcePath = "$TestDrive\SourceDir"
|
||||
$archivePath = "$TestDrive\FileAndDirTreeForExpand.zip"
|
||||
$destinationPath = "$TestDrive\FileAndDirTree"
|
||||
$sourcePath = "$TestDrive/SourceDir"
|
||||
$archivePath = "$TestDrive/FileAndDirTreeForExpand.zip"
|
||||
$destinationPath = "$TestDrive/FileAndDirTree"
|
||||
$sourceList = dir $sourcePath -Name
|
||||
|
||||
Add-CompressionAssemblies
|
||||
@@ -850,8 +865,8 @@ Describe "Test suite for Microsoft.PowerShell.Archive module" -Tags "BVT" {
|
||||
}
|
||||
|
||||
It "Validate Expand-Archive cmdlet in pipleline scenario" {
|
||||
$sourcePath = "$TestDrive\SamplePreCreated*.zip"
|
||||
$destinationPath = "$TestDrive\PipeToExpandArchive"
|
||||
$sourcePath = "$TestDrive/SamplePreCreated*.zip"
|
||||
$destinationPath = "$TestDrive/PipeToExpandArchive"
|
||||
|
||||
$content = "Some Data"
|
||||
$files = @("Sample-1.txt", "Sample-2.txt")
|
||||
@@ -867,8 +882,8 @@ Describe "Test suite for Microsoft.PowerShell.Archive module" -Tags "BVT" {
|
||||
}
|
||||
|
||||
It "Validate that Expand-Archive generates Verbose messages" {
|
||||
$sourcePath = "$TestDrive\SamplePreCreatedArchive.zip"
|
||||
$destinationPath = "$TestDrive\VerboseMessagesInExpandArchive"
|
||||
$sourcePath = "$TestDrive/SamplePreCreatedArchive.zip"
|
||||
$destinationPath = "$TestDrive/VerboseMessagesInExpandArchive"
|
||||
|
||||
try
|
||||
{
|
||||
@@ -889,8 +904,8 @@ Describe "Test suite for Microsoft.PowerShell.Archive module" -Tags "BVT" {
|
||||
}
|
||||
|
||||
It "Validate that without -Force parameter Expand-Archive generates non-terminating errors without overwriting existing files" {
|
||||
$sourcePath = "$TestDrive\SamplePreCreatedArchive.zip"
|
||||
$destinationPath = "$TestDrive\NoForceParameterExpandArchive"
|
||||
$sourcePath = "$TestDrive/SamplePreCreatedArchive.zip"
|
||||
$destinationPath = "$TestDrive/NoForceParameterExpandArchive"
|
||||
|
||||
try
|
||||
{
|
||||
@@ -910,10 +925,10 @@ Describe "Test suite for Microsoft.PowerShell.Archive module" -Tags "BVT" {
|
||||
}
|
||||
|
||||
It "Validate that without DestinationPath parameter Expand-Archive cmdlet succeeds in expanding the archive" {
|
||||
$sourcePath = "$TestDrive\SamplePreCreatedArchive.zip"
|
||||
$archivePath = "$TestDrive\NoDestinationPathParameter.zip"
|
||||
$destinationPath = "$TestDrive\NoDestinationPathParameter"
|
||||
copy $sourcePath $archivePath -Force
|
||||
$sourcePath = "$TestDrive/SamplePreCreatedArchive.zip"
|
||||
$archivePath = "$TestDrive/NoDestinationPathParameter.zip"
|
||||
$destinationPath = "$TestDrive/NoDestinationPathParameter"
|
||||
copy-item $sourcePath $archivePath -Force
|
||||
|
||||
try
|
||||
{
|
||||
@@ -929,10 +944,10 @@ Describe "Test suite for Microsoft.PowerShell.Archive module" -Tags "BVT" {
|
||||
}
|
||||
|
||||
It "Validate that without DestinationPath parameter Expand-Archive cmdlet succeeds in expanding the archive when destination directory exists" {
|
||||
$sourcePath = "$TestDrive\SamplePreCreatedArchive.zip"
|
||||
$archivePath = "$TestDrive\NoDestinationPathParameterDirExists.zip"
|
||||
$destinationPath = "$TestDrive\NoDestinationPathParameterDirExists"
|
||||
copy $sourcePath $archivePath -Force
|
||||
$sourcePath = "$TestDrive/SamplePreCreatedArchive.zip"
|
||||
$archivePath = "$TestDrive/NoDestinationPathParameterDirExists.zip"
|
||||
$destinationPath = "$TestDrive/NoDestinationPathParameterDirExists"
|
||||
copy-item $sourcePath $archivePath -Force
|
||||
New-Item -Path $destinationPath -ItemType Directory | Out-Null
|
||||
|
||||
try
|
||||
@@ -948,4 +963,4 @@ Describe "Test suite for Microsoft.PowerShell.Archive module" -Tags "BVT" {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
Describe "History cmdlet test cases" -tags 'DRT' {
|
||||
Describe "History cmdlet test cases" -Tags "CI" {
|
||||
|
||||
It "Tests Invoke-History on a cmdlet that generates output on all streams" {
|
||||
$streamSpammer = '
|
||||
@@ -61,4 +61,4 @@ Describe "History cmdlet test cases" -tags 'DRT' {
|
||||
|
||||
$errorResult | Should be CommandNotFoundException
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+14
-13
@@ -2,16 +2,21 @@
|
||||
## Copyright (c) Microsoft Corporation, 2015
|
||||
##
|
||||
|
||||
Describe "Tests Get-Command with relative paths and wildcards" {
|
||||
Describe "Tests Get-Command with relative paths and wildcards" -Tag "CI" {
|
||||
|
||||
BeforeAll {
|
||||
# Create temporary EXE command files
|
||||
$null = New-Item -ItemType File -Path (Join-Path $env:Temp WildCardCommandA.exe) -ErrorAction Ignore
|
||||
$null = New-Item -ItemType File -Path (Join-Path $env:Temp WildCardCommand[B].exe) -ErrorAction Ignore
|
||||
$file1 = Setup -f WildCardCommandA.exe -pass
|
||||
$file2 = Setup -f WildCard
|
||||
$null = New-Item -ItemType File -Path (Join-Path $TestDrive WildCardCommandA.exe) -ErrorAction Ignore
|
||||
$null = New-Item -ItemType File -Path (Join-Path $TestDRive WildCardCommand[B].exe) -ErrorAction Ignore
|
||||
if ( $IsLinux -or $IsOSX ) {
|
||||
/bin/chmod +x
|
||||
}
|
||||
}
|
||||
|
||||
It "Test wildcard with drive relative directory path" {
|
||||
$pathName = Join-Path $env:Temp "WildCardCommandA*"
|
||||
$pathName = Join-Path $TestDrive "WildCardCommandA*"
|
||||
$pathName = $pathName.Substring(2, ($pathName.Length - 2))
|
||||
$result = Get-Command -Name $pathName
|
||||
$result | Should Not Be $null
|
||||
@@ -19,15 +24,15 @@ Describe "Tests Get-Command with relative paths and wildcards" {
|
||||
}
|
||||
|
||||
It "Test wildcard with relative directory path" {
|
||||
pushd $env:Temp
|
||||
push-location $TestDrive
|
||||
$result = Get-Command -Name .\WildCardCommandA*
|
||||
popd
|
||||
pop-location
|
||||
$result | Should Not Be $null
|
||||
$result | Should Be WildCardCommandA.exe
|
||||
}
|
||||
|
||||
It "Test with PowerShell wildcard and reative path" {
|
||||
pushd $env:Temp
|
||||
It "Test with PowerShell wildcard and relative path" {
|
||||
push-location $TestDrive
|
||||
|
||||
# This should use the wildcard to find WildCardCommandA.exe
|
||||
$result = Get-Command -Name .\WildCardCommand[A].exe
|
||||
@@ -39,11 +44,7 @@ Describe "Tests Get-Command with relative paths and wildcards" {
|
||||
$result | Should Not Be $null
|
||||
$result | Should Be WildCardCommand[B].exe
|
||||
|
||||
popd
|
||||
Pop-Location
|
||||
}
|
||||
|
||||
AfterAll {
|
||||
# Remove temporary files
|
||||
Remove-Item -Path (Join-Path $env:Temp WildCardCommand*) -Force -ErrorAction Ignore
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
# If PS Remoting is not available, do not run the suite.
|
||||
function ShouldRun
|
||||
{
|
||||
if ( $IsCore ) { return $false }
|
||||
$result = Invoke-Command -ComputerName . -ScriptBlock {1} -ErrorAction SilentlyContinue
|
||||
return ($result -eq 1)
|
||||
}
|
||||
@@ -17,7 +18,7 @@ if (-not (ShouldRun))
|
||||
return
|
||||
}
|
||||
|
||||
Describe "Validate Copy-Item Remotely" -Tags "Innerloop", "DRT" {
|
||||
Describe "Validate Copy-Item Remotely" -Tags "CI" {
|
||||
|
||||
# Validate a copy item operation.
|
||||
# $filePath is the source file path
|
||||
@@ -643,7 +644,7 @@ Describe "Validate Copy-Item Remotely" -Tags "Innerloop", "DRT" {
|
||||
}
|
||||
}
|
||||
|
||||
Describe "Validate Copy-Item error for target sessions not in FullLanguageMode." -Tags "Innerloop", "RI", "P1" {
|
||||
Describe "Validate Copy-Item error for target sessions not in FullLanguageMode." -Tags "Feature" {
|
||||
|
||||
BeforeAll {
|
||||
|
||||
@@ -731,7 +732,7 @@ Describe "Validate Copy-Item error for target sessions not in FullLanguageMode."
|
||||
}
|
||||
}
|
||||
|
||||
Describe "Copy-Item can use Recurse and Exclude together" -Tags "RI", "P1" {
|
||||
Describe "Copy-Item can use Recurse and Exclude together" -Tags "Feature" {
|
||||
|
||||
Context "Local and Remote Tests" {
|
||||
|
||||
@@ -776,7 +777,7 @@ Describe "Copy-Item can use Recurse and Exclude together" -Tags "RI", "P1" {
|
||||
}
|
||||
}
|
||||
|
||||
Describe "Copy-Item remotely bug fixes" -Tags "RI", "P1" {
|
||||
Describe "Copy-Item remotely bug fixes" -Tags "Feature" {
|
||||
|
||||
BeforeAll {
|
||||
$s = New-PSSession -ComputerName . -ErrorAction SilentlyContinue
|
||||
@@ -864,4 +865,4 @@ Describe "Copy-Item remotely bug fixes" -Tags "RI", "P1" {
|
||||
"TestDrive:\AnotherDestination\FileThatDoesNotExist.txt" | Should Exist
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
# Tests related to TFS item 1370133 [PSUpgrade] Need -NoNewline parameter on Out-File, Add-Content and Set-Content
|
||||
# Connect request https://connect.microsoft.com/PowerShell/feedback/details/524739/need-nonewline-parameter-on-out-file-add-content-and-set-content
|
||||
|
||||
Describe "Tests for -NoNewline parameter of Out-File, Add-Content and Set-Content" -tags 'P1', 'RI' {
|
||||
Describe "Tests for -NoNewline parameter of Out-File, Add-Content and Set-Content" -tags "Feature" {
|
||||
|
||||
It "NoNewline parameter works on Out-File" {
|
||||
$temp = New-TemporaryFile
|
||||
@@ -23,4 +23,4 @@ Describe "Tests for -NoNewline parameter of Out-File, Add-Content and Set-Conten
|
||||
(Get-Content $temp -Encoding Byte).Count | Should Be 9
|
||||
Remove-Item $temp -ErrorAction SilentlyContinue -Force
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,26 +14,25 @@
|
||||
Hexa decimal equivalent of the input data is displayed.
|
||||
#>
|
||||
|
||||
Describe "FormatHex" -tags 'DRT' {
|
||||
Describe "FormatHex" -tags "CI" {
|
||||
BeforeAll {
|
||||
Setup -d FormatHexDataDir
|
||||
$inputText1 = 'Hello World'
|
||||
$inputText2 = 'This is a bit more text'
|
||||
$inputFile1 = setup -f "FormatHexDataDir/SourceFile-1.txt" -content $inputText1 -pass
|
||||
$inputFile2 = setup -f "FormatHexDataDir/SourceFile-2.txt" -content $inputText2 -pass
|
||||
}
|
||||
|
||||
New-Item TestDrive:\FormatHexDataDir -Type Directory -Force | Out-Null
|
||||
$inputFile = "TestDrive:\FormatHexDataDir\SourceFile-1.txt"
|
||||
$inputText = 'Hello World'
|
||||
Set-Content -Value $inputText -Path $inputFile
|
||||
$inputFile2 = "TestDrive:\FormatHexDataDir\SourceFile-2.txt"
|
||||
$inputText2 = 'This is a bit more text'
|
||||
Set-Content -Value $inputText2 -Path $inputFile2
|
||||
|
||||
# This test is to validate to pipeline support in Format-Hex cmdlet.
|
||||
It "ValidatePipelineSupport" {
|
||||
|
||||
# InputObject Parameter set should get invoked and
|
||||
# the input data should be treated as string.
|
||||
$result = $inputText | Format-Hex
|
||||
$result = $inputText1 | Format-Hex
|
||||
$result | Should Not Be $null
|
||||
$result.GetType().Name | Should Be 'ByteCollection'
|
||||
$actualResult = $result.ToString()
|
||||
($actualResult -match $inputText) | Should Be $true
|
||||
($actualResult -match $inputText1) | Should Be $true
|
||||
}
|
||||
|
||||
# This test is to validate to pipeline support in Format-Hex cmdlet.
|
||||
@@ -41,63 +40,63 @@ Describe "FormatHex" -tags 'DRT' {
|
||||
|
||||
# InputObject Parameter set should get invoked and
|
||||
# the input data should be treated as byte[].
|
||||
$inputBytes = [System.Text.Encoding]::ASCII.GetBytes($inputText)
|
||||
$inputBytes = [System.Text.Encoding]::ASCII.GetBytes($inputText1)
|
||||
|
||||
$result = Format-Hex -InputObject $inputBytes
|
||||
$result | Should Not Be $null
|
||||
$result.GetType().Name | Should Be 'ByteCollection'
|
||||
$actualResult = $result.ToString()
|
||||
($actualResult -match $inputText) | Should Be $true
|
||||
($actualResult -match $inputText1) | Should Be $true
|
||||
}
|
||||
|
||||
# This test is to validate to input given through Path paramter set in Format-Hex cmdlet.
|
||||
It "ValidatePathParameterSet" {
|
||||
|
||||
$result = Format-Hex -Path $inputFile
|
||||
$result = Format-Hex -Path $inputFile1
|
||||
$result | Should Not Be $null
|
||||
$result.GetType().Name | Should Be 'ByteCollection'
|
||||
$actualResult = $result.ToString()
|
||||
($actualResult -match $inputText) | Should Be $true
|
||||
($actualResult -match $inputText1) | Should Be $true
|
||||
}
|
||||
|
||||
# This test is to validate to Path paramter set is considered as default in Format-Hex cmdlet.
|
||||
It "ValidatePathAsDefaultParameterSet" {
|
||||
|
||||
$result = Format-Hex $inputFile
|
||||
$result = Format-Hex $inputFile1
|
||||
$result | Should Not BeNullOrEmpty
|
||||
$result.GetType().Name | Should Be 'ByteCollection'
|
||||
$actualResult = $result.ToString()
|
||||
($actualResult -match $inputText) | Should Be $true
|
||||
($actualResult -match $inputText1) | Should Be $true
|
||||
}
|
||||
|
||||
# This test is to validate to input given through LiteralPath paramter set in Format-Hex cmdlet.
|
||||
It "ValidateLiteralPathParameterSet" {
|
||||
|
||||
$result = Format-Hex -LiteralPath $inputFile
|
||||
$result = Format-Hex -LiteralPath $inputFile1
|
||||
$result | Should Not BeNullOrEmpty
|
||||
$result.GetType().Name | Should Be 'ByteCollection'
|
||||
$actualResult = $result.ToString()
|
||||
($actualResult -match $inputText) | Should Be $true
|
||||
($actualResult -match $inputText1) | Should Be $true
|
||||
}
|
||||
|
||||
# This test is to validate to input given through pipeline. The input being piped from results of Get-hildItem
|
||||
It "ValidateFileInfoPipelineInput" {
|
||||
|
||||
$result = Get-ChildItem $inputFile | Format-Hex
|
||||
$result = Get-ChildItem $inputFile1 | Format-Hex
|
||||
$result | Should Not BeNullOrEmpty
|
||||
$result.GetType().Name | Should Be 'ByteCollection'
|
||||
$actualResult = $result.ToString()
|
||||
($actualResult -match $inputText) | Should Be $true
|
||||
($actualResult -match $inputText1) | Should Be $true
|
||||
}
|
||||
|
||||
# This test is to validate Encoding formats functionality of Format-Hex cmdlet.
|
||||
It "ValidateEncodingFormats" {
|
||||
|
||||
$result = Format-Hex -InputObject $inputText -Encoding ASCII
|
||||
$result = Format-Hex -InputObject $inputText1 -Encoding ASCII
|
||||
$result | Should Not BeNullOrEmpty
|
||||
$result.GetType().Name | Should Be 'ByteCollection'
|
||||
$actualResult = $result.ToString()
|
||||
($actualResult -match $inputText) | Should Be $true
|
||||
($actualResult -match $inputText1) | Should Be $true
|
||||
}
|
||||
|
||||
# This test is to validate that integers can be piped to the format-hex
|
||||
@@ -190,15 +189,19 @@ Describe "FormatHex" -tags 'DRT' {
|
||||
$result | Should Not BeNullOrEmpty
|
||||
$result.Count | should be 2
|
||||
$result[0].ToString() | Should be "00000000 54 68 69 73 20 69 73 20 61 20 62 69 74 20 6D 6F This is a bit mo"
|
||||
$result[1].ToString() | Should be "00000010 72 65 20 74 65 78 74 0D 0A re text.. "
|
||||
if ( $IsCore ) {
|
||||
$result[1].ToString() | Should be "00000010 72 65 20 74 65 78 74 re text "
|
||||
}
|
||||
}
|
||||
|
||||
# This test ensures that if we stream bytes from a file, the output is correct
|
||||
It "ValidateStreamOfBytesFromFileHasProperOutput" {
|
||||
$result = Get-Content $InputFile -Encoding Byte | Format-Hex
|
||||
$result = Get-Content $InputFile1 -Encoding Byte | Format-Hex
|
||||
$result | Should Not BeNullOrEmpty
|
||||
$result.GetType().Name | Should Be "ByteCollection"
|
||||
$result.ToString() | Should be "00000000 48 65 6C 6C 6F 20 57 6F 72 6C 64 0D 0A Hello World.. "
|
||||
if ( $IsCore ) {
|
||||
$result.ToString() | Should be "00000000 48 65 6C 6C 6F 20 57 6F 72 6C 64 Hello World "
|
||||
}
|
||||
}
|
||||
|
||||
# This test is to validate the alias for Format-Hex cmdlet.
|
||||
|
||||
+23
-4
@@ -1,4 +1,4 @@
|
||||
Describe "Using delimiters with Export-CSV and Import-CSV behave correctly" -tags P1 {
|
||||
Describe "Using delimiters with Export-CSV and Import-CSV behave correctly" -tags "Feature" {
|
||||
BeforeAll {
|
||||
# note, we will not use "," as that's the default for CSV
|
||||
$delimiters = "/", " ", "@", "#", "$", "\", "&", "(", ")",
|
||||
@@ -6,6 +6,9 @@ Describe "Using delimiters with Export-CSV and Import-CSV behave correctly" -tag
|
||||
'"', "~", "!", "%", "^", "*", "_", "+", ":",
|
||||
"?", "-", "=", "[", "]", "."
|
||||
$defaultDelimiter = [System.Globalization.CultureInfo]::CurrentCulture.TextInfo.ListSeparator
|
||||
# With CORECLR the CurrentCulture.TextInfo.ListSeparator is not writable, so
|
||||
# we need to use an entirely new CultureInfo which we can modify
|
||||
$enCulture = [System.Globalization.CultureInfo]::new("en-us")
|
||||
$d = get-date
|
||||
$testCases = @(
|
||||
foreach($del in $delimiters)
|
||||
@@ -13,9 +16,25 @@ Describe "Using delimiters with Export-CSV and Import-CSV behave correctly" -tag
|
||||
@{ Delimiter = $del; Data = $d; ExpectedResult = $d.Ticks }
|
||||
}
|
||||
)
|
||||
function Set-delimiter {
|
||||
param ( $delimiter )
|
||||
if ( $IsCore ) {
|
||||
$enCulture.TextInfo.ListSeparator = $delimiter
|
||||
[System.Globalization.CultureInfo]::CurrentCulture = $enCulture
|
||||
}
|
||||
else {
|
||||
[System.Globalization.cultureInfo]::CurrentCulture.TextInfo.ListSeparator = $delimiter
|
||||
}
|
||||
}
|
||||
}
|
||||
AfterEach {
|
||||
[System.Globalization.CultureInfo]::CurrentCulture.TextInfo.ListSeparator = $defaultDelimiter
|
||||
if ( $IsCore ) {
|
||||
$enCulture.TextInfo.ListSeparator = $defaultDelimiter
|
||||
[System.Globalization.CultureInfo]::CurrentCulture = $enCulture
|
||||
}
|
||||
else {
|
||||
[System.Globalization.CultureInfo]::CurrentCulture.TextInfo.ListSeparator = $defaultDelimiter
|
||||
}
|
||||
remove-item -force -ea silentlycontinue TESTDRIVE:/file.csv
|
||||
}
|
||||
|
||||
@@ -42,7 +61,7 @@ Describe "Using delimiters with Export-CSV and Import-CSV behave correctly" -tag
|
||||
# parameter generated tests
|
||||
It 'Delimiter <Delimiter> with CSV import will fail correctly when culture does not match' -testCases $testCases {
|
||||
param ($delimiter, $Data, $ExpectedResult)
|
||||
[System.Globalization.CultureInfo]::CurrentCulture.TextInfo.ListSeparator = $delimiter
|
||||
set-Delimiter $delimiter
|
||||
$Data | export-CSV TESTDRIVE:\File.csv -useCulture
|
||||
$i = Import-CSV TESTDRIVE:\File.csv
|
||||
$i.Ticks | Should Not Be $ExpectedResult
|
||||
@@ -50,7 +69,7 @@ Describe "Using delimiters with Export-CSV and Import-CSV behave correctly" -tag
|
||||
|
||||
It 'Delimiter <Delimiter> with CSV import will succeed when culture matches export' -testCases $testCases {
|
||||
param ($delimiter, $Data, $ExpectedResult)
|
||||
[System.Globalization.CultureInfo]::CurrentCulture.TextInfo.ListSeparator = $delimiter
|
||||
set-Delimiter $delimiter
|
||||
$Data | export-CSV TESTDRIVE:\File.csv -useCulture
|
||||
$i = Import-CSV TESTDRIVE:\File.csv -useCulture
|
||||
$i.Ticks | Should Be $ExpectedResult
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
Describe "GetDateFormatUpdates" -tags 'P1', 'RI' {
|
||||
Describe "GetDateFormatUpdates" -Tags "Feature" {
|
||||
|
||||
It "Verifies that FileDate format works" {
|
||||
$date = Get-Date
|
||||
@@ -34,7 +34,7 @@ Describe "GetDateFormatUpdates" -tags 'P1', 'RI' {
|
||||
|
||||
}
|
||||
|
||||
Describe "GetRandomMiscTests" -tags 'P1', 'RI' {
|
||||
Describe "GetRandomMiscTests" -Tags "Feature" {
|
||||
It "Shouldn't overflow when using max range" {
|
||||
|
||||
$hadError = $false
|
||||
@@ -51,4 +51,4 @@ Describe "GetRandomMiscTests" -tags 'P1', 'RI' {
|
||||
|
||||
$hadError | Should be $false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
Describe -Tags "Unit","DRT" "New-Guid" {
|
||||
Describe "New-Guid" -Tags "CI" {
|
||||
|
||||
It "returns a new guid" {
|
||||
$guid = New-Guid
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
A FileInfo object for the temporary file is returned.
|
||||
#>
|
||||
|
||||
Describe "NewTemporaryFile" -tags 'DRT' {
|
||||
Describe "NewTemporaryFile" -Tags "CI" {
|
||||
|
||||
It "creates a new temporary file" {
|
||||
$tempFile = New-TemporaryFile
|
||||
|
||||
+15
-14
@@ -8,7 +8,7 @@
|
||||
# This 'Describe' is for tests that were converted from utscripts (SDXROOT/admin/monad/tests/monad/DRT/utscripts)
|
||||
# and C# tests (SDXROOT/admin/monad/tests/monad/DRT/commands/utility/UnitTests) to Pester.
|
||||
#
|
||||
Describe "Json Tests" -Tags "RI", "P1" {
|
||||
Describe "Json Tests" -Tags "Feature" {
|
||||
|
||||
BeforeAll {
|
||||
|
||||
@@ -144,7 +144,7 @@ namespace Bug378368
|
||||
$response.d.Name.First | Should Match "Joel"
|
||||
}
|
||||
|
||||
It "Convert to Json using PSOjbect" {
|
||||
It "Convert to Json using PSObject" -pending:($IsCore) {
|
||||
|
||||
$response = ConvertFrom-Json '{"d":{"__type":"SimpleJsonObject","Name":{"First":"Joel","Last":"Wood"},"Greeting":"Hello"}}'
|
||||
|
||||
@@ -204,7 +204,7 @@ namespace Bug378368
|
||||
$response2 | Should Be $result3
|
||||
}
|
||||
|
||||
It "Convert to Json using hashtable" {
|
||||
It "Convert to Json using hashtable" -pending:($IsCore) {
|
||||
|
||||
$nameHash = @{First="Joe1";Last="Wood"}
|
||||
$dHash = @{Name=$nameHash; Greeting="Hello"}
|
||||
@@ -393,14 +393,14 @@ namespace Bug378368
|
||||
|
||||
# This Describe is for new Json tests
|
||||
#
|
||||
Describe "Validate Json serialization" -Tags "BVT" {
|
||||
Describe "Validate Json serialization" -Tags "CI" {
|
||||
|
||||
Context "Validate Json serialization ascii values" {
|
||||
|
||||
$testCases = @(
|
||||
@{
|
||||
TestInput = 0
|
||||
ToJson = 'null'
|
||||
ToJson = if ( $IsCore ) { '"\u0000"' } else { 'null' }
|
||||
FromJson = ''
|
||||
}
|
||||
@{
|
||||
@@ -590,12 +590,12 @@ Describe "Validate Json serialization" -Tags "BVT" {
|
||||
}
|
||||
@{
|
||||
TestInput = 38
|
||||
ToJson = '"\u0026"'
|
||||
ToJson = if ( $IsCore ) { '"&"' } else { '"\u0026"' }
|
||||
FromJson = '&'
|
||||
}
|
||||
@{
|
||||
TestInput = 39
|
||||
ToJson = '"\u0027"'
|
||||
ToJson = if ( $IsCore ) { '"''"' } else { '"\u0027"' }
|
||||
FromJson = "'"
|
||||
}
|
||||
@{
|
||||
@@ -700,7 +700,7 @@ Describe "Validate Json serialization" -Tags "BVT" {
|
||||
}
|
||||
@{
|
||||
TestInput = 60
|
||||
ToJson = '"\u003c"'
|
||||
ToJson = if ( $IsCore ) { '"<"' } else { '"\u003c"' }
|
||||
FromJson = '<'
|
||||
}
|
||||
@{
|
||||
@@ -710,7 +710,7 @@ Describe "Validate Json serialization" -Tags "BVT" {
|
||||
}
|
||||
@{
|
||||
TestInput = 62
|
||||
ToJson = '"\u003e"'
|
||||
ToJson = if ( $IsCore ) { '">"' } else { '"\u003e"' }
|
||||
FromJson = '>'
|
||||
}
|
||||
@{
|
||||
@@ -1265,7 +1265,8 @@ Describe "Validate Json serialization" -Tags "BVT" {
|
||||
{
|
||||
param ($testCase)
|
||||
|
||||
It "Validate '$($testCase.TestInput) | ConvertTo-Json' and '$($testCase.TestInput) | ConvertTo-Json | ConvertFrom-Json'" {
|
||||
if ( $TestCase.TestInput -eq "[char]::MinValue" ) { $pending = $true } else { $pending = $false }
|
||||
It "Validate '$($testCase.TestInput) | ConvertTo-Json' and '$($testCase.TestInput) | ConvertTo-Json | ConvertFrom-Json'" -pending:$pending {
|
||||
|
||||
# The test case input is executed via invoke-expression. Then, we use this value as an input to ConvertTo-Json,
|
||||
# and the result is saved into in the $result.ToJson variable. Lastly, this value is deserialized back using
|
||||
@@ -1321,7 +1322,7 @@ Describe "Validate Json serialization" -Tags "BVT" {
|
||||
}
|
||||
}
|
||||
|
||||
It "Validate that CimClass Properties for win32_bios can be serialized using ConvertTo-Json and ConvertFrom-Json" {
|
||||
It "Validate that CimClass Properties for win32_bios can be serialized using ConvertTo-Json and ConvertFrom-Json" -skip {
|
||||
|
||||
$class = Get-CimClass win32_bios
|
||||
|
||||
@@ -1361,7 +1362,7 @@ Describe "Validate Json serialization" -Tags "BVT" {
|
||||
$a = 1..5
|
||||
$b = 6..10
|
||||
|
||||
$actual = @{'a'=$a;'b'=$b} | ConvertTo-Json
|
||||
$actual = [ordered]@{'a'=$a;'b'=$b} | ConvertTo-Json
|
||||
$expected = @'
|
||||
{
|
||||
"a": [
|
||||
@@ -1385,7 +1386,7 @@ Describe "Validate Json serialization" -Tags "BVT" {
|
||||
}
|
||||
}
|
||||
|
||||
Describe "Json Bug fixes" -Tags "RI", "P1" {
|
||||
Describe "Json Bug fixes" -Tags "Feature" {
|
||||
|
||||
function RunJsonTest
|
||||
{
|
||||
@@ -1462,4 +1463,4 @@ Describe "Json Bug fixes" -Tags "RI", "P1" {
|
||||
{
|
||||
RunJsonTest $testCase
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
Describe "Tests for the Import-PowerShellDataFile cmdlet" -Tags 'P1', 'RI' {
|
||||
Describe "Tests for the Import-PowerShellDataFile cmdlet" -Tags "Feature" {
|
||||
|
||||
It "Validates error on a missing path" {
|
||||
|
||||
$foundError = ""
|
||||
try
|
||||
{
|
||||
Import-PowerShellDataFile -Path c:\SomeMissingDirectory -ErrorAction Stop
|
||||
Import-PowerShellDataFile -Path /SomeMissingDirectory -ErrorAction Stop
|
||||
}
|
||||
catch
|
||||
{
|
||||
@@ -20,7 +20,7 @@ Describe "Tests for the Import-PowerShellDataFile cmdlet" -Tags 'P1', 'RI' {
|
||||
$foundError = ""
|
||||
try
|
||||
{
|
||||
Import-PowerShellDataFile ($env:SYSTEMDRIVE + '\') -ErrorAction Stop
|
||||
Import-PowerShellDataFile ${TESTDRIVE} -ErrorAction Stop
|
||||
}
|
||||
catch
|
||||
{
|
||||
@@ -83,4 +83,4 @@ Describe "Tests for the Import-PowerShellDataFile cmdlet" -Tags 'P1', 'RI' {
|
||||
$result.Hello | Should be "World"
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
Describe "Alias tests" -Tags "innerloop", "P1", "RI" {
|
||||
Describe "Alias tests" -Tags "CI" {
|
||||
|
||||
BeforeAll {
|
||||
$testPath = Join-Path testdrive:\ ("testAlias\[.test")
|
||||
@@ -157,4 +157,4 @@ Describe "Alias tests" -Tags "innerloop", "P1", "RI" {
|
||||
$definedAlias.Definition | Should Be "update-help"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
Describe "CliXml test" -Tags "innerloop", "P1", "RI" {
|
||||
Describe "CliXml test" -Tags "CI" {
|
||||
|
||||
BeforeAll {
|
||||
$testFilePath = Join-Path "testdrive:\" "testCliXml"
|
||||
@@ -184,4 +184,4 @@ Describe "CliXml test" -Tags "innerloop", "P1", "RI" {
|
||||
$testPath | Should Not Exist
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,29 +1,29 @@
|
||||
Describe "Trace-Command" -tags "P1", "RI" {
|
||||
Describe "Trace-Command" -tags "Feature" {
|
||||
|
||||
Context "Listner options" {
|
||||
BeforeAll {
|
||||
$logFile = New-Item "TestDrive:\traceCommandLog.txt" -Force
|
||||
$actualLogFile = New-Item "TestDrive:\actualTraceCommandLog.txt" -Force
|
||||
$logFile = setup -f traceCommandLog.txt -pass
|
||||
$actualLogFile = setup -f actualTraceCommandLog.txt -pass
|
||||
}
|
||||
|
||||
AfterEach {
|
||||
Remove-Item "TestDrive:\traceCommandLog.txt" -Force -ErrorAction SilentlyContinue
|
||||
Remove-Item "TestDrive:\actualTraceCommandLog.txt" -Force -ErrorAction SilentlyContinue
|
||||
if ( test-path $logfile ) { Remove-Item $logFile }
|
||||
if ( test-path $actualLogFile ) { Remove-Item $actualLogFile }
|
||||
}
|
||||
|
||||
It "LogicalOperationStack works" {
|
||||
It "LogicalOperationStack works" -pending:($IsCore) {
|
||||
$keyword = "Trace_Command_ListenerOption_LogicalOperationStack_Foo"
|
||||
$stack = [System.Diagnostics.Trace]::CorrelationManager.LogicalOperationStack
|
||||
$stack.Push($keyword)
|
||||
|
||||
Trace-Command -Name * -Expression {echo Foo} -ListenerOption LogicalOperationStack -FilePath $logfile
|
||||
Trace-Command -Name * -Expression {write-output Foo} -ListenerOption LogicalOperationStack -FilePath $logfile
|
||||
|
||||
$log = Get-Content $logfile | Where-Object {$_ -like "*LogicalOperationStack=$keyword*"}
|
||||
$log.Count | Should BeGreaterThan 0
|
||||
}
|
||||
|
||||
It "Callstack works" {
|
||||
Trace-Command -Name * -Expression {echo Foo} -ListenerOption Callstack -FilePath $logfile
|
||||
It "Callstack works" -pending:($IsCore) {
|
||||
Trace-Command -Name * -Expression {write-output Foo} -ListenerOption Callstack -FilePath $logfile
|
||||
$log = Get-Content $logfile | Where-Object {$_ -like "*Callstack= * System.Environment.GetStackTrace(Exception e, Boolean needFileInfo)*"}
|
||||
$log.Count | Should BeGreaterThan 0
|
||||
}
|
||||
@@ -47,14 +47,14 @@ Describe "Trace-Command" -tags "P1", "RI" {
|
||||
}
|
||||
|
||||
It "None options has no effect" {
|
||||
Trace-Command -Name * -Expression {echo Foo} -ListenerOption None -FilePath $actualLogfile
|
||||
Trace-Command -name * -Expression {echo Foo} -FilePath $logfile
|
||||
Trace-Command -Name * -Expression {write-output Foo} -ListenerOption None -FilePath $actualLogfile
|
||||
Trace-Command -name * -Expression {write-output Foo} -FilePath $logfile
|
||||
|
||||
Compare-Object (Get-Content $actualLogfile) (Get-Content $logfile) | Should BeNullOrEmpty
|
||||
}
|
||||
|
||||
It "ThreadID works" {
|
||||
Trace-Command -Name * -Expression {echo Foo} -ListenerOption ThreadId -FilePath $logfile
|
||||
Trace-Command -Name * -Expression {write-output Foo} -ListenerOption ThreadId -FilePath $logfile
|
||||
$log = Get-Content $logfile | Where-Object {$_ -like "*ThreadID=*"}
|
||||
$results = $log | ForEach-Object {$_.Split("=")[1]}
|
||||
|
||||
@@ -62,7 +62,7 @@ Describe "Trace-Command" -tags "P1", "RI" {
|
||||
}
|
||||
|
||||
It "Timestamp creates logs in ascending order" {
|
||||
Trace-Command -Name * -Expression {echo Foo} -ListenerOption Timestamp -FilePath $logfile
|
||||
Trace-Command -Name * -Expression {write-output Foo} -ListenerOption Timestamp -FilePath $logfile
|
||||
$log = Get-Content $logfile | Where-Object {$_ -like "*Timestamp=*"}
|
||||
$results = $log | ForEach-Object {$_.Split("=")[1]}
|
||||
$sortedResults = $results | Sort-Object
|
||||
@@ -70,11 +70,11 @@ Describe "Trace-Command" -tags "P1", "RI" {
|
||||
}
|
||||
|
||||
It "ProcessId logs current process Id" {
|
||||
Trace-Command -Name * -Expression {echo Foo} -ListenerOption ProcessId -FilePath $logfile
|
||||
Trace-Command -Name * -Expression {write-output Foo} -ListenerOption ProcessId -FilePath $logfile
|
||||
$log = Get-Content $logfile | Where-Object {$_ -like "*ProcessID=*"}
|
||||
$results = $log | ForEach-Object {$_.Split("=")[1]}
|
||||
|
||||
$results | ForEach-Object { $_ | Should Be $pid }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
Describe "FormatData" -tags "P1", "RI" {
|
||||
Describe "FormatData" -tags "Feature" {
|
||||
|
||||
Context "Export" {
|
||||
It "can export all types" {
|
||||
try
|
||||
{
|
||||
$expectAllFormat = Get-FormatData -typename *
|
||||
$expectAllFormat | Export-FormatData -path $env:temp\allformat.ps1xml -IncludeScriptBlock
|
||||
$expectAllFormat | Export-FormatData -path $TESTDRIVE\allformat.ps1xml -IncludeScriptBlock
|
||||
|
||||
$sessionState = [System.Management.Automation.Runspaces.InitialSessionState]::CreateDefault()
|
||||
$sessionState.Formats.Clear()
|
||||
@@ -14,7 +14,7 @@ Describe "FormatData" -tags "P1", "RI" {
|
||||
$runspace = [System.Management.Automation.Runspaces.RunspaceFactory]::CreateRunspace($sessionState)
|
||||
$runspace.Open()
|
||||
|
||||
$runspace.CreatePipeline("Update-FormatData -AppendPath $env:temp\allformat.ps1xml").Invoke()
|
||||
$runspace.CreatePipeline("Update-FormatData -AppendPath $TESTDRIVE\allformat.ps1xml").Invoke()
|
||||
$actualAllFormat = $runspace.CreatePipeline("Get-FormatData -TypeName *").Invoke()
|
||||
|
||||
$expectAllFormat.Count | Should Be $actualAllFormat.Count
|
||||
@@ -23,7 +23,7 @@ Describe "FormatData" -tags "P1", "RI" {
|
||||
}
|
||||
finally
|
||||
{
|
||||
Remove-Item -Path $env:temp\allformat.ps1xml -Force -ErrorAction SilentlyContinue
|
||||
Remove-Item -Path $TESTDRIVE\allformat.ps1xml -Force -ErrorAction SilentlyContinue
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
Describe "Object cmdlets" -Tags 'innerloop', 'P1', 'RI' {
|
||||
Describe "Object cmdlets" -Tags "CI" {
|
||||
Context "Group-Object" {
|
||||
It "AsHashtable returns a hashtable" {
|
||||
$result = Get-Process | Group-Object -Property ProcessName -AsHashTable
|
||||
@@ -21,7 +21,7 @@ Describe "Object cmdlets" -Tags 'innerloop', 'P1', 'RI' {
|
||||
}
|
||||
}
|
||||
|
||||
Describe "Object cmdlets" -Tags 'DRT' {
|
||||
Describe "Object cmdlets" -Tags "CI" {
|
||||
Context "Measure-Object" {
|
||||
BeforeAll {
|
||||
## Powershell language prefers , as an array seperator without "".
|
||||
@@ -97,4 +97,4 @@ Describe "Object cmdlets" -Tags 'DRT' {
|
||||
$gmi.Count | Should Be 2
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
Describe "String cmdlets" -Tags 'innerloop', 'P1', 'RI' {
|
||||
Describe "String cmdlets" -Tags "CI" {
|
||||
Context "Select-String" {
|
||||
BeforeAll {
|
||||
$sep = [io.path]::DirectorySeparatorChar
|
||||
$fileName = New-Item 'TestDrive:\selectStr[ingLi]teralPath.txt'
|
||||
"abc" | Out-File -LiteralPath $fileName.fullname
|
||||
"bcd" | Out-File -LiteralPath $fileName.fullname -Append
|
||||
@@ -35,12 +36,13 @@ Describe "String cmdlets" -Tags 'innerloop', 'P1', 'RI' {
|
||||
(select-string -LiteralPath $fileNameWithDots "b").count | Should Be 2
|
||||
}
|
||||
|
||||
It "Network path" {
|
||||
It "Network path" -skip:($IsCore) {
|
||||
(select-string -LiteralPath $fileNameAsNetworkPath "b").count | Should Be 2
|
||||
}
|
||||
|
||||
It "throws error for non filesystem providers" {
|
||||
select-string -literalPath cert:\currentuser\my "a" -ErrorAction SilentlyContinue -ErrorVariable selectStringError
|
||||
$aaa = "aaaaaaaaaa"
|
||||
select-string -literalPath variable:\aaa "a" -ErrorAction SilentlyContinue -ErrorVariable selectStringError
|
||||
$selectStringError.FullyQualifiedErrorId | Should Be 'ProcessingFile,Microsoft.PowerShell.Commands.SelectStringCommand'
|
||||
}
|
||||
|
||||
@@ -49,7 +51,7 @@ Describe "String cmdlets" -Tags 'innerloop', 'P1', 'RI' {
|
||||
}
|
||||
|
||||
It "match object supports RelativePath method" {
|
||||
$file = "Modules\Microsoft.PowerShell.Utility\Microsoft.PowerShell.Utility.psd1"
|
||||
$file = "Modules${sep}Microsoft.PowerShell.Utility${sep}Microsoft.PowerShell.Utility.psd1"
|
||||
|
||||
$match = Select-String CmdletsToExport $pshome/$file
|
||||
|
||||
|
||||
Binary file not shown.
@@ -1,4 +1,4 @@
|
||||
Describe "XML cmdlets" -Tags 'P1', 'RI' {
|
||||
Describe "XML cmdlets" -Tags "Feature" {
|
||||
Context "Select-XML" {
|
||||
BeforeAll {
|
||||
$fileName = New-Item -Path 'TestDrive:\testSelectXml.xml'
|
||||
@@ -28,11 +28,15 @@ Describe "XML cmdlets" -Tags 'P1', 'RI' {
|
||||
$testcases += [TestData]::new('literalpath with relative paths', @{LiteralPath = $fileName.Name; XPath = 'Root'})
|
||||
$testcases += [TestData]::new('literalpath with absolute paths', @{LiteralPath = $fileName.FullName; XPath = 'Root'})
|
||||
$testcases += [TestData]::new('literalpath with path with dots', @{LiteralPath = $fileNameWithDots; XPath = 'Root'})
|
||||
$testcases += [TestData]::new('literalpath with network path', @{LiteralPath = $fileNameAsNetworkPath; XPath = 'Root'})
|
||||
if ( ! $IsCore ) {
|
||||
$testcases += [TestData]::new('literalpath with network path', @{LiteralPath = $fileNameAsNetworkPath; XPath = 'Root'})
|
||||
}
|
||||
$testcases += [TestData]::new('path with relative paths', @{Path = $fileName.Name; XPath = 'Root'})
|
||||
$testcases += [TestData]::new('path with absolute paths', @{Path = $fileName.FullName; XPath = 'Root'})
|
||||
$testcases += [TestData]::new('path with path with dots', @{Path = $fileNameWithDots; XPath = 'Root'})
|
||||
$testcases += [TestData]::new('path with network path', @{Path = $fileNameAsNetworkPath; XPath = 'Root'})
|
||||
if ( ! $IsCore ) {
|
||||
$testcases += [TestData]::new('path with network path', @{Path = $fileNameAsNetworkPath; XPath = 'Root'})
|
||||
}
|
||||
}
|
||||
|
||||
AfterAll {
|
||||
@@ -50,13 +54,15 @@ Describe "XML cmdlets" -Tags 'P1', 'RI' {
|
||||
}
|
||||
|
||||
It "literalpath with non filesystem path" {
|
||||
Select-XML -literalPath cert:\currentuser\my "Root" -ErrorVariable selectXmlError -ErrorAction SilentlyContinue
|
||||
$__data = "abcdefg"
|
||||
Select-XML -literalPath variable:__data "Root" -ErrorVariable selectXmlError -ErrorAction SilentlyContinue
|
||||
$selectXmlError.FullyQualifiedErrorId | Should Be 'ProcessingFile,Microsoft.PowerShell.Commands.SelectXmlCommand'
|
||||
}
|
||||
|
||||
It "path with non filesystem path" {
|
||||
Select-XML -Path cert:\currentuser\my "Root" -ErrorVariable selectXmlError -ErrorAction SilentlyContinue
|
||||
$__data = "abcdefg"
|
||||
Select-XML -Path variable:\__data "Root" -ErrorVariable selectXmlError -ErrorAction SilentlyContinue
|
||||
$selectXmlError.FullyQualifiedErrorId | Should Be 'ProcessingFile,Microsoft.PowerShell.Commands.SelectXmlCommand'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user