Length script property for List View didn't include a name for the property so it defaulted to using the script as the property name (#4437)

This commit is contained in:
Steve Lee authored and Dongbo Wang committed 2017-07-31 12:56:41 -07:00
1 parent baa56f9c71
commit ab764eeac1
2 files changed
+9 -2

No files matched your search

@@ -74,7 +74,7 @@ return $_.Length";
.GroupByProperty("PSParentPath", customControl: sharedControls[0])
.StartEntry(entrySelectedByType: new[] { "System.IO.FileInfo" })
.AddItemProperty(@"Name")
.AddItemScriptBlock(LengthScriptBlock)
.AddItemScriptBlock(LengthScriptBlock, label: "Length")
.AddItemProperty(@"CreationTime")
.AddItemProperty(@"LastWriteTime")
.AddItemProperty(@"LastAccessTime")
@@ -149,5 +149,12 @@ Describe "Format-List DRT basic functionality" -Tags "CI" {
$result | Should Match "Length : 2"
$result | Should Match "Name : name3"
$result | Should Match "Length : 3"
}
}
It "Format-List with FileInfo should work" {
$null = New-Item $testdrive\test.txt -ItemType File -Value "hello" -Force
$result = Get-ChildItem -File $testdrive\test.txt | Format-List | Out-String
$result | Should Match "Name\s*:\s*test.txt"
$result | Should Match "Length\s*:\s*5"
}
}