Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
Context "Select-XML" {
BeforeAll {
$fileName = New-Item -Path 'TestDrive:\testSelectXml.xml'
Push-Location "$fileName\.."
"<Root>" | out-file -LiteralPath $fileName
" <Node Attribute='blah' />" | out-file -LiteralPath $fileName -Append
"</Root>" | out-file -LiteralPath $fileName -Append
Push-Location "$fileName\.."
"<Root>" | out-file -LiteralPath $fileName
" <Node Attribute='blah' />" | out-file -LiteralPath $fileName -Append
"</Root>" | out-file -LiteralPath $fileName -Append
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tabs?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It used to be tabs, and now is changed to spaces as in rest of the file.


$fileNameWithDots = $fileName.FullName.Replace("\", "\.\")

$driveLetter = [string]($fileName.FullName)[0]
$fileNameAsNetworkPath = "\\localhost\$driveLetter`$" + $fileName.FullName.SubString(2)
$fileNameAsNetworkPath = "\\localhost\$driveLetter`$" + $fileName.FullName.SubString(2)

class TestData
{
Expand Down Expand Up @@ -65,7 +65,7 @@
$file = 'env:xmltestfile'
$params = @{$parameter=$file}
$err = $null
Select-XML @params "Root" -ErrorVariable err
Select-XML @params "Root" -ErrorVariable err -ErrorAction SilentlyContinue
$err.FullyQualifiedErrorId | Should Be $expectedError
}
finally
Expand All @@ -78,7 +78,7 @@
$testfile = "$testdrive/test.xml"
Set-Content -Path $testfile -Value "<a><b>"
$err = $null
Select-Xml -Path $testfile -XPath foo -ErrorVariable err
Select-Xml -Path $testfile -XPath foo -ErrorVariable err -ErrorAction SilentlyContinue
$err.FullyQualifiedErrorId | Should Be 'ProcessingFile,Microsoft.PowerShell.Commands.SelectXmlCommand'
}

Expand All @@ -93,13 +93,13 @@
It "Returns error for invalid xmlnamespace" {
$err = $null
[xml]$xml = "<a xmlns='bar'><b xmlns:b='foo'>hello</b><c>world</c></a>"
Select-Xml -Xml $xml -XPath foo -Namespace @{c=$null} -ErrorVariable err
Select-Xml -Xml $xml -XPath foo -Namespace @{c=$null} -ErrorVariable err -ErrorAction SilentlyContinue
$err.FullyQualifiedErrorId | Should Be 'PrefixError,Microsoft.PowerShell.Commands.SelectXmlCommand'
}

It "Returns error for invalid content" {
$err = $null
Select-Xml -Content "hello" -XPath foo -ErrorVariable err
Select-Xml -Content "hello" -XPath foo -ErrorVariable err -ErrorAction SilentlyContinue
$err.FullyQualifiedErrorId | Should Be 'InvalidCastToXmlDocument,Microsoft.PowerShell.Commands.SelectXmlCommand'
}

Expand Down