-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Only display properties with values for MeasureInfo #7104
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
iSazonov
merged 10 commits into
PowerShell:master
from
powercode:formatting_ItemSelectionConditions
Aug 28, 2018
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
8131fa1
Adding support for built-in List formats to include ItemSelectionCond…
7906048
Adding ItemSelectionCondition to GenericMeasureInfo
bee583e
Adding tests for MeasureInfo format-list
powercode 356faf9
Addressing review comments
powercode f069ac4
fixing casing of Sum
powercode 2bb06fe
Adding positive tests
powercode 42b4a68
Fixing typo
powercode f6ffe1a
Code factor fixes.
powercode f6d6633
Yet another code factor.
powercode b424329
Adding missing testcase for Sum.
powercode File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,9 +8,9 @@ Describe "Object cmdlets" -Tags "CI" { | |
| } | ||
|
|
||
| It "AsString returns a string" { | ||
| $processes = Get-Process | Group-Object -Property ProcessName -AsHashTable -AsString | ||
| $result = $processes.Keys | ForEach-Object {$_.GetType()} | ||
| $result[0].Name | Should -Be "String" | ||
| $processes = Get-Process | Group-Object -Property ProcessName -AsHashTable -AsString | ||
| $result = $processes.Keys | ForEach-Object {$_.GetType()} | ||
| $result[0].Name | Should -Be "String" | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -45,18 +45,18 @@ Describe "Object cmdlets" -Tags "CI" { | |
| $secondObject | Add-Member -NotePropertyName Header -NotePropertyValue $secondValue | ||
|
|
||
| $testCases = @( | ||
| @{ data = @("abc","ABC","Def"); min = "abc"; max = "Def"}, | ||
| @{ data = @("abc", "ABC", "Def"); min = "abc"; max = "Def"}, | ||
| @{ data = @([datetime]::Today, [datetime]::Today.AddDays(-1)); min = ([datetime]::Today.AddDays(-1)).ToString() ; max = [datetime]::Today.ToString() } | ||
| @{ data = @(1,2,3,"ABC"); min = 1; max = "ABC"}, | ||
| @{ data = @(4,2,3,"ABC",1); min = 1; max = "ABC"}, | ||
| @{ data = @(4,2,3,"ABC",1,"DEF"); min = 1; max = "DEF"}, | ||
| @{ data = @("111 Test","19"); min = "111 Test"; max = "19"}, | ||
| @{ data = @(1, 2, 3, "ABC"); min = 1; max = "ABC"}, | ||
| @{ data = @(4, 2, 3, "ABC", 1); min = 1; max = "ABC"}, | ||
| @{ data = @(4, 2, 3, "ABC", 1, "DEF"); min = 1; max = "DEF"}, | ||
| @{ data = @("111 Test", "19"); min = "111 Test"; max = "19"}, | ||
| @{ data = @("19", "111 Test"); min = "111 Test"; max = "19"}, | ||
| @{ data = @("111 Test",19); min = "111 Test"; max = 19}, | ||
| @{ data = @("111 Test", 19); min = "111 Test"; max = 19}, | ||
| @{ data = @(19, "111 Test"); min = "111 Test"; max = 19}, | ||
| @{ data = @(100,2,3, "A", 1); min = 1; max = "A"}, | ||
| @{ data = @(4,2,3, "ABC", 1, "DEF"); min = 1; max = "DEF"}, | ||
| @{ data = @("abc",[Datetime]::Today,"def"); min = [Datetime]::Today.ToString(); max = "def"} | ||
| @{ data = @(100, 2, 3, "A", 1); min = 1; max = "A"}, | ||
| @{ data = @(4, 2, 3, "ABC", 1, "DEF"); min = 1; max = "DEF"}, | ||
| @{ data = @("abc", [Datetime]::Today, "def"); min = [Datetime]::Today.ToString(); max = "def"} | ||
| ) | ||
| } | ||
|
|
||
|
|
@@ -85,18 +85,31 @@ Describe "Object cmdlets" -Tags "CI" { | |
| } | ||
|
|
||
| It 'returns a GenericMeasureInfoObject' { | ||
| $gmi = 1,2,3 | measure-object -max -min | ||
| $gmi = 1, 2, 3 | measure-object -max -min | ||
| $gmi | Should -BeOfType Microsoft.PowerShell.Commands.GenericMeasureInfo | ||
| } | ||
|
|
||
| It 'should return correct error for non-numeric input' { | ||
| $gmi = "abc",[Datetime]::Now | measure -sum -max -ErrorVariable err -ErrorAction silentlycontinue | ||
| $gmi = "abc", [Datetime]::Now | measure -sum -max -ErrorVariable err -ErrorAction silentlycontinue | ||
| $err | ForEach-Object { $_.FullyQualifiedErrorId | Should -Be 'NonNumericInputObject,Microsoft.PowerShell.Commands.MeasureObjectCommand' } | ||
| } | ||
|
|
||
| It 'should have the correct count' { | ||
| $gmi = "abc",[Datetime]::Now | measure -sum -max -ErrorVariable err -ErrorAction silentlycontinue | ||
| $gmi = "abc", [Datetime]::Now | measure -sum -max -ErrorVariable err -ErrorAction silentlycontinue | ||
| $gmi.Count | Should -Be 2 | ||
| } | ||
|
|
||
| It 'should only display fields that are set' { | ||
| $text = 1, 2, 3 | Measure-Object -Sum -Average | Format-List | Out-String | ||
| $text -match "min|max" | Should -BeFalse | ||
| $text -match 'Sum' | Should -BeTrue | ||
| $text -match 'Average' | Should -BeTrue | ||
|
|
||
| $text = 1, 2, 3 | Measure-Object -Minimum -Maximum | Format-List | Out-String | ||
| $text -match "min" | Should -BeTrue | ||
| $text -match "max" | Should -BeTrue | ||
| $text -match 'Average' | Should -BeFalse | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Seems we skipped $text -match 'Sum' | Should -BeFalse
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @powercode Please address the comment. |
||
| $text -match 'Sum' | Should -BeFalse | ||
| } | ||
| } | ||
| } | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@PaulHigin should review this new public api for any security implications in creating script blocks that might circumvent the language mode.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@PaulHigin reviewed this and told me he doesn't see a security issue. @PaulHigin can you confirm?