mirror of
https://github.com/PowerShell/PowerShell
synced 2026-06-08 12:12:50 +00:00
Fix logic to not rely on build number to determine whether to output formatdata (#8063)
This commit is contained in:
committed by
Aditya Patwardhan
parent
0bce3e0e0d
commit
3ceb1c17ef
+1
-1
@@ -97,7 +97,7 @@ namespace Microsoft.PowerShell.Commands
|
||||
{
|
||||
bool writeOldWay = PowerShellVersion == null ||
|
||||
PowerShellVersion.Major < 5 ||
|
||||
PowerShellVersion.Build < 11086;
|
||||
(PowerShellVersion.Major == 5 && PowerShellVersion.Minor < 1);
|
||||
|
||||
TypeInfoDataBase db = this.Context.FormatDBManager.Database;
|
||||
|
||||
|
||||
@@ -9,4 +9,16 @@ Describe "Get-FormatData" -Tags "CI" {
|
||||
,$result | Should -BeOfType "System.Object[]"
|
||||
}
|
||||
}
|
||||
|
||||
It "Can get format data requiring '-PowerShellVersion 5.1'" {
|
||||
$format = Get-FormatData System.IO.FileInfo -PowerShellVersion 5.1
|
||||
$format.TypeNames | Should -HaveCount 2
|
||||
$format.TypeNames[0] | Should -BeExactly "System.IO.DirectoryInfo"
|
||||
$format.TypeNames[1] | Should -BeExactly "System.IO.FileInfo"
|
||||
$format.FormatViewDefinition | Should -HaveCount 3
|
||||
}
|
||||
|
||||
It "Should return nothing for format data requiring '-PowerShellVersion 5.1' and not provided" {
|
||||
Get-FormatData System.IO.FileInfo | Should -BeNullOrEmpty
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user