Repository: PowerShell/PowerShell
File: test/powershell/Modules/Microsoft.PowerShell.Utility/Group-Object.Tests.ps1 (PowerShell)

Code before:
    }

    It "User's scenario should work (see issue #6933 for link to stackoverflow question)" {
        # Sort numbers into two groups even succeeded, odd failed.
        $result = 1..9 | ForEach-Object {[PSCustomObject]@{ErrorMessage = if ($_ % 2) {'SomeError'} else {''}}} |
            Group-Object -Property {if ($_.ErrorMessage) {'Failed'} else {'Successful'}} -AsHashTable

        $result['Failed'].ErrorMessage.Count | Should -Be 5
        $result['Failed'].ErrorMessage[0] | Should -Be 'SomeError'
        $result['Successful'].ErrorMessage.Count | Should -Be 4
        $result['Successful'].ErrorMessage[0] | Should -Be ''
    }

    It "Should understand empty NoteProperty" {
        $result = "dummy" | Select-Object -Property @{Name = 'X'; Expression = {}} | Group-Object X
        $result.Count | Should -Be 1
        $result[0].Name | Should -Be ""
        $result[0].Group | Should -Be '@{X=}'
    }

    It "Should handle format-like strings with curly braces like normal strings" {
        $result = '{', '}', '{0}' | Group-Object
        $result.Count | Should -Be 3
        $result[0].Name | Should -Be '{'
        $result[1].Name | Should -Be '{0}'
        $result[2].Name | Should -Be '}'
    }
}

Describe "Check 'Culture' parameter in order object cmdlets (Group-Object, Sort-Object, Compare-Object)" -Tags "CI" {

    BeforeAll {

        $testObject = Get-ChildItem

    }

    It "Should accept a culture by name" {

        if ( (Get-Culture).Name -eq "ru-Ru" ) {
            $testCulture = "ru-UA"
        }
        else {
            $testCulture = "ru-RU"
        }

        {$testObject | Group-Object -Culture $testCulture } | Should -Not -Throw
    }

    It "Should accept a culture by hex string LCID" {


Review comment (suggestion):
```suggestion
        $result[0].Name | Should -BeExactly '{'
        $result[1].Name | Should -BeExactly '{0}'
        $result[2].Name | Should -BeExactly '}'
```

Code after:
    }

    It "User's scenario should work (see issue #6933 for link to stackoverflow question)" {
        # Sort numbers into two groups even succeeded, odd failed.
        $result = 1..9 | ForEach-Object {[PSCustomObject]@{ErrorMessage = if ($_ % 2) {'SomeError'} else {''}}} |
            Group-Object -Property {if ($_.ErrorMessage) {'Failed'} else {'Successful'}} -AsHashTable

        $result['Failed'].ErrorMessage.Count | Should -Be 5
        $result['Failed'].ErrorMessage[0] | Should -Be 'SomeError'
        $result['Successful'].ErrorMessage.Count | Should -Be 4
        $result['Successful'].ErrorMessage[0] | Should -Be ''
    }

    It "Should understand empty NoteProperty" {
        $result = "dummy" | Select-Object -Property @{Name = 'X'; Expression = {}} | Group-Object X
        $result.Count | Should -Be 1
        $result[0].Name | Should -Be ""
        $result[0].Group | Should -Be '@{X=}'
    }

    It "Should handle format-like strings with curly braces like normal strings" {
        $result = '{', '}', '{0}' | Group-Object
        $result.Count | Should -Be 3
        $result[0].Name | Should -BeExactly '{'
        $result[1].Name | Should -BeExactly '{0}'
        $result[2].Name | Should -BeExactly '}'
    }
}

Describe "Check 'Culture' parameter in order object cmdlets (Group-Object, Sort-Object, Compare-Object)" -Tags "CI" {

    BeforeAll {

        $testObject = Get-ChildItem

    }

    It "Should accept a culture by name" {

        if ( (Get-Culture).Name -eq "ru-Ru" ) {
            $testCulture = "ru-UA"
        }
        else {
            $testCulture = "ru-RU"
        }

        {$testObject | Group-Object -Culture $testCulture } | Should -Not -Throw
    }

    It "Should accept a culture by hex string LCID" {