-
-
Notifications
You must be signed in to change notification settings - Fork 473
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
82 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 21 additions & 30 deletions
51
tst/functions/assert/Collection/Should-BeCollection.Tests.ps1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,27 @@ | ||
Set-StrictMode -Version Latest | ||
|
||
# TODO: Implement the Should-BeCollection tests, I just don't want to remove it from the current PR just to put it back afterwards. | ||
return | ||
|
||
InPesterModuleScope { | ||
Describe "Should-BeCollection" { | ||
It "Passes when collections have the same count and items" -ForEach @( | ||
@{ Actual = @(1); Expected = @(1) } | ||
@{ Actual = @(1, 2); Expected = @(1, 2) } | ||
) { | ||
$actual | Should-BeCollection $expected | ||
} | ||
|
||
It "Fails when collections don't have the same count" -ForEach @( | ||
@{ Actual = @(1); Expected = @(1, 2) } | ||
@{ Actual = @(1, 2); Expected = @(1) } | ||
) { | ||
$err = { $actual | Should-BeCollection $expected } | Verify-AssertionFailed | ||
$err.Exception.Message | Verify-Equal "Expected int '1' to be present in collection '5', but it was not there." | ||
} | ||
|
||
# It "Passes when collection of multiple items contains the expected item" { | ||
# @(1,2,3) | Assert-Contain 1 | ||
# } | ||
Describe "Should-BeCollection" { | ||
It "Passes when collections have the same count and items" -ForEach @( | ||
@{ Actual = @(1); Expected = @(1) } | ||
@{ Actual = 1; Expected = @(1) } | ||
@{ Actual = @(1, 2); Expected = @(1, 2) } | ||
@{ Actual = @(1..3); Expected = @(1..3) } | ||
) { | ||
$actual | Should-BeCollection $expected | ||
} | ||
|
||
# It "Fails when collection of multiple items does not contain the expected item" { | ||
# $err = { @(5,6,7) | Assert-Contain 1 } | Verify-AssertionFailed | ||
# $err.Exception.Message | Verify-Equal "Expected int '1' to be present in collection '5, 6, 7', but it was not there." | ||
# } | ||
It "Fails when collections don't have the same count" -ForEach @( | ||
@{ Actual = @(1, 2); Expected = @(1, 2, 3) } | ||
@{ Actual = @(1, 2, 3); Expected = @(1, 2) } | ||
) { | ||
$err = { $actual | Should-BeCollection $expected } | Verify-AssertionFailed | ||
$err.Exception.Message | Verify-Equal "Expected [Object[]] @($($expected -join ", ")) to be present in [Object[]] @($($actual -join ", ")), but they don't have the same number of items." | ||
} | ||
|
||
# It "Can be called with positional parameters" { | ||
# { Assert-Contain 1 3,4,5 } | Verify-AssertionFailed | ||
# } | ||
It "Fails when collections don't have the same items" -ForEach @( | ||
@{ Actual = @(1, 2, 3, 4, 5); Expected = @(5, 6, 7, 8, 9) } | ||
) { | ||
$err = { $actual | Should-BeCollection $expected } | Verify-AssertionFailed | ||
$err.Exception.Message | Verify-Equal "Expected [Object[]] @(5, 6, 7, 8, 9) to be present in [Object[]] @(1, 2, 3, 4, 5) in any order, but some values were not.`nMissing in actual: '6 (index 1), 7 (index 2), 8 (index 3), 9 (index 4)'`nExtra in actual: '1 (index 0), 2 (index 1), 3 (index 2), 4 (index 3)'" | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
tst/functions/assert/Collection/Should-ContainCollection.Tests.ps1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters