Tests/Unit/Public/Paths/Get-ParentDirectoryPath.Tests.ps1
# Module: Orbit.Tools # Function: Test # Author: David Eberhardt # Updated: 03-JUN 2023 # Script Analyzer Exceptions #[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUserDeclaredVarsMoreThanAssignments', '', Justification = 'Context Boundaries')] # Unit Tests Describe -Tags ('Unit', 'Acceptance') "Function '$(((Split-Path -Leaf $PsCommandPath) -replace '\.Tests\.', '.') -replace '\.ps1', '')'" { InModuleScope -ModuleName 'Orbit.Tools' { BeforeAll { # Mocking basic connection commands to avoid connectivity related errors Mock Assert-GraphConnection -MockWith { $true } Mock Test-GraphConnection -MockWith { $true } Mock Assert-MicrosoftTeamsConnection -MockWith { $true } Mock Test-MicrosoftTeamsConnection -MockWith { $true } # Splatting Parameters $Params = @{ WarningAction = 'SilentlyContinue' InformationAction = 'SilentlyContinue' } # Dot Sourcing Mock Objects . "$(Split-Path -Parent ((Split-Path -Parent $PsScriptRoot) -split 'Tests')[0])\Orbit\Tests\Testing-MockedObjects.ps1" } Context 'Input' { # Pipeline, Position, etc. } Context 'Execution' { # Code Logic } Context 'Output' { #Properties, Values, Types it 'should find the parent directory' { $Parent = Get-ParentDirectoryPath -DirectoryName "C:\Temp\Parent\Directory\Path" -TargetParentDirectory Parent $Parent | Should -Be 'C:\Temp\Parent' } } } } |