Skip to content

Commit

Permalink
Add pipeline input (#52)
Browse files Browse the repository at this point in the history
* Change parameter declarations

* Add basic tests

* Apply suggestions from code review

Co-authored-by: Jakub Jareš <[email protected]>

---------

Co-authored-by: Jakub Jareš <[email protected]>
  • Loading branch information
ronaldborman and nohwnd authored Jun 20, 2024
1 parent b83ae96 commit b3146a0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/Equivalence/Assert-Equivalent.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -658,7 +658,9 @@ function Compare-Equivalent {
function Assert-Equivalent {
[CmdletBinding()]
param(
[Parameter(Position = 1, ValueFromPipeline = $true)]
$Actual,
[Parameter(Position = 0, Mandatory)]
$Expected,
$Options = (Get-EquivalencyOption),
[Switch] $StrictOrder
Expand Down
10 changes: 10 additions & 0 deletions tst/Equivalence/Assert-Equivalent.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -479,5 +479,15 @@ InModuleScope -ModuleName Assert {
It "Can be called with positional parameters" {
{ Assert-Equivalent 1 2 } | Verify-AssertionFailed
}

It "Can be passed pipeline input and a named parameter" {
1 | Assert-Equivalent -Expected 1
{ 1 | Assert-Equivalent -Expected 2 } | Verify-AssertionFailed
}

It "Can be passed pipeline input and a positional parameter" {
1 | Assert-Equivalent 1
{ 1 | Assert-Equivalent 2 } | Verify-AssertionFailed
}
}
}

0 comments on commit b3146a0

Please sign in to comment.