Mock

Before we get to the structure of tests, we need to have a look at mocking. As the word implies, a mock mimics an existing cmdlet with the functionality you expect it to show. In the aforementioned code sample, we are mocking the existing Get-ADReplicationSubnet cmdlet and simply returning nothing.

You can mock any command that can be discovered with a Get command. Since Pester is so incredibly flexible, you can add parameter filters to your mocked cmdlets to ensure that your cmdlet is only called with specific parameters inside your code.

If you need the return values of a cmdlet in subsequent tests, your mocks can also return objects. A mock simply executes a script block, which you can alter at your leisure.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.219.22.107