I have the following test:
dummy.Tests.ps1:
$here = Split-Path -Parent $MyInvocation.MyCommand.Path
$sut = (Split-Path -Leaf $MyInvocation.MyCommand.Path) -replace '\.Tests\.', '.'
. "$here\$sut"
Describe "dummy" {
It "does something useful" {
Mock Set-Content
dummy
Assert-MockCalled Set-Content -Times 1 -Exactly -ParameterFilter {
$Path -eq "C:\foo.txt"
$Value -eq "baz"
}
}
}
dummy.ps1:
function dummy {
Set-Content -Path "C:\foo.txt" -Value "bar"
}
The test passes, even though the $Value parameters don't match. If I change the $Path that is passed in so that it doesn't match, then it fails as expected.
Any suggestions on what I am doing wrong?
$PSVersionTable:
Name Value
---- -----
PSVersion 5.1.14393.1198
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.14393.1198
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
Running on Windows 10.