February 2019
Intermediate to advanced
626 pages
15h 51m
English
It is common to find that there is more than one way to achieve a result in PowerShell. In the case of the Get-SquareRoot function, .NET has a Math.Sqrt static method that can be used to produce a similar result.
The availability of an alternative approach (which is known to work) allows a result to be dynamically validated, either in place of, or in addition to, statically defined values.
The set of test cases might be adjusted to use Math.Sqrt to verify that the function is working as intended:
Describe Get-SquareRoot { It 'When the value is <Value>, the square root is <ExpectedResult>' -TestCases @( @{ Value = 81; ExpectedResult = [Math]::Sqrt(81) } @{ Value = 9801; ExpectedResult = [Math]::Sqrt(9801) } @{ Value ...Read now
Unlock full access