. $PSScriptRoot\..\..\Load-PesterModules.ps1 $here = Split-Path -Parent $MyInvocation.MyCommand.Path $sut = (Split-Path -Leaf $MyInvocation.MyCommand.Path) -replace '\.tests\.', '.' $functionPath = Join-Path -Path $here -ChildPath $sut Write-Host "Overriding SUT: $functionPath" Import-Module $functionPath -Force $moduleForMock = "" #region Read-XMLFile Describe "Read-XMLFile" { $tempPath = [System.IO.Path]::GetTempFileName() Context "When The File Does Not Exist" { if (Test-Path $tempPath) { Remove-Item $tempPath -Force } It "Returns Null" { Read-XMLFile $tempPath | Should Be $null } It "Writes a Warning" { { ((Read-XMLFile $tempPath) 3>&1) -match "File could not be found" } | Should Be $true } } Context "When the File is Empty" { "" | Out-File $tempPath -Force -NoNewline It "Returns Null" { Read-XMLFile $tempPath | Should Be $null } It "Writes a Warning" { { ((Read-XMLFile $tempPath) 3>&1) -match "The Content of the Specified File is Null" } | Should Be $true } } Context "When the File is Invalid XML" { "Hello World" | Out-File $tempPath -Force -NoNewline It "Returns Null" { Read-XMLFile $tempPath | Should Be $null } It "Writes a Warning" { { ((Read-XMLFile $tempPath) 3>&1) -match "Could Not be Cast to XML" } | Should Be $true } } } #endregion Read-XMLFile