Tests/Unit/New-WorkBranch.Tests.ps1
|
# Generated by tools\Build-PublicUnitTests.ps1. Re-run to regenerate. BeforeAll { $ProjectRoot = Split-Path -Parent (Split-Path -Parent $PSScriptRoot) $ModulePath = Join-Path $ProjectRoot 'GitEasy.psd1' } Describe 'New-WorkBranch (unit contract)' { BeforeAll { Remove-Module GitEasy -Force -ErrorAction SilentlyContinue Import-Module $ModulePath -Force } It 'is exported by the GitEasy module' { @(Get-Command -Module GitEasy -Name 'New-WorkBranch').Count | Should -Be 1 } It 'has CmdletBinding' { $cmd = Get-Command 'New-WorkBranch' $cmd.CmdletBinding | Should -Be $true } It 'supports ShouldProcess (-WhatIf and -Confirm available)' { $cmd = Get-Command 'New-WorkBranch' $cmd.Parameters.ContainsKey('WhatIf') | Should -Be $true $cmd.Parameters.ContainsKey('Confirm') | Should -Be $true } It 'declares the -Name parameter' { $cmd = Get-Command 'New-WorkBranch' $cmd.Parameters.ContainsKey('Name') | Should -Be $true } It '-Name is mandatory' { $cmd = Get-Command 'New-WorkBranch' $attrs = $cmd.Parameters['Name'].Attributes $paramAttr = $attrs | Where-Object { $_.GetType().Name -eq 'ParameterAttribute' } | Select-Object -First 1 $paramAttr.Mandatory | Should -Be $true } It 'declares the -LogPath parameter' { $cmd = Get-Command 'New-WorkBranch' $cmd.Parameters.ContainsKey('LogPath') | Should -Be $true } It 'has a non-empty .SYNOPSIS' { $help = Get-Help 'New-WorkBranch' -ErrorAction SilentlyContinue $help.Synopsis | Should -Not -BeNullOrEmpty } It 'has at least one .EXAMPLE in CBH' { $help = Get-Help 'New-WorkBranch' -Full -ErrorAction SilentlyContinue @($help.examples.example).Count -gt 0 | Should -Be $true } } |