This Pester test:
BeforeAll {
function Get-HtmlFileDetail {
param (
[string[]]$Path = 'E:Domains',
[string[]]$Include = 'Alive*.html'
)
return Get-ChildItem -Path $Path -Include $Include -File -Recurse | ForEach-Object {
[PSCustomObject]@{
Drive = Split-Path -Path $PSItem.FullName -Qualifier
Parent = Split-Path (Split-Path $PSItem.FullName -Parent) -Leaf
FileName = Split-Path -Path $PSItem.FullName -Leaf
BodyText = (Get-Content -Path $PSItem.FullName -Raw | Select-String -Pattern '(?<=<body>).*?(?=</body>)').Matches.Value
}
}
}
}
Describe 'FileSytem' {
Context 'Get-HtmlFileDetail' {
Context 'when path and include are NOT specified' {
BeforeAll {
Mock -CommandName Get-ChildItem -MockWith { }
}
It 'should use defaults' {
Get-HtmlFileDetail | Should -Invoke -CommandName Get-ChildItem -Times 1 -ParameterFilter {
$Path -eq 'E:Domains' -and $Include -eq 'Alive*.html'
}
}
}
}
}
Errors with:
[-] FileSytem.Get-HtmlFileDetail.when path and include are NOT specified.should use defaults 620ms (513ms|107ms)
ParameterBindingException: A parameter cannot be found that matches parameter name ‘File’.