Skip to content

Commit

Permalink
Cleanup examples (#2580)
Browse files Browse the repository at this point in the history
Missing linebreak between code and description
  • Loading branch information
fflaten authored Dec 13, 2024
1 parent 422ef99 commit 1889db3
Show file tree
Hide file tree
Showing 9 changed files with 27 additions and 23 deletions.
38 changes: 21 additions & 17 deletions src/functions/assert/Equivalence/Should-BeEquivalent.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -639,43 +639,45 @@ function Should-BeEquivalent {
.EXAMPLE
```powershell
Should-BeEquivalent ... -ExcludePath 'Id', 'Timestamp' -Comparator 'Equality'
Should-BeEquivalent ... -ExcludePath 'Id', 'Timestamp' -Comparator 'Equality'
```
This example generates an equivalency option object that excludes the 'Id' and 'Timestamp' properties from the comparison and uses a simple equality comparison strategy.
.EXAMPLE
```powereshell
Should-BeEquivalent ... -ExcludePathsNotOnExpected
Should-BeEquivalent ... -ExcludePathsNotOnExpected
```
This example generates an equivalency option object that excludes any paths not present on the expected object from the comparison, using the default deep comparison strategy.
.EXAMPLE
```powershell
$expected = [PSCustomObject] @{
Name = "Thomas"
}
$expected = [PSCustomObject] @{
Name = "Thomas"
}
$actual = [PSCustomObject] @{
Name = "Jakub"
Age = 30
}
$actual = [PSCustomObject] @{
Name = "Jakub"
Age = 30
}
$actual | Should-BeEquivalent $expected
$actual | Should-BeEquivalent $expected
```
This will throw an error because the actual object has an additional property Age and the Name values are not equivalent.
.EXAMPLE
```powershell
$expected = [PSCustomObject] @{
Name = "Thomas"
}
$expected = [PSCustomObject] @{
Name = "Thomas"
}
$actual = [PSCustomObject] @{
Name = "Thomas"
}
$actual = [PSCustomObject] @{
Name = "Thomas"
}
$actual | Should-BeEquivalent $expected
$actual | Should-BeEquivalent $expected
```
This will pass because the actual object has the same properties as the expected object and the Name values are equivalent.
Expand Down Expand Up @@ -737,10 +739,12 @@ function Get-EquivalencyOption {
.EXAMPLE
$option = Get-EquivalencyOption -ExcludePath 'Id', 'Timestamp' -Comparator 'Equality'
This example generates an equivalency option object that excludes the 'Id' and 'Timestamp' properties from the comparison and uses a simple equality comparison strategy.
.EXAMPLE
$option = Get-EquivalencyOption -ExcludePathsNotOnExpected
This example generates an equivalency option object that excludes any paths not present on the expected object from the comparison, using the default deep comparison strategy.
.LINK
Expand Down
1 change: 1 addition & 0 deletions src/functions/assert/General/Should-NotBeSame.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
$object = New-Object -TypeName PSObject
$object | Should-NotBeSame $object
```
This assertion will pass, because the actual value is not the same instance as the expected value.
.EXAMPLE
Expand Down
1 change: 0 additions & 1 deletion src/functions/assert/String/Should-BeLikeString.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ function Should-BeLikeString {
.EXAMPLE
```powershell
"hello" | Should-BeLikeString "H*" -CaseSensitive
```
Expand Down
2 changes: 1 addition & 1 deletion src/functions/assert/String/Should-NotBeEmptyString.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
This test will fail, the input is an empty string.
.EXAMPLE
```
```powershell
$null | Should-NotBeEmptyString
$() | Should-NotBeEmptyString
$false | Should-NotBeEmptyString
Expand Down
2 changes: 2 additions & 0 deletions src/functions/assert/String/Should-NotBeString.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,14 @@ function Should-NotBeString {
```powershell
"hello" | Should-NotBeString "HELLO"
```
This assertion will pass, because the actual value is not equal to the expected value.
.EXAMPLE
```powershell
"hello" | Should-NotBeString "hello" -CaseSensitive
```
This assertion will fail, because the actual value is equal to the expected value.
.NOTES
Expand Down
1 change: 0 additions & 1 deletion src/functions/assert/Time/Should-BeAfter.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
(Get-Date).AddDays(1) | Should-BeAfter (Get-Date)
```
This assertion will pass, because the actual value is after the expected value.
.EXAMPLE
Expand Down
2 changes: 1 addition & 1 deletion src/functions/assert/Time/Should-BeBefore.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
```powershell
(Get-Date).AddDays(1) | Should-BeBefore (Get-Date)
```
This assertion will fail, because the actual value is not before the expected value.
.EXAMPLE
Expand All @@ -46,7 +47,6 @@
.EXAMPLE
```powershell
(Get-Date).AddDays(-2) | Should-BeBefore -Time 3days -Ago
```
Expand Down
2 changes: 1 addition & 1 deletion src/functions/assert/Time/Should-BeFasterThan.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
.EXAMPLE
```powershell
{ Start-Sleep -Milliseconds 100 } | Should-BeFasterThan 50ms
{ Start-Sleep -Milliseconds 100 } | Should-BeFasterThan 50ms
```
This assertion will fail, because the actual value is not faster than the expected value.
Expand Down
1 change: 0 additions & 1 deletion src/functions/assert/Time/Should-BeSlowerThan.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
.EXAMPLE
```powershell
{ Start-Sleep -Seconds 1 } | Should-BeSlowerThan 10seconds
```
Expand Down

0 comments on commit 1889db3

Please sign in to comment.