The Actual parameter sits at a different position depending on the assertion.
Two argument assertions use [Parameter(Position = 1, ValueFromPipeline = $true)] $Actual with Expected at Position = 0. But the single subject assertions are not consistent:
- the
Boolean ones (Should-BeTrue, Should-BeFalse, Should-BeTruthy, Should-BeFalsy) have no Position at all, so Should-BeTrue $x does not bind,
Should-BeEmptyString uses Position = 0,
Should-BeNull uses Position = 1 even though there is no Position = 0 parameter,
Should-BeAfter and Should-BeBefore put Actual at Position = 2.
Pick one rule for single subject assertions (Actual at Position = 0 with ValueFromPipeline) and apply it, so passing Actual positionally works and the position does not jump around.
Part of the new Should-* assertion consistency audit, see #2874.
🤖
The
Actualparameter sits at a different position depending on the assertion.Two argument assertions use
[Parameter(Position = 1, ValueFromPipeline = $true)] $ActualwithExpectedatPosition = 0. But the single subject assertions are not consistent:Booleanones (Should-BeTrue,Should-BeFalse,Should-BeTruthy,Should-BeFalsy) have noPositionat all, soShould-BeTrue $xdoes not bind,Should-BeEmptyStringusesPosition = 0,Should-BeNullusesPosition = 1even though there is noPosition = 0parameter,Should-BeAfterandShould-BeBeforeputActualatPosition = 2.Pick one rule for single subject assertions (
ActualatPosition = 0withValueFromPipeline) and apply it, so passingActualpositionally works and the position does not jump around.Part of the new
Should-*assertion consistency audit, see #2874.🤖