11$ErrorActionPreference = " Stop" ;
22Set-StrictMode - Version " Latest" ;
3-
4- function Assert-JsonEquivalent {
5- param (
6- [Parameter (Mandatory = $true )]
7- [string ] $ActualJson ,
8- [Parameter (Mandatory = $true )]
9- [string ] $ExpectedJson
10- )
11-
12- $actualValue = ConvertFrom-Json - InputObject $ActualJson | ConvertTo-Json - Depth 10 - Compress
13- $expectedValue = ConvertFrom-Json - InputObject $ExpectedJson | ConvertTo-Json - Depth 10 - Compress
14- $actualValue | Should Be $expectedValue
15- }
3+ . (Join-Path (Split-Path - Parent $MyInvocation.MyCommand.Path ) " Test-JsonAssertions.ps1" )
164
175Describe " Set-OctopusStepTemplateProperty" {
186
@@ -22,7 +10,7 @@ Describe "Set-OctopusStepTemplateProperty" {
2210 - PropertyName " Octopus.Action.Script.Syntax" `
2311 - Value " PowerShell" ;
2412 $expected = " {`r`n `" Properties`" : {`r`n `" Octopus.Action.Script.Syntax`" : `" PowerShell`"`r`n }`r`n }" ;
25- Assert-JsonEquivalent - ActualJson ( ConvertTo-OctopusJson - InputObject $stepJson ) - ExpectedJson $expected
13+ ConvertTo-OctopusJson - InputObject $stepJson | Should BeJsonEquivalent $expected
2614 }
2715
2816 It " No properties exist" {
@@ -31,7 +19,7 @@ Describe "Set-OctopusStepTemplateProperty" {
3119 - PropertyName " Octopus.Action.Script.Syntax" `
3220 - Value " PowerShell" ;
3321 $expected = " {`r`n `" Properties`" : {`r`n `" Octopus.Action.Script.Syntax`" : `" PowerShell`"`r`n }`r`n }" ;
34- Assert-JsonEquivalent - ActualJson ( ConvertTo-OctopusJson - InputObject $stepJson ) - ExpectedJson $expected
22+ ConvertTo-OctopusJson - InputObject $stepJson | Should BeJsonEquivalent $expected
3523 }
3624
3725 It " Specified property does not exist" {
@@ -40,7 +28,7 @@ Describe "Set-OctopusStepTemplateProperty" {
4028 - PropertyName " Octopus.Action.Script.Syntax" `
4129 - Value " PowerShell" ;
4230 $expected = " {`r`n `" Properties`" : {`r`n `" otherProperty`" : `"`" ,`r`n `" Octopus.Action.Script.Syntax`" : `" PowerShell`"`r`n }`r`n }" ;
43- Assert-JsonEquivalent - ActualJson ( ConvertTo-OctopusJson - InputObject $stepJson ) - ExpectedJson $expected
31+ ConvertTo-OctopusJson - InputObject $stepJson | Should BeJsonEquivalent $expected
4432 }
4533
4634 It " Property does not exist" {
@@ -49,7 +37,7 @@ Describe "Set-OctopusStepTemplateProperty" {
4937 - PropertyName " Octopus.Action.Script.Syntax" `
5038 - Value " PowerShell" ;
5139 $expected = " {`r`n `" Properties`" : {`r`n `" Octopus.Action.Script.Syntax`" : `" PowerShell`"`r`n }`r`n }" ;
52- Assert-JsonEquivalent - ActualJson ( ConvertTo-OctopusJson - InputObject $stepJson ) - ExpectedJson $expected
40+ ConvertTo-OctopusJson - InputObject $stepJson | Should BeJsonEquivalent $expected
5341 }
5442
5543 It " Property exists with a null value" {
@@ -58,7 +46,7 @@ Describe "Set-OctopusStepTemplateProperty" {
5846 - PropertyName " Octopus.Action.Script.Syntax" `
5947 - Value " PowerShell" ;
6048 $expected = " {`r`n `" Properties`" : {`r`n `" Octopus.Action.Script.Syntax`" : `" PowerShell`"`r`n }`r`n }" ;
61- Assert-JsonEquivalent - ActualJson ( ConvertTo-OctopusJson - InputObject $stepJson ) - ExpectedJson $expected
49+ ConvertTo-OctopusJson - InputObject $stepJson | Should BeJsonEquivalent $expected
6250 }
6351
6452 It " Property exists with an empty string value" {
@@ -67,7 +55,7 @@ Describe "Set-OctopusStepTemplateProperty" {
6755 - PropertyName " Octopus.Action.Script.Syntax" `
6856 - Value " PowerShell" ;
6957 $expected = " {`r`n `" Properties`" : {`r`n `" Octopus.Action.Script.Syntax`" : `" PowerShell`"`r`n }`r`n }" ;
70- Assert-JsonEquivalent - ActualJson ( ConvertTo-OctopusJson - InputObject $stepJson ) - ExpectedJson $expected
58+ ConvertTo-OctopusJson - InputObject $stepJson | Should BeJsonEquivalent $expected
7159 }
7260
7361 It " Property exists with a string value" {
@@ -76,7 +64,7 @@ Describe "Set-OctopusStepTemplateProperty" {
7664 - PropertyName " Octopus.Action.Script.Syntax" `
7765 - Value " PowerShell" ;
7866 $expected = " {`r`n `" Properties`" : {`r`n `" Octopus.Action.Script.Syntax`" : `" PowerShell`"`r`n }`r`n }" ;
79- Assert-JsonEquivalent - ActualJson ( ConvertTo-OctopusJson - InputObject $stepJson ) - ExpectedJson $expected
67+ ConvertTo-OctopusJson - InputObject $stepJson | Should BeJsonEquivalent $expected
8068 }
8169
8270
0 commit comments