October 2017
Intermediate to advanced
440 pages
11h 47m
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:
$values = 81, 9801, 60025, 3686400, 212255761, 475316482624 $testCases = foreach ($value in $values) { @{ Value = $value; ExpectedResult = [Math]::Sqrt($value) } } It 'Calculates the square root of <Value> to be <ExpectedResult>' ...Read now
Unlock full access