@@ -6,6 +6,8 @@ InModuleScope Arcus.Scripting.ARM {
66 It " Replaces file path with inline file contents" {
77 # Arrange
88 $armTemplateFile = " $PSScriptRoot \Files\arm-template-inline.json"
9+ $originalContents = Get-Content $armTemplateFile
10+
911 try {
1012 # Act
1113 Inject- ArmContent - Path $armTemplateFile
@@ -15,14 +17,14 @@ InModuleScope Arcus.Scripting.ARM {
1517 $actual = Get-Content $armTemplateFile
1618 $actual [7 ] | Should - Be ' "value": "this is a test value",'
1719 } finally {
18- $originalFile = " $PSScriptRoot \Files\arm-template-inline-org.json"
19- Get-Content $originalFile | Out-File - FilePath $armTemplateFile
20+ $originalContents | Out-File - FilePath $armTemplateFile
2021 }
2122 }
2223 if ([Environment ]::OSVersion.VersionString -like " *Windows*" ) {
2324 It " Replaces relative file path with file contents as JSON object (windows)" {
2425 # Arrange
2526 $armTemplateFile = " $PSScriptRoot \Files\arm-template-object (windows).json"
27+ $originalContents = Get-Content $armTemplateFile
2628 try {
2729 # Act
2830 Inject- ArmContent - Path $armTemplateFile
@@ -32,17 +34,16 @@ InModuleScope Arcus.Scripting.ARM {
3234 $actual = Get-Content $armTemplateFile
3335 $actual [7 ] | Should - Be ' "value": "{\r\n \"test\": \"this is a test value\"\r\n}",'
3436 } finally {
35- $originalFile = " $PSScriptRoot \Files\arm-template-object-org (windows).json"
36- Get-Content $originalFile | Out-File - FilePath $armTemplateFile
37+ $originalContents | Out-File - FilePath $armTemplateFile
3738 }
3839 }
3940 It " Replaces absolute file path with file contents as JSON object (windows)" {
4041 # Arrange
4142 $armTemplateFile = " $PSScriptRoot \Files\arm-template-object-absolutepath (windows).json"
4243 $armTemplateDirectory = Split-Path $armTemplateFile - Parent
43- $armTemplate = Get-Content - path $armTemplateFile - Raw
44- $armTemplate = $armTemplate -replace ' #{ArmTemplateDirectory}#' , $armTemplateDirectory
45- $armTemplate | Set-Content - Path $armTemplateFile
44+ $originalContents = Get-Content $armTemplateFile
45+ $armTemplate = $originalContents -replace ' #{ArmTemplateDirectory}#' , $armTemplateDirectory
46+ $armTemplate | Out-File - FilePath $armTemplateFile
4647
4748 try {
4849 # Act
@@ -53,14 +54,14 @@ InModuleScope Arcus.Scripting.ARM {
5354 $actual = Get-Content $armTemplateFile
5455 $actual [7 ] | Should - Be ' "value": "{\r\n \"test\": \"this is a test value\"\r\n}",'
5556 } finally {
56- $originalFile = " $PSScriptRoot \Files\arm-template-object-absolutepath-org (windows).json"
57- Get-Content $originalFile | Out-File - FilePath $armTemplateFile
57+ $originalContents | Out-File - FilePath $armTemplateFile
5858 }
5959 }
6060 } else {
6161 It " Replaces relative file path with file contents as JSON object (linux)" {
6262 # Arrange
6363 $armTemplateFile = " $PSScriptRoot \Files\arm-template-object (linux).json"
64+ $originalContents = Get-Content $armTemplateFile
6465 try {
6566 # Act
6667 Inject- ArmContent - Path $armTemplateFile
@@ -70,17 +71,16 @@ InModuleScope Arcus.Scripting.ARM {
7071 $actual = Get-Content $armTemplateFile
7172 $actual [7 ] | Should - Be ' "value": "{\n \"test\": \"this is a test value\"\n}",'
7273 } finally {
73- $originalFile = " $PSScriptRoot \Files\arm-template-object-org (linux).json"
74- Get-Content $originalFile | Out-File - FilePath $armTemplateFile
74+ $originalContents | Out-File - FilePath $armTemplateFile
7575 }
7676 }
7777 It " Replaces absolute file path with file contents as JSON object (linux)" {
7878 # Arrange
7979 $armTemplateFile = " $PSScriptRoot \Files\arm-template-object-absolutepath (linux).json"
8080 $armTemplateDirectory = Split-Path $armTemplateFile - Parent
81- $armTemplate = Get-Content - path $armTemplateFile - Raw
82- $armTemplate = $armTemplate -replace ' #{ArmTemplateDirectory}#' , $armTemplateDirectory
83- $armTemplate | Set-Content - Path $armTemplateFile
81+ $originalContents = Get-Content - Path $armTemplateFile
82+ $armTemplate = $originalContents -replace ' #{ArmTemplateDirectory}#' , $armTemplateDirectory
83+ $armTemplate | Out-File - FilePath $armTemplateFile
8484
8585 try {
8686 # Act
@@ -91,14 +91,14 @@ InModuleScope Arcus.Scripting.ARM {
9191 $actual = Get-Content $armTemplateFile
9292 $actual [7 ] | Should - Be ' "value": "{\n \"test\": \"this is a test value\"\n}",'
9393 } finally {
94- $originalFile = " $PSScriptRoot \Files\arm-template-object-absolutepath-org (linux).json"
95- Get-Content $originalFile | Out-File - FilePath $armTemplateFile
94+ $originalContents | Out-File - FilePath $armTemplateFile
9695 }
9796 }
9897 }
9998 It " Replaces file path with file contents as escaped JSON and replaced special characters" {
10099 # Arrange
101100 $armTemplateFile = " $PSScriptRoot \Files\arm-template-escape.json"
101+ $originalContents = Get-Content $armTemplateFile
102102 try {
103103 # Act
104104 Inject- ArmContent - Path $armTemplateFile
@@ -108,8 +108,7 @@ InModuleScope Arcus.Scripting.ARM {
108108 $actual = Get-Content $armTemplateFile
109109 $actual [7 ] | Should - Be ' "value": "<Operation value=\"this is a test value\" />",'
110110 } finally {
111- $originalFile = " $PSScriptRoot \Files\arm-template-escape-org.json"
112- Get-Content $originalFile | Out-File - FilePath $armTemplateFile
111+ $originalContents | Out-File - FilePath $armTemplateFile
113112 }
114113 }
115114 }
0 commit comments