Should -Invoke verifies how many times a mocked command or function was called, making mock usage observable in unit tests. section 13.3.3
Use invocation counts to validate parameter-filter behavior:
- Expect ConvertFrom-Html to be called once for the search. section 13.3.3
- Expect Invoke-WebRequest to be called three times, once for each search result. section 13.3.3
- Treat higher counts as evidence that a filter is too broad and lower counts as evidence that it is too restrictive. section 13.3.3
Validating a filtered mock
A test can mock ConvertFrom-Html with a URI parameter filter, run the search, and use Should -Invoke to confirm that only the intended call triggered the mock. section 13.3.3
