From bef1688f87b5fb5bb63ee72eee699876bba2fcd3 Mon Sep 17 00:00:00 2001 From: JumpingYang001 Date: Mon, 30 May 2016 01:33:31 -0700 Subject: [PATCH 1/3] Add Select-XML Pester Unit Test --- test/powershell/Select-XML.Tests.ps1 | 34 ++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 test/powershell/Select-XML.Tests.ps1 diff --git a/test/powershell/Select-XML.Tests.ps1 b/test/powershell/Select-XML.Tests.ps1 new file mode 100644 index 000000000..4b52c584d --- /dev/null +++ b/test/powershell/Select-XML.Tests.ps1 @@ -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 = @" + + + + Harry Potter + 30.00 + + + Learning XML + 25.00 + + +"@ + $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 + } + } +} From 20de9e04059337e59faf3aaa801c4f90527973e6 Mon Sep 17 00:00:00 2001 From: JumpingYang001 Date: Tue, 31 May 2016 21:25:22 -0700 Subject: [PATCH 2/3] Update fix based on comments for Select-XML Pester Test --- test/powershell/Select-XML.Tests.ps1 | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/test/powershell/Select-XML.Tests.ps1 b/test/powershell/Select-XML.Tests.ps1 index 4b52c584d..4ef388653 100644 --- a/test/powershell/Select-XML.Tests.ps1 +++ b/test/powershell/Select-XML.Tests.ps1 @@ -1,10 +1,8 @@ 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"{ + BeforeAll { + $testfile = Join-Path -Path $TestDrive -ChildPath "testfile.xml" $xmlContent = @" @@ -19,16 +17,15 @@ Describe "Select-XML DRT Unit Tests" -Tags DRT{ "@ $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 - } + } + AfterAll { + rm $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" } } From 72793ae7e411fc8e931e0d3ff227363491a4dcd3 Mon Sep 17 00:00:00 2001 From: JumpingYang001 Date: Thu, 2 Jun 2016 19:27:38 -0700 Subject: [PATCH 3/3] Update fix based on comments for Select-XML Pester Test --- test/powershell/Select-XML.Tests.ps1 | 3 --- 1 file changed, 3 deletions(-) diff --git a/test/powershell/Select-XML.Tests.ps1 b/test/powershell/Select-XML.Tests.ps1 index 4ef388653..5eff5b359 100644 --- a/test/powershell/Select-XML.Tests.ps1 +++ b/test/powershell/Select-XML.Tests.ps1 @@ -18,9 +18,6 @@ Describe "Select-XML DRT Unit Tests" -Tags DRT{ "@ $xmlContent >$testfile } - AfterAll { - rm $testfile - } It "Select-XML should work"{ $results = Select-XML -Path $testfile -XPath "/bookstore/book/title"