11# Copyright (c) Microsoft Corporation. All rights reserved.
22# Licensed under the MIT License.
33
4- Write-Verbose - Verbose (Get-Module - ListAvailable | Out-String )
4+ Write-Verbose - Verbose (" Modules:`n " + (Get-Module - ListAvailable | Out-String ))
5+ Write-Verbose - Verbose (" Exported cmdlets from PSCompatibilityCollector`n :" + (Get-Module - ListAvailable PSCompatibilityCollector | % { $_.ExportedCmdlets.Keys } | Out-String ))
56
67$script :currentMachineProfile = New-PSCompatibilityProfile - PassThru
78
8- Describe " Assert-PSCompatibilityProfileIsValid" {
9- It " Accepts a good profile" {
10- Assert-PSCompatibilityProfileIsValid - CompatibilityProfile $script :currentMachineProfile
11- $? | Should - BeTrue
12- }
13- }
9+ Describe " PSCompatiblityCollector cmdlets" {
10+ BeforeAll {
11+ $compatModulePath = (Get-Module - ListAvailable ' PSCompatibilityCollector' )[0 ].Path
12+ $pwshName = (Get-Process - Id $PID ).Path
13+ $profileLocation = Join-Path $TestDrive ' profile.json'
1414
15- Describe " JSON cmdlets" {
16- It " Serializes a compatibility profile to JSON and back again" {
17- $script :currentMachineProfile |
18- ConvertTo-PSCompatibilityJson |
19- ConvertFrom-PSCompatibilityJson |
20- Assert-PSCompatibilityProfileIsValid
15+ & $pwshName - Command " Import-Module '$compatModulePath '; New-PSCompatibilityProfile -OutFile '$profileLocation '"
2116
22- $? | Should - BeTrue
17+ $currentMachineProfile = ConvertFrom-PSCompatibilityJson - Path $profileLocation
2318 }
24- }
2519
26- Describe " Platform data and naming" {
27- It " Collects platform data properly" {
28- $platformData = Get-PSCompatibilityPlatformData
20+ Context " Assert-PSCompatibilityProfileIsValid" {
21+ It " Accepts a good profile" {
22+ Assert-PSCompatibilityProfileIsValid - CompatibilityProfile $currentMachineProfile
23+ $? | Should - BeTrue
24+ }
25+ }
2926
30- $platformData.PowerShell.Version.Major | Should - Be $PSVersionTable.PSVersion.Major
27+ Context " JSON cmdlets" {
28+ It " Serializes a compatibility profile to JSON and back again" {
29+ $currentMachineProfile |
30+ ConvertTo-PSCompatibilityJson |
31+ ConvertFrom-PSCompatibilityJson |
32+ Assert-PSCompatibilityProfileIsValid
3133
32- if ($PSEdition -eq ' Core' )
33- {
34- $platformData.Dotnet.Edition | Should - Be ' Core'
35- }
36- else
37- {
38- $platformData.Dotnet.Edition | Should - Be ' Framework'
34+ $? | Should - BeTrue
3935 }
36+ }
4037
41- if ($IsLinux )
42- {
43- $platformData.OperatingSystem.Family | Should - Be ' Linux'
44- }
45- elseif ($IsMacOS )
46- {
47- $platformData.OperatingSystem.Family | Should - Be ' MacOS'
48- }
49- else
50- {
51- $platformData.OperatingSystem.Family | Should - Be ' Windows'
38+ Context " Platform data and naming" {
39+ It " Collects platform data properly" {
40+ $platformData = Get-PSCompatibilityPlatformData
41+
42+ $platformData.PowerShell.Version.Major | Should - Be $PSVersionTable.PSVersion.Major
43+
44+ if ($PSEdition -eq ' Core' )
45+ {
46+ $platformData.Dotnet.Edition | Should - Be ' Core'
47+ }
48+ else
49+ {
50+ $platformData.Dotnet.Edition | Should - Be ' Framework'
51+ }
52+
53+ if ($IsLinux )
54+ {
55+ $platformData.OperatingSystem.Family | Should - Be ' Linux'
56+ }
57+ elseif ($IsMacOS )
58+ {
59+ $platformData.OperatingSystem.Family | Should - Be ' MacOS'
60+ }
61+ else
62+ {
63+ $platformData.OperatingSystem.Family | Should - Be ' Windows'
64+ }
5265 }
53- }
5466
55- It " Names the platform appropriately" {
56- $platformName = Get-PSCompatibilityPlatformName
67+ It " Names the platform appropriately" {
68+ $platformName = Get-PSCompatibilityPlatformName
5769
58- $platformNameElements = $platformName -split " _"
70+ $platformNameElements = $platformName -split " _"
5971
60- $platformNameElements | Should - HaveCount 6
72+ $platformNameElements | Should - HaveCount 6
73+ }
6174 }
6275}
63-
64- Describe " New-PSCompatibilityProfile" {
65- It " Generates a compatibility profile" {
66- $jsonPath = Join-Path $TestDrive " profile.json"
67- New-PSCompatibilityProfile - OutFile $jsonPath
68- $json = ConvertFrom-PSCompatibilityJson - Path $jsonPath
69- Assert-PSCompatibilityProfileIsValid $json
70- $? | Should - BeTrue
71- }
72- }
0 commit comments