mirror of
https://github.com/aphrody-labs/PowerShell.git
synced 2026-10-17 12:45:47 +00:00
Add Select-XML Pester Unit Test
This commit is contained in:
1 parent
0139bcea2b
commit
bef1688f87
1 file changed
+34
@@ -0,0 +1,34 @@
|
||||
|
||||
Describe "Select-XML DRT Unit Tests" -Tags DRT{
|
||||
$tmpDirectory = $TestDrive
|
||||
$testfilename = "testfile.xml"
|
||||
$testfile = Join-Path -Path $tmpDirectory -ChildPath $testfilename
|
||||
|
||||
It "Select-XML should work"{
|
||||
$xmlContent = @"
|
||||
<?xml version ="1.0" encoding="ISO-8859-1"?>
|
||||
<bookstore>
|
||||
<book category="CHILDREN">
|
||||
<title lang="english">Harry Potter</title>
|
||||
<price>30.00</price>
|
||||
</book>
|
||||
<book category="WEB">
|
||||
<title lang="english">Learning XML</title>
|
||||
<price>25.00</price>
|
||||
</book>
|
||||
</bookstore>
|
||||
"@
|
||||
$xmlContent >$testfile
|
||||
try
|
||||
{
|
||||
$results=Select-XML -Path $testfile -XPath "/bookstore/book/title"
|
||||
$results.Count | Should Be 2
|
||||
$results[0].Node."#text" | Should Be "Harry Potter"
|
||||
$results[1].Node."#text" | Should Be "Learning XML"
|
||||
}
|
||||
finally
|
||||
{
|
||||
rm $testfile
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user