From 6184dec3ad0bf0c945c89680948c2893fb6b9477 Mon Sep 17 00:00:00 2001 From: JumpingYang001 Date: Wed, 13 Apr 2016 02:42:34 -0700 Subject: [PATCH] Update stand-alone tests for Import-Alias Pester unit test --- test/powershell/Import-Alias.Tests.ps1 | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/test/powershell/Import-Alias.Tests.ps1 b/test/powershell/Import-Alias.Tests.ps1 index 42f699b63..f47b493a4 100644 --- a/test/powershell/Import-Alias.Tests.ps1 +++ b/test/powershell/Import-Alias.Tests.ps1 @@ -1,5 +1,5 @@ Describe "Import-Alias DRT Unit Tests" -Tags DRT{ - $testAliasDirectory = Join-Path -Path $TestDrive -ChildPath ExportAliasTestDirectory + $testAliasDirectory = Join-Path -Path $TestDrive -ChildPath ImportAliasTestDirectory $testAliases = "TestAliases" $fulltestpath = Join-Path -Path $testAliasDirectory -ChildPath $testAliases @@ -60,7 +60,24 @@ Describe "Import-Alias DRT Unit Tests" -Tags DRT{ } Describe "Import-Alias" { - $pesteraliasfile = Join-Path -Path (Join-Path $PSScriptRoot -ChildPath assets) -ChildPath pesteralias.txt + $newLine=[Environment]::NewLine + $testAliasDirectory = Join-Path -Path $TestDrive -ChildPath ImportAliasTestDirectory + $testAliases = "pesteralias.txt" + $pesteraliasfile = Join-Path -Path $testAliasDirectory -ChildPath $testAliases + + BeforeEach { + New-Item -Path $testAliasDirectory -ItemType Directory -Force + + $pesteraliascontent ='# Alias File'+$newLine + $pesteraliascontent+='# Exported by : alex'+$newLine + $pesteraliascontent+='# Date/Time : Thursday, 12 November 2015 21:55:08'+$newLine + $pesteraliascontent+='# Computer : archvm'+$newLine+'"pesterecho","echo","","None"' + $pesteraliascontent > $pesteraliasfile + } + + AfterEach { + Remove-Item -Path $testAliasDirectory -Recurse -Force + } It "Should be able to import an alias file successfully" { { Import-Alias $pesteraliasfile } | Should Not throw