Fix logic to not rely on build number to determine whether to output formatdata (#8063)

This commit is contained in:
Steve Lee 2018-10-20 03:45:03 +08:00 committed by Aditya Patwardhan
parent 0bce3e0e0d
commit 3ceb1c17ef
2 changed files with 13 additions and 1 deletions

View file

@ -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;

View file

@ -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
}
}