Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,26 @@ public SwitchParameter Sum
}
private bool _measureSum;

/// <summary>
/// Gets or sets the value indicating if all statistics should be returned.
/// </summary>
/// <value></value>
[Parameter(ParameterSetName = GenericParameterSet)]
public SwitchParameter AllStats
{
get
{
return _allStats;
}

set
{
_allStats = value;
}
}

private bool _allStats;

/// <summary>
/// Set to true is Average is to be returned
/// </summary>
Expand Down Expand Up @@ -451,6 +471,21 @@ private bool IsMeasuringGeneric
}
}

/// <summary>
/// Does the begin part of the cmdlet.
/// </summary>
protected override void BeginProcessing()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, you should call the base class implementation, base.BeginProcessing(), here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

{
// Sets all other generic parameters to true to get all statistics.
if (_allStats)
{
_measureSum = _measureStandardDeviation = _measureAverage = _measureMax = _measureMin = true;
}

// finally call the base class.
base.BeginProcessing();
}

/// <summary>
/// Collect data about each record that comes in.
/// Side effects: Updates totalRecordCount.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,16 @@ Describe "Measure-Object" -Tags "CI" {

$actual.Maximum | Should -Be $expected
}

It "Should be able to return all the statitics for given values" {
$result = 1..10 | Measure-Object -AllStats
$result.Count | Should -Be 10
$result.Average | Should -Be 5.5
$result.Sum | Should -Be 55
$result.Minimum | Should -Be 1
$result.Maximum | Should -Be 10
($result.StandardDeviation).ToString() | Should -Be '3.02765035409749'
}
}

Context "String tests" {
Expand Down