PSDT.Location.Tests.ps1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
$testLocation = $(Split-Path -Parent $MyInvocation.MyCommand.Path);
# JH: PSDT.App improt is necessary (consider development and build environment).
# Import-Module "$testLocation\..\PSDT.App\PSDT.App.psd1" -Force;
Import-Module "$testLocation\PSDT.Location.psd1" -Force;

Describe -Tags "PSDT.Location" "Enter-Location" {

    It "pushes the first matching location, when executing command" {
      $expectedLocation = "c:\powershell";
      Mock -CommandName Get-Directory -MockWith { return @([pscustomobject]@{FullName = $expectedLocation}, [pscustomobject]@{FullName = "c:\powershell\about"}) };
      Mock -CommandName Push-Location -MockWith { };
      
      Enter-Location en;

      Assert-MockCalled -CommandName Push-Location -Times 1 -Exactly -ParameterFilter { $Path -eq $expectedLocation };
    }
}