Tests/Remove-ItemToTrash.tests.ps1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
gci "$PSScriptRoot\..\*.psm1" | Import-Module  -force

# describes the function Remove-ItemToTrash
Describe 'Remove-ItemToTrash' {

    # scenario 1: call the function without arguments
    Context 'Running without arguments'   {
        $testbasePath = $TestDrive
        # test 1: it does not throw an exception:
        It 'runs without errors' {
            'test' > $testBasePath\test.txt
            { Remove-ItemToTrash -Path $testBasePath\test.txt } | Should Not Throw
        }
        It 'delete a file to the trash' {
            'test' > $testBasePath\test.txt
            Remove-ItemToTrash -Path $testBasePath\test.txt
            "$testBasePath\test.txt" | Should Not Exist
        }
        # test 2: it returns nothing ($null):
        It 'does not return anything'     {
            'test' > $testBasePath\test.txt
            Remove-ItemToTrash -Path $testBasePath\test.txt | Should BeNullOrEmpty 
        }
    }
}