vexx32 / PSKoans

A simple, fun, and interactive way to learn the PowerShell language through Pester unit testing.
GNU General Public License v3.0
1.72k stars 176 forks source link

About XML addresses $RootElement but that changes with the next test #469

Closed DEberhardt closed 2 years ago

DEberhardt commented 2 years ago

Describe "Koan Bug, Issue, or Help Request"

$xml.$rootElement.Element | Should -Be '1', '2', '3', '4', '5' Fails because $RootElement is still 'documentRoot' from previous test

Context "The Problematic Assertions"

        It 'can expand arrays in a similar way to PowerShell' {
            # If a document contains an array it can be expanded in a similar manner to any other PowerShell object.
            $xml = [Xml]@'
<root>
    <element>1</element>
    <element>2</element>
    <element>3</element>
    <element>4</element>
    <element>5</element>
</root>
'@

            $xml.$rootElement.Element | Should -Be '1', '2', '3', '4', '5'
        }

Context "Your Attempts"

replacing $xml.$RootElement.Element with $xml.root.Element works

Context "Additional Information"

PR incoming

DEberhardt commented 2 years ago

Don't mind me, this is self inflicted copy/paste error on my side. apologies.