Private/Tests/Get-RemovableFile.Tests.ps1
<#
# Get-RemovableFile (UTest) Ohne Beschreibung - **Hashtags** UTest Pester - **Version** 2020.01.26 #> Set-StrictMode -Version Latest $CmdletPath = Split-Path -Parent $MyInvocation.MyCommand.Path $CmdletName = (Split-Path -Leaf $MyInvocation.MyCommand.Path) -replace '\.Tests\.ps1', [String]::Empty $CmdletPath = Join-Path -Path $CmdletPath -ChildPath "..\..\Public\$CmdletName.ps1" . $CmdletPath Describe "Teste $CmdletName" { Context "Parameter" { It "Parameter-Signatur korrekt" { Get-Command -Name $CmdletName | Should -HaveParameter "FileType" -Type "CleanUpFileType[]" -Mandatory } It "Throw => -FileType NoExistParamArg => Ungültiges Arg" { { Get-RemovableFile -FileType "NoExistParamArg" } | Should -Throw -ErrorId "ParameterArgumentTransformationError" } } Context "Rückgabeobjekte" { It "Get-RemovableFile -FileType All => PSCustomObject" { Get-RemovableFile -FileType All | Should -BeOfType CleanUpFile } It "Get-RemovableFile -FileType All => Count -gt 0" { $result = Get-RemovableFile -FileType All $result.Length | Should -BeGreaterThan 0 } } Context 'ScriptAnalyzer Tests' { [Array]$testCase = @() $testCase += Invoke-ScriptAnalyzer -Path $CmdletPath -Severity Error, Warning -ExcludeRule PSUseSingularNouns | Foreach-Object { @{ Line = $_.Line RuleName = $_.RuleName Message = $_.Message } } It "Ist die Skript-Datei frei von Regelverletzungen?" { $testCase.Count | Should -Be 0 } if ($testCase.Count -gt 0) { It "REGEL-Verletzung: LINE <Line> | RULE <RuleName> | MESSAGE <Message>" -TestCases $testCase { param( $Line, $RuleName, $Message ) $RuleName | Should BeNullOrEmpty } } } } |