Private/Tests/Get-RemovableFile.Tests.ps1

<#
 
# Get-RemovableFile (UTest)
 
Ohne Beschreibung
 
- **Hashtags** UTest Pester
- **Version** 2020.12.8
 
#>


BeforeAll {
    . ($PSCommandPath.Replace('.Tests.ps1', '.ps1')).Replace('\Private\Tests\', '\Public\')
}

AfterAll {
    "<[ START SCRIPT-ANALYZER ..." | Write-Warning
    Invoke-ScriptAnalyzer -Path ($PSCommandPath.Replace('.Tests.ps1', '.ps1')).Replace('\Private\Tests\', '\Public\') -Severity Error, Warning, Information, ParseError | ForEach-Object -Process {"{0,40} - {1,4} - {2}" -f $_.ScriptName, $_.Line, $_.RuleName, $_.Message | Write-Warning }
    "... ENDE SCRIPT-ANALYZER ]>" | Write-Warning
}

Describe 'Teste Get-RemovableFile' {

    Context 'Teste Parameter "-FileType"' {

        It 'Parameter "-FileType" ist Mandatory' {
            Get-Command -Name 'Get-RemovableFile' | Should -HaveParameter 'FileType' -Mandatory
        }

        It 'Parameter "-FileType" ist vom Typ CleanUpFileType[]' {
            (Get-Command -Name 'Get-RemovableFile').Parameters['FileType'].ParameterType.Name | Should -BeExactly 'CleanUpFileType[]'

        }

        It 'Parameter "-FileType" lässt keine ungültigen Argumente zu' {
            { Get-RemovableFile -FileType 'NoExistParamArg' } | Should -Throw -ErrorId 'ParameterArgumentTransformationError,Get-RemovableFile'
        }
    }

    Context 'Teste Rückgabeobjekte' {

        It 'Rückgabe ist vom Typ "CleanUpFile"' {
            (Get-RemovableFile -FileType All | Select-Object -First 1).GetType().Name | Should -BeExactly 'CleanUpFile'
        }

        It 'Anzahl der Rückgabe-Objekte ist größer 0' {
            Get-RemovableFile -FileType All | Measure-Object | Select-Object -ExpandProperty Count | Should -BeGreaterThan 0
        }
    }
}