@@ -117,21 +117,21 @@ Describe 'Write-ErrorLog' {
117117 It ' should write a valid message to the log file' {
118118
119119 # Arrange
120- Start-ScriptLogger - Path ' TestDrive:\ test.log' - NoEventLog - NoConsoleOutput
120+ Start-ScriptLogger - Path ( Join-Path - Path ' TestDrive:' - ChildPath ' test.log' ) - NoEventLog - NoConsoleOutput
121121 $callerLine = 124
122122
123123 # Act
124124 Write-ErrorLog - Message ' My Error'
125125
126126 # Assert
127- $logFile = Get-Content - Path ' TestDrive:\ test.log'
127+ $logFile = Get-Content - Path ( Join-Path - Path ' TestDrive:' - ChildPath ' test.log' )
128128 $logFile | Should - Be " 2000-12-31 01:02:03 $Env: ComputerName $Env: Username Error [Write-ErrorLog.Tests.ps1:$callerLine ] My Error"
129129 }
130130
131131 It ' should write a valid error record to the log file' {
132132
133133 # Arrange
134- Start-ScriptLogger - Path ' TestDrive:\ test.log' - NoEventLog - NoConsoleOutput
134+ Start-ScriptLogger - Path ( Join-Path - Path ' TestDrive:' - ChildPath ' test.log' ) - NoEventLog - NoConsoleOutput
135135 $callerLine = 144
136136
137137 # Act
@@ -145,14 +145,14 @@ Describe 'Write-ErrorLog' {
145145 }
146146
147147 # Assert
148- $logFile = Get-Content - Path ' TestDrive:\ test.log'
148+ $logFile = Get-Content - Path ( Join-Path - Path ' TestDrive:' - ChildPath ' test.log' )
149149 $logFile | Should - BeLike " 2000-12-31 01:02:03 $Env: ComputerName $Env: Username Error `` [Write-ErrorLog.Tests.ps1:$callerLine `` ] Attempted to divide by zero. (RuntimeException: *\Unit\Write-ErrorLog.Tests.ps1:* char:*)"
150150 }
151151
152152 It ' should write a valid message with stack trace to the log' {
153153
154154 # Arrange
155- Start-ScriptLogger - Path ' TestDrive:\ test.log' - NoEventLog - NoConsoleOutput
155+ Start-ScriptLogger - Path ( Join-Path - Path ' TestDrive:' - ChildPath ' test.log' ) - NoEventLog - NoConsoleOutput
156156 $callerLine = 165
157157
158158 # Act
@@ -166,7 +166,7 @@ Describe 'Write-ErrorLog' {
166166 }
167167
168168 # Assert
169- $logFile = Get-Content - Path ' TestDrive:\ test.log'
169+ $logFile = Get-Content - Path ( Join-Path - Path ' TestDrive:' - ChildPath ' test.log' )
170170 $logFile [0 ] | Should - BeLike " 2000-12-31 01:02:03 $Env: ComputerName $Env: Username Error `` [Write-ErrorLog.Tests.ps1:$callerLine `` ] Attempted to divide by zero. (RuntimeException: *\Unit\Write-ErrorLog.Tests.ps1:* char:*)"
171171 $logFile [1 ] | Should - BeLike " at <ScriptBlock>, *\ScriptLogger\Tests\Unit\Write-ErrorLog.Tests.ps1:*"
172172 }
@@ -177,7 +177,7 @@ Describe 'Write-ErrorLog' {
177177 It ' should write a valid message to the event log' {
178178
179179 # Arrange
180- Start-ScriptLogger - Path ' TestDrive:\ test.log' - NoLogFile - NoConsoleOutput
180+ Start-ScriptLogger - Path ( Join-Path - Path ' TestDrive:' - ChildPath ' test.log' ) - NoLogFile - NoConsoleOutput
181181 $filterTimestamp = [System.DateTime ]::Now.AddSeconds(-1 )
182182 $callerLine = 185
183183
@@ -197,7 +197,7 @@ Describe 'Write-ErrorLog' {
197197 It ' should write a valid error record to the event log' {
198198
199199 # Arrange
200- Start-ScriptLogger - Path ' TestDrive:\ test.log' - NoLogFile - NoConsoleOutput
200+ Start-ScriptLogger - Path ( Join-Path - Path ' TestDrive:' - ChildPath ' test.log' ) - NoLogFile - NoConsoleOutput
201201 $filterTimestamp = [System.DateTime ]::Now.AddSeconds(-1 )
202202 $callerLine = 211
203203
@@ -237,7 +237,7 @@ Describe 'Write-ErrorLog' {
237237 InModuleScope $moduleName {
238238
239239 # Arrange
240- Start-ScriptLogger - Path ' TestDrive:\ test.log' - NoLogFile - NoEventLog
240+ Start-ScriptLogger - Path ( Join-Path - Path ' TestDrive:' - ChildPath ' test.log' ) - NoLogFile - NoEventLog
241241
242242 # Act
243243 Write-ErrorLog - Message ' My Error'
@@ -252,7 +252,7 @@ Describe 'Write-ErrorLog' {
252252 InModuleScope $moduleName {
253253
254254 # Arrange
255- Start-ScriptLogger - Path ' TestDrive:\ test.log' - NoLogFile - NoEventLog
255+ Start-ScriptLogger - Path ( Join-Path - Path ' TestDrive:' - ChildPath ' test.log' ) - NoLogFile - NoEventLog
256256
257257 # Act
258258 try
@@ -272,7 +272,7 @@ Describe 'Write-ErrorLog' {
272272
273273 AfterEach {
274274
275- Remove-Item - Path ' TestDrive:\ test.log' - ErrorAction ' SilentlyContinue'
275+ Remove-Item - Path ( Join-Path - Path ' TestDrive:' - ChildPath ' test.log' ) - ErrorAction ' SilentlyContinue'
276276 Stop-ScriptLogger
277277 }
278278 }
0 commit comments