From 2f5150f5e5fdce74e22b8697329c5e5d63287f0d Mon Sep 17 00:00:00 2001 From: Robert Holt Date: Mon, 9 Aug 2021 15:27:09 -0700 Subject: [PATCH] Make Measure-Object property test independent of the filesystem (#15879) --- .../Measure-Object.Tests.ps1 | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/test/powershell/Modules/Microsoft.PowerShell.Utility/Measure-Object.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Utility/Measure-Object.Tests.ps1 index ea96741de3..b1cf1b36d3 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Utility/Measure-Object.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Utility/Measure-Object.Tests.ps1 @@ -64,10 +64,13 @@ Describe "Measure-Object" -Tags "CI" { } It "Should be able to count using the Property switch" { - $expected = $(Get-ChildItem $TestDrive).Length - $actual = $(Get-ChildItem $TestDrive | Measure-Object -Property Length).Count + $items = @( + [pscustomobject]@{ X = 'a'; Y = 'b' } + [pscustomobject]@{ X = 'c' } + [pscustomobject]@{ X = 'e'; Y = 'f' } + ) - $actual | Should -Be $expected + ($items | Measure-Object -Property Y).Count | Should -Be 2 } It "Should be able to use wildcards for the Property argument" {