1
+ Import-Module .\WindowsDiskCleanup\WindowsDiskCleanup.psm1 - Force
2
+
3
+ Describe ' Get-DiskSpace.Tests' {
4
+ BeforeAll {
5
+ Mock - CommandName Get-PSDrive - ModuleName WindowsDiskCleanup - MockWith {
6
+ return @ {
7
+ Name = ' C'
8
+ Used = 50 GB
9
+ Free = 100 GB
10
+ }
11
+ }
12
+ }
13
+
14
+ It ' should return free space in GB by default' {
15
+ $result = Get-DiskSpace
16
+ $result | Should - Be 100
17
+ }
18
+
19
+ It ' should return total space in GB' {
20
+ $result = Get-DiskSpace - Name ' C' - SpaceType ' Total' - Unit ' GB'
21
+ $result | Should - Be 150
22
+ }
23
+
24
+ It ' should return used space in GB' {
25
+ $result = Get-DiskSpace - Name ' C' - SpaceType ' Used' - Unit ' GB'
26
+ $result | Should - Be 50
27
+ }
28
+
29
+ It ' should return free space in MB' {
30
+ $result = Get-DiskSpace - Name ' C' - SpaceType ' Free' - Unit ' MB'
31
+ $result | Should - Be (100 * 1024 )
32
+ }
33
+
34
+ It ' should return total space in MB' {
35
+ $result = Get-DiskSpace - Name ' C' - SpaceType ' Total' - Unit ' MB'
36
+ $result | Should - Be (150 * 1024 )
37
+ }
38
+
39
+ It ' should return used space in MB' {
40
+ $result = Get-DiskSpace - Name ' C' - SpaceType ' Used' - Unit ' MB'
41
+ $result | Should - Be (50 * 1024 )
42
+ }
43
+
44
+ It ' should return free space in KB' {
45
+ $result = Get-DiskSpace - Name ' C' - SpaceType ' Free' - Unit ' KB'
46
+ $result | Should - Be (100 * 1024 * 1024 )
47
+ }
48
+
49
+ It ' should return total space in KB' {
50
+ $result = Get-DiskSpace - Name ' C' - SpaceType ' Total' - Unit ' KB'
51
+ $result | Should - Be (150 * 1024 * 1024 )
52
+ }
53
+
54
+ It ' should return used space in KB' {
55
+ $result = Get-DiskSpace - Name ' C' - SpaceType ' Used' - Unit ' KB'
56
+ $result | Should - Be (50 * 1024 * 1024 )
57
+ }
58
+ }
0 commit comments