11BeforeAll {
22 $scriptPath = " $PSScriptRoot \Get-RessourcesFromAM.ps1"
3+ $script :scriptContent = Get-Content $scriptPath - Raw
34}
45
56Describe " Get-RessourcesFromAM.ps1 Tests" {
67 Context " Parameter Validation" {
78 It " Should require filePath parameter" {
89 $scriptAst = [System.Management.Automation.Language.Parser ]::ParseFile($scriptPath , [ref ]$null , [ref ]$null )
9- $params = $scriptAst.FindAll ({$args [0 ] -is [System.Management.Automation.Language.ParameterAst ]}, $true )
10-
10+ $params = $scriptAst.FindAll ({ $args [0 ] -is [System.Management.Automation.Language.ParameterAst ] }, $true )
1111 $filePathParam = $params | Where-Object { $_.Name.VariablePath.UserPath -eq ' filePath' }
1212 $filePathParam | Should -Not - BeNullOrEmpty
13-
13+
1414 # Check if parameter is mandatory
15- $isMandatory = $filePathParam.Attributes | Where-Object {
16- $_.TypeName.Name -eq ' Parameter' -and
15+ $isMandatory = $filePathParam.Attributes | Where-Object {
16+ $_.TypeName.Name -eq ' Parameter' -and
1717 $_.NamedArguments.ArgumentName -contains ' Mandatory'
1818 }
1919 $isMandatory | Should -Not - BeNullOrEmpty
2020 }
21-
2221 It " Should have default output file" {
23- $scriptContent = Get-Content $scriptPath - Raw
2422 $scriptContent | Should -Match ' outputFile.*=.*".*summary\.json"'
2523 }
2624 }
2725
2826 Context " Excel File Processing" {
2927 It " Should check for Excel file existence" {
3028 Mock Test-Path { return $false }
31-
29+
3230 # Test would validate file existence check
31+
3332 $true | Should - Be $true
3433 }
3534
@@ -44,31 +43,31 @@ Describe "Get-RessourcesFromAM.ps1 Tests" {
4443 It " Should convert Premium disk SKU correctly" {
4544 $testSku = " Premium SSD P30"
4645 $expected = " Premium_LRS"
47-
46+
4847 $result = switch - Wildcard ($testSku ) {
49- " PremiumV2*" { " PremiumV2_LRS" ; break }
50- " Premium*" { " Premium_LRS" ; break }
51- " StandardSSD*" { " StandardSSD_LRS" ; break }
52- " Standard*" { " Standard_LRS" ; break }
53- " Ultra*" { " UltraSSD_LRS" ; break }
54- default { " Unknown" }
48+ " PremiumV2*" { " PremiumV2_LRS" ; break }
49+ " Premium*" { " Premium_LRS" ; break }
50+ " StandardSSD*" { " StandardSSD_LRS" ; break }
51+ " Standard*" { " Standard_LRS" ; break }
52+ " Ultra*" { " UltraSSD_LRS" ; break }
53+ default { " Unknown" }
5554 }
56-
55+
5756 $result | Should - Be $expected
5857 }
5958
6059 It " Should convert StandardSSD disk SKU correctly" {
6160 $testSku = " StandardSSD E10"
62-
61+
6362 $result = switch - Wildcard ($testSku ) {
64- " PremiumV2*" { " PremiumV2_LRS" ; break }
65- " Premium*" { " Premium_LRS" ; break }
66- " StandardSSD*" { " StandardSSD_LRS" ; break }
67- " Standard*" { " Standard_LRS" ; break }
68- " Ultra*" { " UltraSSD_LRS" ; break }
69- default { " Unknown" }
63+ " PremiumV2*" { " PremiumV2_LRS" ; break }
64+ " Premium*" { " Premium_LRS" ; break }
65+ " StandardSSD*" { " StandardSSD_LRS" ; break }
66+ " Standard*" { " Standard_LRS" ; break }
67+ " Ultra*" { " UltraSSD_LRS" ; break }
68+ default { " Unknown" }
7069 }
71-
70+
7271 $result | Should - Be " StandardSSD_LRS"
7372 }
7473 }
0 commit comments