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 @@ -144,10 +144,11 @@ public int First
private bool _firstOrLastSpecified;

/// <summary>
/// Skips the specified number of items from top when used with First, from end when used with Last.
/// Skips the specified number of items from top when used with First, from end when used with Last or SkipLast.
/// </summary>
/// <value></value>
[Parameter(ParameterSetName = "DefaultParameter")]
[Parameter(ParameterSetName = "SkipLastParameter")]
[ValidateRange(0, int.MaxValue)]
public int Skip { get; set; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,29 @@ Describe "Select-Object DRT basic functionality" -Tags "CI" {
$results[1] | Should -Be 3
}

It "Select-Object with SkipLast should work" {
$results = "1", "2", "3" | Select-Object -SkipLast 1
$results.Count | Should -Be 2
$results[0] | Should -BeExactly "1"
$results[1] | Should -BeExactly "2"
}

It "Select-Object with Skip and SkipLast should work" {
$results = "1", "2", "3" | Select-Object -Skip 1 -SkipLast 1
$results.Count | Should -Be 1
$results[0] | Should -BeExactly "2"
}

It "Select-Object with Skip and SkipLast should work with Skip overlapping SkipLast" {
$results = "1", "2" | Select-Object -Skip 2 -SkipLast 1
$results. Count | Should -Be 0
}

It "Select-Object with Skip and SkipLast should work with skiplast overlapping skip" {
$results = "1", "2" | Select-Object -Skip 1 -SkipLast 2
$results. Count | Should -Be 0
}

It "Select-Object with Index should work" {
$results = "1", "2", "3" | Select-Object -Index 2
$results.Count | Should -Be 1
Expand Down