Skip to content

Allow different order in collections #2874

Description

@fflaten

Checklist

Summary of the feature request

Should assertions like Should-ContainCollection have an option to ignore item order? Sometimes the returned order can not be guaranteed, especially in integration tests.

This is especially visible when migrating from Should -BeIn which checked individual items in the expected collection.

'a',2,$null | Should -BeIn 'b',3,2,'a',$null
# pass

'b',3,2,'a',$null | Should-ContainCollection 'a',2,$null
Expected [Object[]] @('a', 2, $null) to be present in [Object[]] @('b', 3, 2, 'a', $null), but it was not there.

'b',3,2,'a',$null | Sort-Object | Should-ContainCollection ('a',2,$null | Sort-Object)
# pass but ugly

How should it work?

-IgnoreOrder parameter?
Or close request and let this issue document the required use of Sort-Object.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions