MegaBites-AI/Windows-powershell
0372
1# Copyright (c) Microsoft Corporation.2# Licensed under the MIT License.3Describe "New-Guid" -Tags "CI" {4 5 It "Returns a new guid" {6 $guid = New-Guid7 $guid | Should -BeOfType System.Guid8 }9 10 It "Should not be all zeros" {11 $guid = New-Guid12 $guid.ToString() | Should -Not -BeExactly "00000000-0000-0000-0000-000000000000"13 }14 15 It "Should be all zeros" {16 $guid = New-Guid -Empty17 $guid.ToString() | Should -BeExactly "00000000-0000-0000-0000-000000000000"18 }19 20 It "Should respect explicit false value for -Empty" {21 $guid = New-Guid -Empty:$false22 $guid.ToString() | Should -Not -BeExactly "00000000-0000-0000-0000-000000000000"23 }24 25 It "Should convert a string to a guid" {26 $guid1 = New-Guid27 $guid2 = New-Guid -InputObject $guid1.ToString()28 $guid3 = New-Guid $guid1.ToString()29 $guid2 | Should -BeOfType System.Guid30 $guid1.ToString() | Should -BeExactly $guid2.ToString()31 $guid1.ToString() | Should -BeExactly $guid3.ToString()32 }33 34 It "Should convert a string to a guid, value from pipeline" {35 $guids = '11c43ee8-b9d3-4e51-b73f-bd9dda66e29c','0f8fad5bd9cb469fa16570867728950e' | New-Guid36 $guids[0].ToString() | Should -BeExactly '11c43ee8-b9d3-4e51-b73f-bd9dda66e29c'37 $guids[1].ToString() | Should -BeExactly '0f8fad5b-d9cb-469f-a165-70867728950e'38 }39 40 It "Should accept pipeline input" {41 $guids = 1..10 | foreach-object { [guid]::newguid() }42 $observed = $guids.Foreach({$_.ToString()}) | New-Guid43 $observed | Should -Be $guids44 }45 46 It "Should return different guids with each call" {47 $guid1 = New-Guid48 $guid2 = New-Guid49 $guid1.ToString() | Should -Not -Be $guid2.ToString()50 }51}52 53 