From 10144d7c559e09b49b2fbe1fc87d472da494b329 Mon Sep 17 00:00:00 2001 From: TingLiu6 Date: Tue, 10 May 2016 02:07:29 -0700 Subject: [PATCH] Fixed the CR issue --- test/powershell/Update-FormatData.Tests.ps1 | 28 ++++++++++----------- test/powershell/Update-TypeData.Tests.ps1 | 22 ++++++---------- 2 files changed, 22 insertions(+), 28 deletions(-) diff --git a/test/powershell/Update-FormatData.Tests.ps1 b/test/powershell/Update-FormatData.Tests.ps1 index c0bd62d85..c52214830 100644 --- a/test/powershell/Update-FormatData.Tests.ps1 +++ b/test/powershell/Update-FormatData.Tests.ps1 @@ -2,22 +2,22 @@ Describe "Update-FormatData" { Context "Validate Update-FormatData update correctly" { - It "Should not throw upon reloading previous formatting file" { - { Update-FormatData } | Should Not throw - } + It "Should not throw upon reloading previous formatting file" { + { Update-FormatData } | Should Not throw + } - It "Should validly load formatting data" { - { Get-FormatData -typename System.Diagnostics.Process | Export-FormatData -Path "outputfile.ps1xml" } - { Update-FormatData -prependPath "outputfile.ps1xml" | Should Not throw } - { Remove-Item "outputfile.ps1xml" -ErrorAction SilentlyContinue } - } + It "Should validly load formatting data" { + $path = Join-Path -Path $TestDrive -ChildPath "outputfile.ps1xml" + Get-FormatData -typename System.Diagnostics.Process | Export-FormatData -Path $path + { Update-FormatData -prependPath $path } | Should Not throw + Remove-Item $path -ErrorAction SilentlyContinue + } } } Describe "Update-FormatData basic functionality" -Tags DRT{ - $tmpDirectory = $TestDrive $testfilename = "testfile.ps1xml" - $testfile = Join-Path -Path $tmpDirectory -ChildPath $testfilename + $testfile = Join-Path -Path $TestDrive -ChildPath $testfilename It "Update-FormatData with WhatIf should work"{ $xmlContent=@" @@ -36,15 +36,15 @@ Describe "Update-FormatData basic functionality" -Tags DRT{ "@ - $xmlContent>$testfile + $xmlContent > $testfile try { - {Update-FormatData -Append $testfile -WhatIf} | Should Not Throw - {Update-FormatData -Prepend $testfile -WhatIf} | Should Not Throw + { Update-FormatData -Append $testfile -WhatIf } | Should Not Throw + { Update-FormatData -Prepend $testfile -WhatIf } | Should Not Throw } finally { - rm $testfile + Remove-Item $testfile -ErrorAction SilentlyContinue } } } \ No newline at end of file diff --git a/test/powershell/Update-TypeData.Tests.ps1 b/test/powershell/Update-TypeData.Tests.ps1 index 963f23a0d..5375ce087 100644 --- a/test/powershell/Update-TypeData.Tests.ps1 +++ b/test/powershell/Update-TypeData.Tests.ps1 @@ -2,15 +2,9 @@ Describe "Update-TypeData" { Context "Validate Update-Type updates correctly" { - It "Should not throw upon reloading previous formatting file" { - { Update-TypeData } | Should Not throw - } - - It "Should validly load formatting data" { - { Get-TypeData -typename System.Diagnostics.Process | Export-TypeData -Path "outputfile.ps1xml" } - { Update-TypeData -prependPath "outputfile.ps1xml" | Should Not throw } - { Remove-Item "outputfile.ps1xml" -ErrorAction SilentlyContinue } - } + It "Should not throw upon reloading previous formatting file" { + { Update-TypeData } | Should Not throw + } } } @@ -62,7 +56,7 @@ Describe "Update-TypeData basic functionality" -Tags DRT{ finally { Remove-TypeData -Path $testfile - rm $testfile + Remove-Item $testfile -ErrorAction SilentlyContinue } } @@ -82,7 +76,7 @@ Describe "Update-TypeData basic functionality" -Tags DRT{ } finally { - rm $invalidFileExtensionFile + Remove-Item $invalidFileExtensionFile -ErrorAction SilentlyContinue } } @@ -105,8 +99,8 @@ Describe "Update-TypeData basic functionality" -Tags DRT{ finally { Remove-TypeData -Path $filelist - rm $invalidFileExtensionFile - rm $filelist + Remove-Item $invalidFileExtensionFile -ErrorAction SilentlyContinue + Remove-Item $filelist -ErrorAction SilentlyContinue } } @@ -359,7 +353,7 @@ Describe "Update-TypeData basic functionality" -Tags DRT{ finally { Remove-TypeData -Path $testfile - rm $testfile + Remove-Item $testfile -ErrorAction SilentlyContinue } } } \ No newline at end of file