If i have this function:
Function Test-Foo {
$filePath = Read-Host "Tell me a file path"
}
How do i mock the Read-Host to return what i want? e.g. I want to do something like this (which doesn't work):
Describe "Test-Foo" {
Context "When something" {
Mock Read-Host {return "c:\example"}
$result = Test-Foo
It "Returns correct result" {
$result | Should Be "c:\example"
}
}
}
This behavior is correct:
you should change you're code to