Merge pull request #1057 from PowerShell/SelectXMLPesterTest
Add Select-XML Pester Unit Test
This commit is contained in:
commit
8fca9646e9
1 changed files with 28 additions and 0 deletions
28
test/powershell/Select-XML.Tests.ps1
Normal file
28
test/powershell/Select-XML.Tests.ps1
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
|
||||||
|
Describe "Select-XML DRT Unit Tests" -Tags DRT{
|
||||||
|
|
||||||
|
BeforeAll {
|
||||||
|
$testfile = Join-Path -Path $TestDrive -ChildPath "testfile.xml"
|
||||||
|
$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
|
||||||
|
}
|
||||||
|
|
||||||
|
It "Select-XML should work"{
|
||||||
|
$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"
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue