-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTest-VBoxGUI.ps1
More file actions
170 lines (145 loc) · 4.87 KB
/
Test-VBoxGUI.ps1
File metadata and controls
170 lines (145 loc) · 4.87 KB
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
# Test-VBoxGUI.ps1
# Test script for VirtualBox Disk Image Manager GUI
Write-Output "Testing VirtualBox Disk Image Manager GUI"
Write-Output "========================================="
# Test 1: Check if required files exist
Write-Verbose "Test 1: Checking required files..."
$requiredFiles = @(
"VirtualBoxGUI.ps1",
"Modules\VBoxCommands.ps1",
"Modules\GUIComponents.ps1",
"Modules\AdvancedFeatures.ps1",
"README.md",
"Install-App.ps1"
)
$allFilesExist = $true
foreach ($file in $requiredFiles) {
$fullPath = Join-Path $PSScriptRoot $file
if (Test-Path $fullPath) {
Write-Verbose " + $file exists"
} else {
Write-Warning " - $file missing"
$allFilesExist = $false
}
}
if ($allFilesExist) {
Write-Verbose " All required files present"
} else {
Write-Warning " Some files are missing!"
return
}
# Test 2: Check if PowerShell modules can be imported without errors
Write-Verbose "Test 2: Testing module imports..."
try {
. "$PSScriptRoot\Modules\VBoxCommands.ps1"
Write-Verbose " + VBoxCommands module loaded successfully"
} catch {
Write-Warning " - VBoxCommands module failed to load: $($_.Exception.Message)"
}
try {
. "$PSScriptRoot\Modules\GUIComponents.ps1"
Write-Verbose " + GUIComponents module loaded successfully"
} catch {
Write-Warning " - GUIComponents module failed to load: $($_.Exception.Message)"
}
try {
. "$PSScriptRoot\Modules\AdvancedFeatures.ps1"
Write-Verbose " + AdvancedFeatures module loaded successfully"
} catch {
Write-Warning " - AdvancedFeatures module failed to load: $($_.Exception.Message)"
}
# Test 3: Check if VBoxManage is available
Write-Verbose "Test 3: Checking VBoxManage availability..."
$vboxAvailable = Get-Command vboxmanage.exe -ErrorAction SilentlyContinue
if ($vboxAvailable) {
Write-Verbose " + VBoxManage is available"
$versionResult = & vboxmanage --version
Write-Verbose " VirtualBox version: $versionResult"
} else {
Write-Verbose " ~ VBoxManage not found (this is expected if VirtualBox is not installed)"
}
# Test 4: Check function definitions
Write-Verbose "Test 4: Checking function definitions..."
$expectedFunctions = @(
"Invoke-VBoxCommand",
"Get-VBoxDiskImage",
"Convert-VBoxDiskImage",
"Resize-VBoxDiskImage",
"New-VBoxDiskImage",
"Optimize-VBoxDiskImage",
"Copy-VBoxDiskImage",
"Get-VBoxInfo",
"Get-VBoxSupportedFormat",
"Repair-VBoxImage",
"Protect-VBoxDiskImage",
"Unlock-VBoxDiskImage",
"Convert-PlainTextToSecureString"
)
$missingFunctions = @()
foreach ($func in $expectedFunctions) {
if (Get-Command $func -ErrorAction SilentlyContinue) {
Write-Verbose " + Function $func exists"
} else {
Write-Warning " - Function $func missing"
$missingFunctions += $func
}
}
if ($missingFunctions.Count -eq 0) {
Write-Verbose " All expected functions are defined"
} else {
Write-Warning " Missing functions: $($missingFunctions -join ', ')"
}
# Test 5: Check GUI components
Write-Verbose "Test 5: Checking GUI components..."
$expectedGUICmdlets = @(
"Initialize-MainForm",
"Initialize-ConvertTab",
"Initialize-ManageTab",
"Initialize-CreateTab",
"Initialize-AdvancedTab"
)
$missingGUIComponents = @()
foreach ($cmdlet in $expectedGUICmdlets) {
if (Get-Command $cmdlet -ErrorAction SilentlyContinue) {
Write-Verbose " + GUI component $cmdlet exists"
} else {
Write-Warning " - GUI component $cmdlet missing"
$missingGUIComponents += $cmdlet
}
}
if ($missingGUIComponents.Count -eq 0) {
Write-Verbose " All expected GUI components are defined"
} else {
Write-Warning " Missing GUI components: $($missingGUIComponents -join ', ')"
}
# Test 6: Check specific GUI functions
Write-Verbose "Test 6: Checking specific GUI functions..."
$expectedGUIFunctions = @(
"Get-DiskImage"
)
$missingGUIFunctions = @()
foreach ($func in $expectedGUIFunctions) {
if (Get-Command $func -ErrorAction SilentlyContinue) {
Write-Verbose " + GUI function $func exists"
} else {
Write-Warning " - GUI function $func missing"
$missingGUIFunctions += $func
}
}
if ($missingGUIFunctions.Count -eq 0) {
Write-Verbose " All expected GUI functions are defined"
} else {
Write-Warning " Missing GUI functions: $($missingGUIFunctions -join ', ')"
}
# Summary
Write-Output "Test Summary:"
Write-Output "============="
if ($allFilesExist -and $missingFunctions.Count -eq 0 -and $missingGUIComponents.Count -eq 0 -and $missingGUIFunctions.Count -eq 0) {
Write-Output "Application structure: COMPLETE"
Write-Output "All components are properly implemented!"
Write-Output "To run the application, execute: .\VirtualBoxGUI.ps1"
} else {
Write-Output "Application structure: INCOMPLETE"
Write-Output "Some components need attention."
}
Write-Output "Testing completed."