diff --git a/CHANGELOG.md b/CHANGELOG.md index 6fff08df7..0f08a6163 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -32,6 +32,7 @@ - Deleted the obsolete xActiveDirectory_TechNetDocumentation.html file - Cleanup of code - Removed semicolon throughout where it is not needed. + - Migrate tests to Pester syntax v4.x ([issue #322](https://github.com/PowerShell/xActiveDirectory/issues/322)). - Changes to xADComputer - Refactored the resource and the unit tests. - BREAKING CHANGE: The `Enabled` property is **DEPRECATED** and is no diff --git a/Tests/Unit/MSFT_xADDomain.Tests.ps1 b/Tests/Unit/MSFT_xADDomain.Tests.ps1 index dd7f18ad1..faa9eadb7 100644 --- a/Tests/Unit/MSFT_xADDomain.Tests.ps1 +++ b/Tests/Unit/MSFT_xADDomain.Tests.ps1 @@ -95,7 +95,7 @@ try $result = Get-TargetResource @testDefaultParams -DomainName $correctDomainName - $result -is [System.Collections.Hashtable] | Should Be $true + $result -is [System.Collections.Hashtable] | Should -Be $true } It 'Calls "Get-ADDomain" without credentials if domain member' { @@ -133,7 +133,7 @@ try } ## Match operator is case-sensitive! - { Get-TargetResource @testDefaultParams -DomainName $incorrectDomainName } | Should Throw 'invalid credentials' + { Get-TargetResource @testDefaultParams -DomainName $incorrectDomainName } | Should -Throw 'invalid credentials' } It 'Throws "Computer is already a domain member" when is already a domain member' { @@ -141,7 +141,7 @@ try Write-Error -Exception (New-Object Microsoft.ActiveDirectory.Management.ADIdentityNotFoundException) } - { Get-TargetResource @testDefaultParams -DomainName $incorrectDomainName } | Should Throw 'Computer is already a domain member' + { Get-TargetResource @testDefaultParams -DomainName $incorrectDomainName } | Should -Throw 'Computer is already a domain member' } It 'Does not throw when domain cannot be located' { @@ -149,7 +149,7 @@ try Write-Error -Exception (New-Object Microsoft.ActiveDirectory.Management.ADServerDownException) } - { Get-TargetResource @testDefaultParams -DomainName $missingDomainName } | Should Not Throw + { Get-TargetResource @testDefaultParams -DomainName $missingDomainName } | Should -Not -Throw } It 'Returns the correct domain mode' { @@ -161,7 +161,7 @@ try } Mock -CommandName Get-ADForest -MockWith { [psobject]@{ForestMode = $mgmtForestMode} } - (Get-TargetResource @testDefaultParams -DomainName $correctDomainName).DomainMode | Should Be $domainMode + (Get-TargetResource @testDefaultParams -DomainName $correctDomainName).DomainMode | Should -Be $domainMode } It 'Returns the correct forest mode' { @@ -173,7 +173,7 @@ try } Mock -CommandName Get-ADForest -MockWith { [psobject]@{ForestMode = $mgmtForestMode} } - (Get-TargetResource @testDefaultParams -DomainName $correctDomainName).ForestMode | Should Be $forestMode + (Get-TargetResource @testDefaultParams -DomainName $correctDomainName).ForestMode | Should -Be $forestMode } } #endregion @@ -209,7 +209,7 @@ try $result = Test-TargetResource @testDefaultParams -DomainName $correctDomainName - $result | Should Be $true + $result | Should -Be $true } It 'Returns "False" when "DomainName" does not match' { @@ -217,7 +217,7 @@ try $result = Test-TargetResource @testDefaultParams -DomainName $incorrectDomainName - $result | Should Be $false + $result | Should -Be $false } It 'Returns "True" when "DomainNetBIOSName" matches' { @@ -225,7 +225,7 @@ try $result = Test-TargetResource @testDefaultParams -DomainName $correctDomainName -DomainNetBIOSName $correctDomainNetBIOSName - $result | Should Be $true + $result | Should -Be $true } It 'Returns "False" when "DomainNetBIOSName" does not match' { @@ -233,7 +233,7 @@ try $result = Test-TargetResource @testDefaultParams -DomainName $correctDomainName -DomainNetBIOSName 'INCORRECT' - $result | Should Be $false + $result | Should -Be $false } It 'Returns "True" when "ParentDomainName" matches' { @@ -241,7 +241,7 @@ try $result = Test-TargetResource @testDefaultParams -DomainName $correctChildDomainName -ParentDomainName $parentDomainName - $result | Should Be $true + $result | Should -Be $true } It 'Returns "False" when "ParentDomainName" does not match' { @@ -249,7 +249,7 @@ try $result = Test-TargetResource @testDefaultParams -DomainName $correctChildDomainName -ParentDomainName 'incorrect.com' - $result | Should Be $false + $result | Should -Be $false } } diff --git a/Tests/Unit/MSFT_xADDomainDefaultPasswordPolicy.Tests.ps1 b/Tests/Unit/MSFT_xADDomainDefaultPasswordPolicy.Tests.ps1 index b55ace962..e81d31ffc 100644 --- a/Tests/Unit/MSFT_xADDomainDefaultPasswordPolicy.Tests.ps1 +++ b/Tests/Unit/MSFT_xADDomainDefaultPasswordPolicy.Tests.ps1 @@ -76,7 +76,7 @@ try $result = Get-TargetResource @testDefaultParams - $result -is [System.Collections.Hashtable] | Should Be $true + $result -is [System.Collections.Hashtable] | Should -Be $true } It 'Calls "Get-ADDefaultDomainPasswordPolicy" without credentials by default' { @@ -141,7 +141,7 @@ try $result = Test-TargetResource @testDefaultParams - $result -is [System.Boolean] | Should Be $true + $result -is [System.Boolean] | Should -Be $true } It 'Calls "Get-TargetResource" with "Credential" parameter when specified' { @@ -169,7 +169,7 @@ try $result = Test-TargetResource @propertyDefaultParams - $result | Should Be $true + $result | Should -Be $true } It "Fails when '$propertyName' parameter does not match resource property value" { @@ -191,7 +191,7 @@ try $result = Test-TargetResource @propertyDefaultParams - $result | Should Be $false + $result | Should -Be $false } } #end foreach property diff --git a/Tests/Unit/MSFT_xADGroup.Tests.ps1 b/Tests/Unit/MSFT_xADGroup.Tests.ps1 index 64322d7b3..4abb71a3d 100644 --- a/Tests/Unit/MSFT_xADGroup.Tests.ps1 +++ b/Tests/Unit/MSFT_xADGroup.Tests.ps1 @@ -113,13 +113,13 @@ try Mock -CommandName Get-ADGroup { return $fakeADGroup; } Mock -CommandName Get-ADGroupMember { return @($fakeADUser1, $fakeADUser2); } - (Get-TargetResource @testPresentParams).Ensure | Should Be 'Present' + (Get-TargetResource @testPresentParams).Ensure | Should -Be 'Present' } It "Returns 'Ensure' is 'Absent' when group does not exist" { Mock -CommandName Get-ADGroup { throw New-Object Microsoft.ActiveDirectory.Management.ADIdentityNotFoundException } - (Get-TargetResource @testPresentParams).Ensure | Should Be 'Absent' + (Get-TargetResource @testPresentParams).Ensure | Should -Be 'Absent' } @@ -174,7 +174,7 @@ try $targetResource = Test-TargetResource @testPresentParams -Members $fakeADUser1.$attribute, $fakeADUser2.$attribute -MembershipAttribute $attribute - $targetResource | Should Be $true + $targetResource | Should -Be $true } It "Fails when group membership counts do not match using '$attribute'" { @@ -183,7 +183,7 @@ try $targetResource = Test-TargetResource @testPresentParams -Members $fakeADUser2.$attribute, $fakeADUser3.$attribute -MembershipAttribute $attribute - $targetResource | Should Be $false + $targetResource | Should -Be $false } It "Fails when group 'Members' do not match using '$attribute'" { @@ -192,7 +192,7 @@ try $targetResource = Test-TargetResource @testPresentParams -Members $fakeADUser2.$attribute, $fakeADUser3.$attribute -MembershipAttribute $attribute - $targetResource | Should Be $false + $targetResource | Should -Be $false } It "Passes when specified 'MembersToInclude' match using '$attribute'" { @@ -201,7 +201,7 @@ try $targetResource = Test-TargetResource @testPresentParams -MembersToInclude $fakeADUser2.$attribute -MembershipAttribute $attribute - $targetResource | Should Be $true + $targetResource | Should -Be $true } It "Fails when specified 'MembersToInclude' are missing using '$attribute'" { @@ -210,7 +210,7 @@ try $targetResource = Test-TargetResource @testPresentParams -MembersToInclude $fakeADUser3.$attribute -MembershipAttribute $attribute - $targetResource | Should Be $false + $targetResource | Should -Be $false } It "Passes when specified 'MembersToExclude' are missing using '$attribute'" { @@ -219,7 +219,7 @@ try $targetResource = Test-TargetResource @testPresentParams -MembersToExclude $fakeADUser3.$attribute -MembershipAttribute $attribute - $targetResource | Should Be $true + $targetResource | Should -Be $true } It "Fails when when specified 'MembersToExclude' match using '$attribute'" { @@ -228,7 +228,7 @@ try $targetResource = Test-TargetResource @testPresentParams -MembersToExclude $fakeADUser2.$attribute -MembershipAttribute $attribute - $targetResource | Should Be $false + $targetResource | Should -Be $false } } #end foreach attribute @@ -236,7 +236,7 @@ try It "Fails when group does not exist and 'Ensure' is 'Present'" { Mock -CommandName Get-TargetResource -MockWith { return $testAbsentParams } - Test-TargetResource @testPresentParams | Should Be $false + Test-TargetResource @testPresentParams | Should -Be $false } It "Fails when group exists, 'Ensure' is 'Present' but 'Scope' is wrong" { @@ -246,7 +246,7 @@ try return $duffADGroup } - Test-TargetResource @testPresentParams | Should Be $false + Test-TargetResource @testPresentParams | Should -Be $false } It "Fails when group exists, 'Ensure' is 'Present' but 'Category' is wrong" { @@ -256,7 +256,7 @@ try return $duffADGroup } - Test-TargetResource @testPresentParams | Should Be $false + Test-TargetResource @testPresentParams | Should -Be $false } It "Fails when group exists, 'Ensure' is 'Present' but 'Path' is wrong" { @@ -266,7 +266,7 @@ try return $duffADGroup } - Test-TargetResource @testPresentParams | Should Be $false + Test-TargetResource @testPresentParams | Should -Be $false } It "Fails when group exists, 'Ensure' is 'Present' but 'Description' is wrong" { @@ -276,7 +276,7 @@ try return $duffADGroup } - Test-TargetResource @testPresentParams | Should Be $false + Test-TargetResource @testPresentParams | Should -Be $false } It "Fails when group exists, 'Ensure' is 'Present' but 'DisplayName' is wrong" { @@ -286,7 +286,7 @@ try return $duffADGroup } - Test-TargetResource @testPresentParams | Should Be $false + Test-TargetResource @testPresentParams | Should -Be $false } It "Fails when group exists, 'Ensure' is 'Present' but 'ManagedBy' is wrong" { @@ -296,7 +296,7 @@ try return $duffADGroup } - Test-TargetResource @testPresentParams | Should Be $false + Test-TargetResource @testPresentParams | Should -Be $false } It "Fails when group exists, 'Ensure' is 'Present' but 'Notes' is wrong" { @@ -306,25 +306,25 @@ try return $duffADGroup } - Test-TargetResource @testPresentParams | Should Be $false + Test-TargetResource @testPresentParams | Should -Be $false } It "Fails when group exists and 'Ensure' is 'Absent'" { Mock -CommandName Get-TargetResource -MockWith { return $testPresentParams } - Test-TargetResource @testAbsentParams | Should Be $false + Test-TargetResource @testAbsentParams | Should -Be $false } It "Passes when group exists, target matches and 'Ensure' is 'Present'" { Mock -CommandName Get-TargetResource -MockWith { return $testPresentParams } - Test-TargetResource @testPresentParams | Should Be $true + Test-TargetResource @testPresentParams | Should -Be $true } It "Passes when group does not exist and 'Ensure' is 'Absent'" { Mock -CommandName Get-TargetResource -MockWith { return $testAbsentParams } - Test-TargetResource @testAbsentParams | Should Be $true + Test-TargetResource @testAbsentParams | Should -Be $true } } @@ -629,7 +629,7 @@ try Mock -CommandName Add-ADCommonGroupMember $universalGroupInCompliance = Test-TargetResource -GroupName $testUniversalPresentParams.GroupName -DisplayName $testUniversalPresentParams.DisplayName - $universalGroupInCompliance | Should Be $true + $universalGroupInCompliance | Should -Be $true } # tests for issue 183 @@ -644,7 +644,7 @@ try Mock -CommandName Add-ADCommonGroupMember $universalGroupInCompliance = Test-TargetResource -GroupName $testUniversalPresentParams.GroupName -DisplayName $testUniversalPresentParams.DisplayName - $universalGroupInCompliance | Should Be $true + $universalGroupInCompliance | Should -Be $true } It "Calls Restore-AdCommonObject when RestoreFromRecycleBin is used" { diff --git a/Tests/Unit/MSFT_xADKDSKey.Tests.ps1 b/Tests/Unit/MSFT_xADKDSKey.Tests.ps1 index 16edf0c86..aa48aa8ab 100644 --- a/Tests/Unit/MSFT_xADKDSKey.Tests.ps1 +++ b/Tests/Unit/MSFT_xADKDSKey.Tests.ps1 @@ -404,7 +404,7 @@ try $getTargetResourceResult = Get-TargetResource @getTargetResourceParametersFuture - $getTargetResourceResult.Ensure | Should Be 'Absent' + $getTargetResourceResult.Ensure | Should -Be 'Absent' Assert-MockCalled -CommandName Assert-HasDomainAdminRights -Scope It -Exactly -Times 1 Assert-MockCalled -CommandName Get-KdsRootKey -Scope It -Exactly -Times 1 @@ -422,7 +422,7 @@ try } $getTargetResourceResult = Get-TargetResource @getTargetResourceParametersFuture - $getTargetResourceResult.Ensure | Should Be 'Absent' + $getTargetResourceResult.Ensure | Should -Be 'Absent' Assert-MockCalled -CommandName Assert-HasDomainAdminRights -Scope It -Exactly -Times 1 Assert-MockCalled -CommandName Get-KdsRootKey -Scope It -Exactly -Times 1 @@ -606,7 +606,7 @@ try } $testTargetResourceParametersFuture[$Parameter] = $value - Test-TargetResource @testTargetResourceParametersFuture | Should Be $false + Test-TargetResource @testTargetResourceParametersFuture | Should -Be $false Assert-MockCalled -CommandName Compare-TargetResourceState -ParameterFilter { $mockKDSRootKeyFuture.EffectiveTime -eq $EffectiveTime diff --git a/Tests/Unit/MSFT_xADManagedServiceAccount.Tests.ps1 b/Tests/Unit/MSFT_xADManagedServiceAccount.Tests.ps1 index ffe98a7f2..ed31b6b1e 100644 --- a/Tests/Unit/MSFT_xADManagedServiceAccount.Tests.ps1 +++ b/Tests/Unit/MSFT_xADManagedServiceAccount.Tests.ps1 @@ -442,7 +442,7 @@ try $getTargetResourceResult = Get-TargetResource @testResourceParametersSingle It "Should return 'Ensure' is 'Absent'" { - $getTargetResourceResult.Ensure | Should Be 'Absent' + $getTargetResourceResult.Ensure | Should -Be 'Absent' } It "Should return 'ServiceAccountName' when 'Absent'" { @@ -886,7 +886,7 @@ try DisplayName = '' } - Test-TargetResource @testResourceParametersGroup | Should Be $true + Test-TargetResource @testResourceParametersGroup | Should -Be $true } } @@ -960,7 +960,7 @@ try } $testResourceParametersSingle[$Parameter] = $value - Test-TargetResource @testResourceParametersSingle | Should Be $false + Test-TargetResource @testResourceParametersSingle | Should -Be $false } } @@ -1014,7 +1014,7 @@ try } $testResourceParametersGroup[$Parameter] = $value - Test-TargetResource @testResourceParametersGroup | Should Be $false + Test-TargetResource @testResourceParametersGroup | Should -Be $false } } } diff --git a/Tests/Unit/MSFT_xADObjectPermissionEntry.Tests.ps1 b/Tests/Unit/MSFT_xADObjectPermissionEntry.Tests.ps1 index 63b313065..7c1cad7c2 100644 --- a/Tests/Unit/MSFT_xADObjectPermissionEntry.Tests.ps1 +++ b/Tests/Unit/MSFT_xADObjectPermissionEntry.Tests.ps1 @@ -110,7 +110,7 @@ try $targetResource = Get-TargetResource @testDefaultParameters -Verbose # Assert - $targetResource | Should BeOfType [System.Collections.Hashtable] + $targetResource | Should -BeOfType [System.Collections.Hashtable] } It 'Should return a valid result if the ace is present' { @@ -118,14 +118,14 @@ try $targetResource = Get-TargetResource @testDefaultParameters -Verbose # Assert - $targetResource.Ensure | Should Be 'Present' - $targetResource.Path | Should Be $testDefaultParameters.Path - $targetResource.IdentityReference | Should Be $testDefaultParameters.IdentityReference - $targetResource.ActiveDirectoryRights | Should Be 'GenericAll' - $targetResource.AccessControlType | Should Be $testDefaultParameters.AccessControlType - $targetResource.ObjectType | Should Be $testDefaultParameters.ObjectType - $targetResource.ActiveDirectorySecurityInheritance | Should Be $testDefaultParameters.ActiveDirectorySecurityInheritance - $targetResource.InheritedObjectType | Should Be $testDefaultParameters.InheritedObjectType + $targetResource.Ensure | Should -Be 'Present' + $targetResource.Path | Should -Be $testDefaultParameters.Path + $targetResource.IdentityReference | Should -Be $testDefaultParameters.IdentityReference + $targetResource.ActiveDirectoryRights | Should -Be 'GenericAll' + $targetResource.AccessControlType | Should -Be $testDefaultParameters.AccessControlType + $targetResource.ObjectType | Should -Be $testDefaultParameters.ObjectType + $targetResource.ActiveDirectorySecurityInheritance | Should -Be $testDefaultParameters.ActiveDirectorySecurityInheritance + $targetResource.InheritedObjectType | Should -Be $testDefaultParameters.InheritedObjectType } } @@ -143,14 +143,14 @@ try $targetResource = Get-TargetResource @testDefaultParameters -Verbose # Assert - $targetResource.Ensure | Should Be 'Absent' - $targetResource.Path | Should Be $testDefaultParameters.Path - $targetResource.IdentityReference | Should Be $testDefaultParameters.IdentityReference - $targetResource.ActiveDirectoryRights | Should Be '' - $targetResource.AccessControlType | Should Be $testDefaultParameters.AccessControlType - $targetResource.ObjectType | Should Be $testDefaultParameters.ObjectType - $targetResource.ActiveDirectorySecurityInheritance | Should Be $testDefaultParameters.ActiveDirectorySecurityInheritance - $targetResource.InheritedObjectType | Should Be $testDefaultParameters.InheritedObjectType + $targetResource.Ensure | Should -Be 'Absent' + $targetResource.Path | Should -Be $testDefaultParameters.Path + $targetResource.IdentityReference | Should -Be $testDefaultParameters.IdentityReference + $targetResource.ActiveDirectoryRights | Should -Be '' + $targetResource.AccessControlType | Should -Be $testDefaultParameters.AccessControlType + $targetResource.ObjectType | Should -Be $testDefaultParameters.ObjectType + $targetResource.ActiveDirectorySecurityInheritance | Should -Be $testDefaultParameters.ActiveDirectorySecurityInheritance + $targetResource.InheritedObjectType | Should -Be $testDefaultParameters.InheritedObjectType } } } @@ -169,7 +169,7 @@ try $targetResource = Test-TargetResource @testDefaultParameters @testPresentParameters # Assert - $targetResource | Should BeOfType [System.Boolean] + $targetResource | Should -BeOfType [System.Boolean] } It 'Should return $true if the ace desired state is present' { @@ -177,7 +177,7 @@ try $targetResource = Test-TargetResource @testDefaultParameters @testPresentParameters -Verbose # Assert - $targetResource | Should Be $true + $targetResource | Should -Be $true } It 'Should return $false if the ace desired state is absent' { @@ -185,7 +185,7 @@ try $targetResource = Test-TargetResource @testDefaultParameters @testAbsentParameters # Assert - $targetResource | Should Be $false + $targetResource | Should -Be $false } } @@ -198,7 +198,7 @@ try $targetResource = Test-TargetResource @testDefaultParameters @testPresentParameters # Assert - $targetResource | Should Be $false + $targetResource | Should -Be $false } It 'Should return $true if the ace desired state is absent' { @@ -206,7 +206,7 @@ try $targetResource = Test-TargetResource @testDefaultParameters @testAbsentParameters # Assert - $targetResource | Should Be $true + $targetResource | Should -Be $true } } } diff --git a/Tests/Unit/MSFT_xADOrganizationalUnit.Tests.ps1 b/Tests/Unit/MSFT_xADOrganizationalUnit.Tests.ps1 index 0e97af33f..34f78237b 100644 --- a/Tests/Unit/MSFT_xADOrganizationalUnit.Tests.ps1 +++ b/Tests/Unit/MSFT_xADOrganizationalUnit.Tests.ps1 @@ -69,7 +69,7 @@ try Mock -CommandName Get-ADOrganizationalUnit -MockWith { return [PSCustomObject] $protectedFakeAdOu } $targetResource = Get-TargetResource -Name $testPresentParams.Name -Path $testPresentParams.Path - $targetResource -is [System.Collections.Hashtable] | Should Be $true + $targetResource -is [System.Collections.Hashtable] | Should -Be $true } It 'Returns "Ensure" = "Present" when OU exists' { @@ -77,7 +77,7 @@ try Mock -CommandName Get-ADOrganizationalUnit -MockWith { return [PSCustomObject] $protectedFakeAdOu } $targetResource = Get-TargetResource -Name $testPresentParams.Name -Path $testPresentParams.Path - $targetResource.Ensure | Should Be 'Present' + $targetResource.Ensure | Should -Be 'Present' } It 'Returns "Ensure" = "Absent" when OU does not exist' { @@ -85,7 +85,7 @@ try Mock -CommandName Get-ADOrganizationalUnit $targetResource = Get-TargetResource -Name $testPresentParams.Name -Path $testPresentParams.Path - $targetResource.Ensure | Should Be 'Absent' + $targetResource.Ensure | Should -Be 'Absent' } It 'Returns "ProtectedFromAccidentalDeletion" = "$true" when OU is protected' { @@ -93,7 +93,7 @@ try Mock -CommandName Get-ADOrganizationalUnit -MockWith { return [PSCustomObject] $protectedFakeAdOu } $targetResource = Get-TargetResource -Name $testPresentParams.Name -Path $testPresentParams.Path - $targetResource.ProtectedFromAccidentalDeletion | Should Be $true + $targetResource.ProtectedFromAccidentalDeletion | Should -Be $true } It 'Returns "ProtectedFromAccidentalDeletion" = "$false" when OU is not protected' { @@ -105,7 +105,7 @@ try } $targetResource = Get-TargetResource -Name $testPresentParams.Name -Path $testPresentParams.Path - $targetResource.ProtectedFromAccidentalDeletion | Should Be $false + $targetResource.ProtectedFromAccidentalDeletion | Should -Be $false } It 'Returns an empty description' { @@ -118,7 +118,7 @@ try $targetResource = Get-TargetResource -Name $testPresentParams.Name -Path $testPresentParams.Path - $targetResource.Description | Should BeNullOrEmpty + $targetResource.Description | Should -BeNullOrEmpty } } @@ -131,21 +131,21 @@ try Mock -CommandName Get-ADOrganizationalUnit -MockWith { return [PSCustomObject] $protectedFakeAdOu } $targetResource = Test-TargetResource @testPresentParams - $targetResource -is [System.Boolean] | Should Be $true + $targetResource -is [System.Boolean] | Should -Be $true } It 'Fails when OU does not exist and "Ensure" = "Present"' { Mock -CommandName Assert-Module Mock -CommandName Get-ADOrganizationalUnit - Test-TargetResource @testPresentParams | Should Be $false + Test-TargetResource @testPresentParams | Should -Be $false } It 'Fails when OU does exist and "Ensure" = "Absent"' { Mock -CommandName Assert-Module Mock -CommandName Get-ADOrganizationalUnit -MockWith { return [PSCustomObject] $protectedFakeAdOu } - Test-TargetResource @testAbsentParams | Should Be $false + Test-TargetResource @testAbsentParams | Should -Be $false } It 'Fails when OU does exist but "Description" is incorrect' { @@ -154,7 +154,7 @@ try $testDescriptionParams = $testPresentParams.Clone() $testDescriptionParams['Description'] = 'Wrong description' - Test-TargetResource @testDescriptionParams | Should Be $false + Test-TargetResource @testDescriptionParams | Should -Be $false } It 'Fails when OU does exist but "ProtectedFromAccidentalDeletion" is incorrect' { @@ -163,21 +163,21 @@ try $testProtectedFromAccidentalDeletionParams = $testPresentParams.Clone() $testProtectedFromAccidentalDeletionParams['ProtectedFromAccidentalDeletion'] = $false - Test-TargetResource @testProtectedFromAccidentalDeletionParams | Should Be $false + Test-TargetResource @testProtectedFromAccidentalDeletionParams | Should -Be $false } It 'Passes when OU does exist, "Ensure" = "Present" and all properties are correct' { Mock -CommandName Assert-Module Mock -CommandName Get-ADOrganizationalUnit -MockWith { return [PSCustomObject] $protectedFakeAdOu } - Test-TargetResource @testPresentParams | Should Be $true + Test-TargetResource @testPresentParams | Should -Be $true } It 'Passes when OU does not exist and "Ensure" = "Absent"' { Mock -CommandName Assert-Module Mock -CommandName Get-ADOrganizationalUnit - Test-TargetResource @testAbsentParams | Should Be $true + Test-TargetResource @testAbsentParams | Should -Be $true } It 'Passes when no OU description is specified with existing OU description' { @@ -186,7 +186,7 @@ try $testEmptyDescriptionParams = $testPresentParams.Clone() $testEmptyDescriptionParams['Description'] = '' - Test-TargetResource @testEmptyDescriptionParams | Should Be $true + Test-TargetResource @testEmptyDescriptionParams | Should -Be $true } } diff --git a/Tests/Unit/MSFT_xADReplicationSite.Tests.ps1 b/Tests/Unit/MSFT_xADReplicationSite.Tests.ps1 index 48a85b2bc..367a8120c 100644 --- a/Tests/Unit/MSFT_xADReplicationSite.Tests.ps1 +++ b/Tests/Unit/MSFT_xADReplicationSite.Tests.ps1 @@ -86,7 +86,7 @@ try $targetResource = Get-TargetResource -Name $presentSiteName # Assert - $targetResource -is [System.Collections.Hashtable] | Should Be $true + $targetResource -is [System.Collections.Hashtable] | Should -Be $true } It 'Should return present if the site exists' { @@ -98,8 +98,8 @@ try $targetResource = Get-TargetResource -Name $presentSiteName # Assert - $targetResource.Ensure | Should Be 'Present' - $targetResource.Name | Should Be $presentSiteName + $targetResource.Ensure | Should -Be 'Present' + $targetResource.Name | Should -Be $presentSiteName } It 'Should return absent if the site does not exist' { @@ -111,8 +111,8 @@ try $targetResource = Get-TargetResource -Name $absentSiteName # Assert - $targetResource.Ensure | Should Be 'Absent' - $targetResource.Name | Should Be $absentSiteName + $targetResource.Ensure | Should -Be 'Absent' + $targetResource.Name | Should -Be $absentSiteName } } #endregion @@ -128,7 +128,7 @@ try $targetResourceState = Test-TargetResource @presentSiteTestPresent # Assert - $targetResourceState -is [System.Boolean] | Should Be $true + $targetResourceState -is [System.Boolean] | Should -Be $true } It 'Should return true if the site should exists and does exists' { @@ -140,7 +140,7 @@ try $targetResourceState = Test-TargetResource @presentSiteTestPresent # Assert - $targetResourceState | Should Be $true + $targetResourceState | Should -Be $true } It 'Should return false if the site should exists but does not exists' { @@ -152,7 +152,7 @@ try $targetResourceState = Test-TargetResource @absentSiteTestPresent # Assert - $targetResourceState | Should Be $false + $targetResourceState | Should -Be $false } It 'Should return false if the site should not exists but does exists' { @@ -164,7 +164,7 @@ try $targetResourceState = Test-TargetResource @presentSiteTestAbsent # Assert - $targetResourceState | Should Be $false + $targetResourceState | Should -Be $false } It 'Should return true if the site should not exists and does not exists' { @@ -176,7 +176,7 @@ try $targetResourceState = Test-TargetResource @absentSiteTestAbsent # Assert - $targetResourceState | Should Be $true + $targetResourceState | Should -Be $true } } diff --git a/Tests/Unit/MSFT_xADReplicationSubnet.Tests.ps1 b/Tests/Unit/MSFT_xADReplicationSubnet.Tests.ps1 index cdb10f1b3..b6632900a 100644 --- a/Tests/Unit/MSFT_xADReplicationSubnet.Tests.ps1 +++ b/Tests/Unit/MSFT_xADReplicationSubnet.Tests.ps1 @@ -51,10 +51,10 @@ try $result = Get-TargetResource @testDefaultParameters - $result.Ensure | Should Be 'Absent' - $result.Name | Should Be $testDefaultParameters.Name - $result.Site | Should Be '' - $result.Location | Should Be '' + $result.Ensure | Should -Be 'Absent' + $result.Name | Should -Be $testDefaultParameters.Name + $result.Site | Should -Be '' + $result.Location | Should -Be '' } } @@ -76,10 +76,10 @@ try $result = Get-TargetResource @testDefaultParameters - $result.Ensure | Should Be 'Present' - $result.Name | Should Be $testDefaultParameters.Name - $result.Site | Should Be 'Default-First-Site-Name' - $result.Location | Should Be 'Seattle' + $result.Ensure | Should -Be 'Present' + $result.Name | Should -Be $testDefaultParameters.Name + $result.Site | Should -Be 'Default-First-Site-Name' + $result.Location | Should -Be 'Seattle' } } @@ -98,10 +98,10 @@ try $result = Get-TargetResource @testDefaultParameters - $result.Ensure | Should Be 'Present' - $result.Name | Should Be $testDefaultParameters.Name - $result.Site | Should Be '' - $result.Location | Should Be 'Seattle' + $result.Ensure | Should -Be 'Present' + $result.Name | Should -Be $testDefaultParameters.Name + $result.Site | Should -Be '' + $result.Location | Should -Be 'Seattle' } } } @@ -123,13 +123,13 @@ try It 'Should return false for present' { $result = Test-TargetResource -Ensure 'Present' @testDefaultParameters - $result | Should Be $false + $result | Should -Be $false } It 'Should return true for absent' { $result = Test-TargetResource -Ensure 'Absent' @testDefaultParameters - $result | Should Be $true + $result | Should -Be $true } } @@ -150,25 +150,25 @@ try It 'Should return true for present' { $result = Test-TargetResource -Ensure 'Present' @testDefaultParameters - $result | Should Be $true + $result | Should -Be $true } It 'Should return false for absent' { $result = Test-TargetResource -Ensure 'Absent' @testDefaultParameters - $result | Should Be $false + $result | Should -Be $false } It 'Should return false for wrong site' { $result = Test-TargetResource -Ensure 'Present' -Name $testDefaultParameters.Name -Site 'WrongSite' -Location $testDefaultParameters.Location - $result | Should Be $false + $result | Should -Be $false } It 'Should return false for wrong location' { $result = Test-TargetResource -Ensure 'Present' -Name $testDefaultParameters.Name -Site $testDefaultParameters.Site -Location 'WringLocation' - $result | Should Be $false + $result | Should -Be $false } } } diff --git a/Tests/Unit/MSFT_xADServicePrincipalName.Tests.ps1 b/Tests/Unit/MSFT_xADServicePrincipalName.Tests.ps1 index b0f81ea45..e280794c1 100644 --- a/Tests/Unit/MSFT_xADServicePrincipalName.Tests.ps1 +++ b/Tests/Unit/MSFT_xADServicePrincipalName.Tests.ps1 @@ -50,9 +50,9 @@ try $result = Get-TargetResource @testDefaultParameters - $result.Ensure | Should Be 'Absent' - $result.ServicePrincipalName | Should Be 'HOST/demo' - $result.Account | Should Be '' + $result.Ensure | Should -Be 'Absent' + $result.ServicePrincipalName | Should -Be 'HOST/demo' + $result.Account | Should -Be '' } } @@ -66,9 +66,9 @@ try $result = Get-TargetResource @testDefaultParameters - $result.Ensure | Should Be 'Present' - $result.ServicePrincipalName | Should Be 'HOST/demo' - $result.Account | Should Be 'User' + $result.Ensure | Should -Be 'Present' + $result.ServicePrincipalName | Should -Be 'HOST/demo' + $result.Account | Should -Be 'User' } } @@ -83,9 +83,9 @@ try $result = Get-TargetResource @testDefaultParameters - $result.Ensure | Should Be 'Present' - $result.ServicePrincipalName | Should Be 'HOST/demo' - $result.Account | Should Be 'User;Computer' + $result.Ensure | Should -Be 'Present' + $result.ServicePrincipalName | Should -Be 'HOST/demo' + $result.Account | Should -Be 'User;Computer' } } } @@ -105,13 +105,13 @@ try It 'Should return false for present' { $result = Test-TargetResource -Ensure 'Present' @testDefaultParameters - $result | Should Be $false + $result | Should -Be $false } It 'Should return true for absent' { $result = Test-TargetResource -Ensure 'Absent' @testDefaultParameters - $result | Should Be $true + $result | Should -Be $true } } @@ -124,13 +124,13 @@ try It 'Should return true for present' { $result = Test-TargetResource -Ensure 'Present' @testDefaultParameters - $result | Should Be $true + $result | Should -Be $true } It 'Should return false for absent' { $result = Test-TargetResource -Ensure 'Absent' @testDefaultParameters - $result | Should Be $false + $result | Should -Be $false } } @@ -143,13 +143,13 @@ try It 'Should return false for present' { $result = Test-TargetResource -Ensure 'Present' @testDefaultParameters - $result | Should Be $false + $result | Should -Be $false } It 'Should return false for absent' { $result = Test-TargetResource -Ensure 'Absent' @testDefaultParameters - $result | Should Be $false + $result | Should -Be $false } } @@ -163,13 +163,13 @@ try It 'Should return false for present' { $result = Test-TargetResource -Ensure 'Present' @testDefaultParameters - $result | Should Be $false + $result | Should -Be $false } It 'Should return false for absent' { $result = Test-TargetResource -Ensure 'Absent' @testDefaultParameters - $result | Should Be $false + $result | Should -Be $false } } @@ -195,7 +195,7 @@ try It 'Should throw the correct exception' { - { Set-TargetResource @testPresentParams } | Should Throw "AD object with SamAccountName 'User' not found!" + { Set-TargetResource @testPresentParams } | Should -Throw "AD object with SamAccountName 'User' not found!" } } diff --git a/Tests/Unit/MSFT_xADUser.Tests.ps1 b/Tests/Unit/MSFT_xADUser.Tests.ps1 index 3c237cd95..2aa6fc0c0 100644 --- a/Tests/Unit/MSFT_xADUser.Tests.ps1 +++ b/Tests/Unit/MSFT_xADUser.Tests.ps1 @@ -75,7 +75,7 @@ try $adUser = Get-TargetResource @testPresentParams - $adUser -is [System.Collections.Hashtable] | Should Be $true + $adUser -is [System.Collections.Hashtable] | Should -Be $true } It "Returns 'Ensure' is 'Present' when user account exists" { @@ -83,7 +83,7 @@ try $adUser = Get-TargetResource @testPresentParams - $adUser.Ensure | Should Be 'Present' + $adUser.Ensure | Should -Be 'Present' } It "Returns 'Ensure' is 'Absent' when user account does not exist" { @@ -91,7 +91,7 @@ try $adUser = Get-TargetResource @testPresentParams - $adUser.Ensure | Should Be 'Absent' + $adUser.Ensure | Should -Be 'Absent' } It "Calls 'Get-ADUser' with 'Server' parameter when 'DomainController' specified" { @@ -123,46 +123,46 @@ try It "Passes when user account does not exist and 'Ensure' is 'Absent'" { Mock -CommandName Get-TargetResource -MockWith { return $testAbsentParams } - Test-TargetResource @testAbsentParams | Should Be $true + Test-TargetResource @testAbsentParams | Should -Be $true } It "Passes when user account exists and 'Ensure' is 'Present'" { Mock -CommandName Get-TargetResource -MockWith { return $testPresentParams } - Test-TargetResource @testPresentParams | Should Be $true + Test-TargetResource @testPresentParams | Should -Be $true } It "Passes when user account password matches, 'Password' is specified and 'PasswordNeverResets' is False" { Mock -CommandName Get-TargetResource -MockWith { return $testPresentParams } Mock -CommandName Test-Password { return $true } - Test-TargetResource @testPresentParams -Password $testCredential | Should Be $true + Test-TargetResource @testPresentParams -Password $testCredential | Should -Be $true } It "Passes when user account password does not match, 'Password' is specified and 'PasswordNeverResets' is True" { Mock -CommandName Get-TargetResource -MockWith { return $testPresentParams } Mock -CommandName Test-Password { return $false } - Test-TargetResource @testPresentParams -Password $testCredential -PasswordNeverResets $true | Should Be $true + Test-TargetResource @testPresentParams -Password $testCredential -PasswordNeverResets $true | Should -Be $true } It "Fails when user account does not exist and 'Ensure' is 'Present'" { Mock -CommandName Get-TargetResource -MockWith { return $testAbsentParams } - Test-TargetResource @testPresentParams | Should Be $false + Test-TargetResource @testPresentParams | Should -Be $false } It "Fails when user account exists, and 'Ensure' is 'Absent'" { Mock -CommandName Get-TargetResource -MockWith { return $testPresentParams } - Test-TargetResource @testAbsentParams | Should Be $false + Test-TargetResource @testAbsentParams | Should -Be $false } It "Fails when user account password is incorrect, 'Password' is specified and 'PasswordNeverResets' is False" { Mock -CommandName Get-TargetResource -MockWith { return $testPresentParams } Mock -CommandName Test-Password { return $false } - Test-TargetResource @testPresentParams -Password $testCredential | Should Be $false + Test-TargetResource @testPresentParams -Password $testCredential | Should -Be $false } It "Calls 'Test-Password' with 'Default' PasswordAuthentication by default" { @@ -196,7 +196,7 @@ try return $validADUser } - Test-TargetResource @testValidPresentParams | Should Be $true + Test-TargetResource @testValidPresentParams | Should -Be $true } It "Fails when user account '$testParameter' does not match incorrect AD account property value" { @@ -210,7 +210,7 @@ try return $invalidADUser } - Test-TargetResource @testValidPresentParams | Should Be $false + Test-TargetResource @testValidPresentParams | Should -Be $false } It "Fails when user account '$testParameter' does not match empty AD account property value" { @@ -224,7 +224,7 @@ try return $invalidADUser } - Test-TargetResource @testValidPresentParams | Should Be $false + Test-TargetResource @testValidPresentParams | Should -Be $false } It "Fails when user account '$testParameter' does not match null AD account property value" { @@ -238,7 +238,7 @@ try return $invalidADUser } - Test-TargetResource @testValidPresentParams | Should Be $false + Test-TargetResource @testValidPresentParams | Should -Be $false } It "Passes when empty user account '$testParameter' matches empty AD account property" { @@ -250,7 +250,7 @@ try return $validADUser } - Test-TargetResource @testValidPresentParams | Should Be $true + Test-TargetResource @testValidPresentParams | Should -Be $true } It "Passes when empty user account '$testParameter' matches null AD account property" { @@ -262,7 +262,7 @@ try return $validADUser } - Test-TargetResource @testValidPresentParams | Should Be $true + Test-TargetResource @testValidPresentParams | Should -Be $true } } #end foreach test string property @@ -280,7 +280,7 @@ try return $validADUser } - Test-TargetResource @testValidPresentParams | Should Be $true + Test-TargetResource @testValidPresentParams | Should -Be $true } It "Fails when user account '$testParameter' does not match AD account property value" { @@ -294,7 +294,7 @@ try return $invalidADUser } - Test-TargetResource @testValidPresentParams | Should Be $false + Test-TargetResource @testValidPresentParams | Should -Be $false } } #end foreach test boolean property @@ -310,7 +310,7 @@ try return $validADUser } - Test-TargetResource @testValidPresentParams | Should Be $true + Test-TargetResource @testValidPresentParams | Should -Be $true } It "Passes when user account '$testParameter' matches single AD account property" { @@ -323,7 +323,7 @@ try return $validADUser } - Test-TargetResource @testValidPresentParams | Should Be $true + Test-TargetResource @testValidPresentParams | Should -Be $true } It "Passes when user account '$testParameter' matches multiple AD account property" { $testParameterValue = @('Entry1', 'Entry2') @@ -335,7 +335,7 @@ try return $validADUser } - Test-TargetResource @testValidPresentParams | Should Be $true + Test-TargetResource @testValidPresentParams | Should -Be $true } It "Fails when user account '$testParameter' does not match AD account property count" { $testParameterValue = @('Entry1', 'Entry2') @@ -347,7 +347,7 @@ try return $validADUser } - Test-TargetResource @testValidPresentParams | Should Be $false + Test-TargetResource @testValidPresentParams | Should -Be $false } It "Fails when user account '$testParameter' does not match AD account property name" { @@ -360,7 +360,7 @@ try return $validADUser } - Test-TargetResource @testValidPresentParams | Should Be $false + Test-TargetResource @testValidPresentParams | Should -Be $false } It "Fails when user account '$testParameter' does not match empty AD account property" { @@ -373,7 +373,7 @@ try return $validADUser } - Test-TargetResource @testValidPresentParams | Should Be $false + Test-TargetResource @testValidPresentParams | Should -Be $false } It "Fails when empty user account '$testParameter' does not match AD account property" { @@ -386,7 +386,7 @@ try return $validADUser } - Test-TargetResource @testValidPresentParams | Should Be $false + Test-TargetResource @testValidPresentParams | Should -Be $false } }#end foreach test array property @@ -634,15 +634,15 @@ try #region Function Assert-TargetResource Describe 'xADUser\Assert-Parameters' { It "Does not throw when 'PasswordNeverExpires' and 'CannotChangePassword' are specified" { - { Assert-Parameters -PasswordNeverExpires $true -CannotChangePassword $true } | Should Not Throw + { Assert-Parameters -PasswordNeverExpires $true -CannotChangePassword $true } | Should -Not -Throw } It "Throws when account is disabled and 'Password' is specified" { - { Assert-Parameters -Password $testCredential -Enabled $false } | Should Throw + { Assert-Parameters -Password $testCredential -Enabled $false } | Should -Throw } It "Does not throw when 'TrustedForDelegation' is specified" { - { Assert-Parameters -TrustedForDelegation $true } | Should Not Throw + { Assert-Parameters -TrustedForDelegation $true } | Should -Not -Throw } } #endregion diff --git a/Tests/Unit/MSFT_xWaitForADDomain.Tests.ps1 b/Tests/Unit/MSFT_xWaitForADDomain.Tests.ps1 index df501463e..1a833c8cf 100644 --- a/Tests/Unit/MSFT_xWaitForADDomain.Tests.ps1 +++ b/Tests/Unit/MSFT_xWaitForADDomain.Tests.ps1 @@ -64,19 +64,19 @@ try It 'Returns a "System.Collections.Hashtable" object type' { Mock -CommandName Get-Domain -MockWith {return $fakeDomainObject} $targetResource = Get-TargetResource @testParams - $targetResource -is [System.Collections.Hashtable] | Should Be $true + $targetResource -is [System.Collections.Hashtable] | Should -Be $true } It "Returns DomainName = $($testParams.DomainName) when domain is found" { Mock -CommandName Get-Domain -MockWith {return $fakeDomainObject} $targetResource = Get-TargetResource @testParams - $targetResource.DomainName | Should Be $testParams.DomainName + $targetResource.DomainName | Should -Be $testParams.DomainName } It "Returns an empty DomainName when domain is not found" { Mock -CommandName Get-Domain $targetResource = Get-TargetResource @testParams - $targetResource.DomainName | Should Be $null + $targetResource.DomainName | Should -Be $null } } #endregion @@ -87,17 +87,17 @@ try It 'Returns a "System.Boolean" object type' { Mock -CommandName Get-Domain -MockWith {return $fakeDomainObject} $targetResource = Test-TargetResource @testParams - $targetResource -is [System.Boolean] | Should Be $true + $targetResource -is [System.Boolean] | Should -Be $true } It 'Passes when domain found' { Mock -CommandName Get-Domain -MockWith {return $fakeDomainObject} - Test-TargetResource @testParams | Should Be $true + Test-TargetResource @testParams | Should -Be $true } It 'Fails when domain not found' { Mock -CommandName Get-Domain - Test-TargetResource @testParams | Should Be $false + Test-TargetResource @testParams | Should -Be $false } } #endregion @@ -113,44 +113,44 @@ try Mock -CommandName Get-Domain -MockWith {return $fakeDomainObject} Mock -CommandName Start-Sleep Mock -CommandName Clear-DnsClientCache - {Set-TargetResource @testParams} | Should Not Throw - $global:DSCMachineStatus | should not be 1 + {Set-TargetResource @testParams} | Should -Not -Throw + $global:DSCMachineStatus | should -not -be 1 Assert-MockCalled -CommandName Start-Sleep -Times 0 -Scope It Assert-MockCalled -CommandName Clear-DnsClientCache -Times 0 -Scope It } It "Throws exception and does not set `$global:DSCMachineStatus when domain not found after $($testParams.RetryCount) retries when RebootRetryCount is not set" { Mock -CommandName Get-Domain - {Set-TargetResource @testParams} | Should Throw - $global:DSCMachineStatus | should not be 1 + {Set-TargetResource @testParams} | Should -Throw + $global:DSCMachineStatus | should -not -be 1 } It "Throws exception when domain not found after $($rebootTestParams.RebootRetryCount) reboot retries when RebootRetryCount is exceeded" { Mock -CommandName Get-Domain Mock -CommandName Get-Content -MockWith {return $rebootTestParams.RebootRetryCount} - {Set-TargetResource @rebootTestParams} | Should Throw + {Set-TargetResource @rebootTestParams} | Should -Throw } It "Calls Set-Content if reboot count is less than RebootRetryCount when domain not found" { Mock -CommandName Get-Domain Mock -CommandName Get-Content -MockWith {return 0} Mock -CommandName Set-Content - {Set-TargetResource @rebootTestParams} | Should Not Throw + {Set-TargetResource @rebootTestParams} | Should -Not -Throw Assert-MockCalled -CommandName Set-Content -Times 1 -Exactly -Scope It } It "Sets `$global:DSCMachineStatus = 1 and does not throw an exception if the domain is not found and RebootRetryCount is not exceeded" { Mock -CommandName Get-Domain Mock -CommandName Get-Content -MockWith {return 0} - {Set-TargetResource @rebootTestParams} | Should Not Throw - $global:DSCMachineStatus | should be 1 + {Set-TargetResource @rebootTestParams} | Should -Not -Throw + $global:DSCMachineStatus | should -be 1 } It "Calls Get-Domain exactly $($testParams.RetryCount) times when domain not found" { Mock -CommandName Get-Domain Mock -CommandName Start-Sleep Mock -CommandName Clear-DnsClientCache - {Set-TargetResource @testParams} | Should Throw + {Set-TargetResource @testParams} | Should -Throw Assert-MockCalled -CommandName Get-Domain -Times $testParams.RetryCount -Exactly -Scope It } @@ -158,7 +158,7 @@ try Mock -CommandName Get-Domain Mock -CommandName Start-Sleep Mock -CommandName Clear-DnsClientCache - {Set-TargetResource @testParams} | Should Throw + {Set-TargetResource @testParams} | Should -Throw Assert-MockCalled -CommandName Start-Sleep -Times $testParams.RetryCount -Exactly -Scope It } @@ -166,7 +166,7 @@ try Mock -CommandName Get-Domain Mock -CommandName Start-Sleep Mock -CommandName Clear-DnsClientCache - {Set-TargetResource @testParams} | Should Throw + {Set-TargetResource @testParams} | Should -Throw Assert-MockCalled -CommandName Clear-DnsClientCache -Times $testParams.RetryCount -Exactly -Scope It } } diff --git a/Tests/Unit/xActiveDirectory.Common.Tests.ps1 b/Tests/Unit/xActiveDirectory.Common.Tests.ps1 index 376a85b74..cd49a2483 100644 --- a/Tests/Unit/xActiveDirectory.Common.Tests.ps1 +++ b/Tests/Unit/xActiveDirectory.Common.Tests.ps1 @@ -582,7 +582,7 @@ InModuleScope 'xActiveDirectory.Common' { $result = Resolve-DomainFQDN -DomainName $testDomainName -ParentDomainName $testParentDomainName - $result | Should Be $testDomainName + $result | Should -Be $testDomainName } It 'Returns compound "DomainName.ParentDomainName" when "ParentDomainName" supplied' { @@ -591,7 +591,7 @@ InModuleScope 'xActiveDirectory.Common' { $result = Resolve-DomainFQDN -DomainName $testDomainName -ParentDomainName $testParentDomainName - $result | Should Be ('{0}.{1}' -f $testDomainName, $testParentDomainName) + $result | Should -Be ('{0}.{1}' -f $testDomainName, $testParentDomainName) } } @@ -604,7 +604,7 @@ InModuleScope 'xActiveDirectory.Common' { } } - Test-DomainMember | Should Be $true + Test-DomainMember | Should -Be $true } It 'Returns "False" when workgroup member' { @@ -614,7 +614,7 @@ InModuleScope 'xActiveDirectory.Common' { } } - Test-DomainMember | Should Be $false + Test-DomainMember | Should -Be $false } } @@ -627,7 +627,7 @@ InModuleScope 'xActiveDirectory.Common' { } } - Get-DomainName | Should Be 'contoso.com' + Get-DomainName | Should -Be 'contoso.com' } } @@ -676,11 +676,11 @@ InModuleScope 'xActiveDirectory.Common' { Describe 'xActiveDirectory.Common\Get-ADObjectParentDN' { It 'Returns CN object parent path' { - Get-ADObjectParentDN -DN 'CN=Administrator,CN=Users,DC=contoso,DC=com' | Should Be 'CN=Users,DC=contoso,DC=com' + Get-ADObjectParentDN -DN 'CN=Administrator,CN=Users,DC=contoso,DC=com' | Should -Be 'CN=Users,DC=contoso,DC=com' } It 'Returns OU object parent path' { - Get-ADObjectParentDN -DN 'CN=Administrator,OU=Custom Organizational Unit,DC=contoso,DC=com' | Should Be 'OU=Custom Organizational Unit,DC=contoso,DC=com' + Get-ADObjectParentDN -DN 'CN=Administrator,OU=Custom Organizational Unit,DC=contoso,DC=com' | Should -Be 'OU=Custom Organizational Unit,DC=contoso,DC=com' } } @@ -688,65 +688,65 @@ InModuleScope 'xActiveDirectory.Common' { It 'Removes one duplicate' { $members = Remove-DuplicateMembers -Members 'User1','User2','USER1' - $members.Count | Should Be 2 - $members -contains 'User1' | Should Be $true - $members -contains 'User2' | Should Be $true + $members.Count | Should -Be 2 + $members -contains 'User1' | Should -Be $true + $members -contains 'User2' | Should -Be $true } It 'Removes two duplicates' { $members = Remove-DuplicateMembers -Members 'User1','User2','USER1','USER2' - $members.Count | Should Be 2 - $members -contains 'User1' | Should Be $true - $members -contains 'User2' | Should Be $true + $members.Count | Should -Be 2 + $members -contains 'User1' | Should -Be $true + $members -contains 'User2' | Should -Be $true } It 'Removes double duplicates' { $members = Remove-DuplicateMembers -Members 'User1','User2','USER1','user1' - $members.Count | Should Be 2 - $members -contains 'User1' | Should Be $true - $members -contains 'User2' | Should Be $true + $members.Count | Should -Be 2 + $members -contains 'User1' | Should -Be $true + $members -contains 'User2' | Should -Be $true } } Describe 'xActiveDirectory.Common\Test-Members' { It 'Passes when nothing is passed' { - Test-Members -ExistingMembers $null | Should Be $true + Test-Members -ExistingMembers $null | Should -Be $true } It 'Passes when there are existing members but members are required' { $testExistingMembers = @('USER1', 'USER2') - Test-Members -ExistingMembers $testExistingMembers | Should Be $true + Test-Members -ExistingMembers $testExistingMembers | Should -Be $true } It 'Passes when existing members match required members' { $testExistingMembers = @('USER1', 'USER2') $testMembers = @('USER2', 'USER1') - Test-Members -ExistingMembers $testExistingMembers -Members $testMembers | Should Be $true + Test-Members -ExistingMembers $testExistingMembers -Members $testMembers | Should -Be $true } It 'Fails when there are no existing members and members are required' { $testExistingMembers = @('USER1', 'USER2') $testMembers = @('USER1', 'USER3') - Test-Members -ExistingMembers $null -Members $testMembers | Should Be $false + Test-Members -ExistingMembers $null -Members $testMembers | Should -Be $false } It 'Fails when there are more existing members than the members required' { $testExistingMembers = @('USER1', 'USER2', 'USER3') $testMembers = @('USER1', 'USER3') - Test-Members -ExistingMembers $null -Members $testMembers | Should Be $false + Test-Members -ExistingMembers $null -Members $testMembers | Should -Be $false } It 'Fails when there are more existing members than the members required' { $testExistingMembers = @('USER1', 'USER2') $testMembers = @('USER1', 'USER3', 'USER2') - Test-Members -ExistingMembers $null -Members $testMembers | Should Be $false + Test-Members -ExistingMembers $null -Members $testMembers | Should -Be $false } It 'Fails when existing members do not match required members' { @@ -868,19 +868,19 @@ InModuleScope 'xActiveDirectory.Common' { } It "Throws if 'Members' and 'MembersToInclude' are specified" { - { Assert-MemberParameters -Members @('User1') -MembersToInclude @('User1') } | Should Throw 'parameters conflict' + { Assert-MemberParameters -Members @('User1') -MembersToInclude @('User1') } | Should -Throw 'parameters conflict' } It "Throws if 'Members' and 'MembersToExclude' are specified" { - { Assert-MemberParameters -Members @('User1') -MembersToExclude @('User2') } | Should Throw 'parameters conflict' + { Assert-MemberParameters -Members @('User1') -MembersToExclude @('User2') } | Should -Throw 'parameters conflict' } It "Throws if 'MembersToInclude' and 'MembersToExclude' contain the same member" { - { Assert-MemberParameters -MembersToExclude @('user1') -MembersToInclude @('USER1') } | Should Throw 'member must not be included in both' + { Assert-MemberParameters -MembersToExclude @('user1') -MembersToInclude @('USER1') } | Should -Throw 'member must not be included in both' } It "Throws if 'MembersToInclude' and 'MembersToExclude' are empty" { - { Assert-MemberParameters -MembersToExclude @() -MembersToInclude @() } | Should Throw 'At least one member must be specified' + { Assert-MemberParameters -MembersToExclude @() -MembersToInclude @() } | Should -Throw 'At least one member must be specified' } } @@ -890,7 +890,7 @@ InModuleScope 'xActiveDirectory.Common' { $result = ConvertTo-TimeSpan -TimeSpan $testIntTimeSpan -TimeSpanType Minutes - $result -is [System.TimeSpan] | Should Be $true + $result -is [System.TimeSpan] | Should -Be $true } It 'Creates TimeSpan from seconds' { @@ -898,7 +898,7 @@ InModuleScope 'xActiveDirectory.Common' { $result = ConvertTo-TimeSpan -TimeSpan $testIntTimeSpan -TimeSpanType Seconds - $result.TotalSeconds | Should Be $testIntTimeSpan + $result.TotalSeconds | Should -Be $testIntTimeSpan } It 'Creates TimeSpan from minutes' { @@ -906,7 +906,7 @@ InModuleScope 'xActiveDirectory.Common' { $result = ConvertTo-TimeSpan -TimeSpan $testIntTimeSpan -TimeSpanType Minutes - $result.TotalMinutes | Should Be $testIntTimeSpan + $result.TotalMinutes | Should -Be $testIntTimeSpan } It 'Creates TimeSpan from hours' { @@ -914,7 +914,7 @@ InModuleScope 'xActiveDirectory.Common' { $result = ConvertTo-TimeSpan -TimeSpan $testIntTimeSpan -TimeSpanType Hours - $result.TotalHours | Should Be $testIntTimeSpan + $result.TotalHours | Should -Be $testIntTimeSpan } It 'Creates TimeSpan from days' { @@ -922,7 +922,7 @@ InModuleScope 'xActiveDirectory.Common' { $result = ConvertTo-TimeSpan -TimeSpan $testIntTimeSpan -TimeSpanType Days - $result.TotalDays | Should Be $testIntTimeSpan + $result.TotalDays | Should -Be $testIntTimeSpan } } @@ -933,7 +933,7 @@ InModuleScope 'xActiveDirectory.Common' { $result = ConvertFrom-TimeSpan -TimeSpan $testTimeSpan -TimeSpanType Seconds - $result -is [System.UInt32] | Should Be $true + $result -is [System.UInt32] | Should -Be $true } It 'Converts TimeSpan to total seconds' { @@ -942,7 +942,7 @@ InModuleScope 'xActiveDirectory.Common' { $result = ConvertFrom-TimeSpan -TimeSpan $testTimeSpan -TimeSpanType Seconds - $result | Should Be $testTimeSpan.TotalSeconds + $result | Should -Be $testTimeSpan.TotalSeconds } It 'Converts TimeSpan to total minutes' { @@ -951,7 +951,7 @@ InModuleScope 'xActiveDirectory.Common' { $result = ConvertFrom-TimeSpan -TimeSpan $testTimeSpan -TimeSpanType Minutes - $result | Should Be $testTimeSpan.TotalMinutes + $result | Should -Be $testTimeSpan.TotalMinutes } It 'Converts TimeSpan to total hours' { @@ -960,7 +960,7 @@ InModuleScope 'xActiveDirectory.Common' { $result = ConvertFrom-TimeSpan -TimeSpan $testTimeSpan -TimeSpanType Hours - $result | Should Be $testTimeSpan.TotalHours + $result | Should -Be $testTimeSpan.TotalHours } It 'Converts TimeSpan to total days' { @@ -969,7 +969,7 @@ InModuleScope 'xActiveDirectory.Common' { $result = ConvertFrom-TimeSpan -TimeSpan $testTimeSpan -TimeSpanType Days - $result | Should Be $testTimeSpan.TotalDays + $result | Should -Be $testTimeSpan.TotalDays } } @@ -979,7 +979,7 @@ InModuleScope 'xActiveDirectory.Common' { $result = Get-ADCommonParameters -Identity $testIdentity - $result -is [System.Collections.Hashtable] | Should Be $true + $result -is [System.Collections.Hashtable] | Should -Be $true } It "Returns 'Identity' key by default" { @@ -987,7 +987,7 @@ InModuleScope 'xActiveDirectory.Common' { $result = Get-ADCommonParameters -Identity $testIdentity - $result['Identity'] | Should Be $testIdentity + $result['Identity'] | Should -Be $testIdentity } It "Returns 'Name' key when 'UseNameParameter' is specified" { @@ -995,7 +995,7 @@ InModuleScope 'xActiveDirectory.Common' { $result = Get-ADCommonParameters -Identity $testIdentity -UseNameParameter - $result['Name'] | Should Be $testIdentity + $result['Name'] | Should -Be $testIdentity } foreach ($identityParam in @('UserName','GroupName','ComputerName')) @@ -1008,7 +1008,7 @@ InModuleScope 'xActiveDirectory.Common' { $result = Get-ADCommonParameters @getADCommonParameters - $result['Identity'] | Should Be $testIdentity + $result['Identity'] | Should -Be $testIdentity } } @@ -1018,7 +1018,7 @@ InModuleScope 'xActiveDirectory.Common' { $result = Get-ADCommonParameters -Identity $testIdentity -CommonName $testCommonName - $result['Identity'] | Should Be $testIdentity + $result['Identity'] | Should -Be $testIdentity } It "Returns 'Identity' key with 'CommonName' when 'Identity', 'CommonName' and 'PreferCommonName' are specified" { @@ -1027,7 +1027,7 @@ InModuleScope 'xActiveDirectory.Common' { $result = Get-ADCommonParameters -Identity $testIdentity -CommonName $testCommonName -PreferCommonName - $result['Identity'] | Should Be $testCommonName + $result['Identity'] | Should -Be $testCommonName } It "Returns 'Identity' key with 'Identity' when 'Identity' and 'PreferCommonName' are specified" { @@ -1035,7 +1035,7 @@ InModuleScope 'xActiveDirectory.Common' { $result = Get-ADCommonParameters -Identity $testIdentity -PreferCommonName - $result['Identity'] | Should Be $testIdentity + $result['Identity'] | Should -Be $testIdentity } it "Returns 'Name' key when 'UseNameParameter' and 'PreferCommonName' are supplied" { @@ -1044,7 +1044,7 @@ InModuleScope 'xActiveDirectory.Common' { $result = Get-ADCommonParameters -Identity $testIdentity -UseNameParameter -CommonName $testCommonName -PreferCommonName - $result['Name'] | Should Be $testCommonName + $result['Name'] | Should -Be $testCommonName } It "Does not return 'Credential' key by default" { @@ -1052,7 +1052,7 @@ InModuleScope 'xActiveDirectory.Common' { $result = Get-ADCommonParameters -Identity $testIdentity - $result.ContainsKey('Credential') | Should Be $false + $result.ContainsKey('Credential') | Should -Be $false } It "Returns 'Credential' key when specified" { @@ -1061,7 +1061,7 @@ InModuleScope 'xActiveDirectory.Common' { $result = Get-ADCommonParameters -Identity $testIdentity -Credential $testCredential - $result['Credential'] | Should Be $testCredential + $result['Credential'] | Should -Be $testCredential } It "Does not return 'Server' key by default" { @@ -1069,7 +1069,7 @@ InModuleScope 'xActiveDirectory.Common' { $result = Get-ADCommonParameters -Identity $testIdentity - $result.ContainsKey('Server') | Should Be $false + $result.ContainsKey('Server') | Should -Be $false } It "Returns 'Server' key when specified" { @@ -1078,7 +1078,7 @@ InModuleScope 'xActiveDirectory.Common' { $result = Get-ADCommonParameters -Identity $testIdentity -Server $testServer - $result['Server'] | Should Be $testServer + $result['Server'] | Should -Be $testServer } It "Converts 'DomainAdministratorCredential' parameter to 'Credential' key" { @@ -1087,7 +1087,7 @@ InModuleScope 'xActiveDirectory.Common' { $result = Get-ADCommonParameters -Identity $testIdentity -DomainAdministratorCredential $testCredential - $result['Credential'] | Should Be $testCredential + $result['Credential'] | Should -Be $testCredential } It "Converts 'DomainController' parameter to 'Server' key" { @@ -1096,7 +1096,7 @@ InModuleScope 'xActiveDirectory.Common' { $result = Get-ADCommonParameters -Identity $testIdentity -DomainController $testServer - $result['Server'] | Should Be $testServer + $result['Server'] | Should -Be $testServer } It 'Accepts remaining arguments' { @@ -1104,83 +1104,83 @@ InModuleScope 'xActiveDirectory.Common' { $result = Get-ADCommonParameters -Identity $testIdentity -UnexpectedParameter 42 - $result['Identity'] | Should Be $testIdentity + $result['Identity'] | Should -Be $testIdentity } } Describe 'xActiveDirectory.Common\ConvertTo-DeploymentForestMode' { It 'Converts an Microsoft.ActiveDirectory.Management.ForestMode to Microsoft.DirectoryServices.Deployment.Types.ForestMode' { - ConvertTo-DeploymentForestMode -Mode Windows2012Forest | Should BeOfType [Microsoft.DirectoryServices.Deployment.Types.ForestMode] + ConvertTo-DeploymentForestMode -Mode Windows2012Forest | Should -BeOfType [Microsoft.DirectoryServices.Deployment.Types.ForestMode] } It 'Converts an Microsoft.ActiveDirectory.Management.ForestMode to the correct Microsoft.DirectoryServices.Deployment.Types.ForestMode' { - ConvertTo-DeploymentForestMode -Mode Windows2012Forest | Should Be ([Microsoft.DirectoryServices.Deployment.Types.ForestMode]::Win2012) + ConvertTo-DeploymentForestMode -Mode Windows2012Forest | Should -Be ([Microsoft.DirectoryServices.Deployment.Types.ForestMode]::Win2012) } It 'Converts valid integer to Microsoft.DirectoryServices.Deployment.Types.ForestMode' { - ConvertTo-DeploymentForestMode -ModeId 5 | Should BeOfType [Microsoft.DirectoryServices.Deployment.Types.ForestMode] + ConvertTo-DeploymentForestMode -ModeId 5 | Should -BeOfType [Microsoft.DirectoryServices.Deployment.Types.ForestMode] } It 'Converts a valid integer to the correct Microsoft.DirectoryServices.Deployment.Types.ForestMode' { - ConvertTo-DeploymentForestMode -ModeId 5 | Should Be ([Microsoft.DirectoryServices.Deployment.Types.ForestMode]::Win2012) + ConvertTo-DeploymentForestMode -ModeId 5 | Should -Be ([Microsoft.DirectoryServices.Deployment.Types.ForestMode]::Win2012) } It 'Throws an exception when an invalid forest mode is selected' { - { ConvertTo-DeploymentForestMode -Mode Nonexistant } | Should Throw + { ConvertTo-DeploymentForestMode -Mode Nonexistant } | Should -Throw } It 'Throws no exception when a null value is passed' { - { ConvertTo-DeploymentForestMode -Mode $null } | Should Not Throw + { ConvertTo-DeploymentForestMode -Mode $null } | Should -Not -Throw } It 'Throws no exception when an invalid mode id is selected' { - { ConvertTo-DeploymentForestMode -ModeId 666 } | Should Not Throw + { ConvertTo-DeploymentForestMode -ModeId 666 } | Should -Not -Throw } It 'Returns $null when a null value is passed' { - ConvertTo-DeploymentForestMode -Mode $null | Should Be $null + ConvertTo-DeploymentForestMode -Mode $null | Should -Be $null } It 'Returns $null when an invalid mode id is selected' { - ConvertTo-DeploymentForestMode -ModeId 666 | Should Be $null + ConvertTo-DeploymentForestMode -ModeId 666 | Should -Be $null } } Describe 'xActiveDirectory.Common\ConvertTo-DeploymentDomainMode' { It 'Converts an Microsoft.ActiveDirectory.Management.DomainMode to Microsoft.DirectoryServices.Deployment.Types.DomainMode' { - ConvertTo-DeploymentDomainMode -Mode Windows2012Domain | Should BeOfType [Microsoft.DirectoryServices.Deployment.Types.DomainMode] + ConvertTo-DeploymentDomainMode -Mode Windows2012Domain | Should -BeOfType [Microsoft.DirectoryServices.Deployment.Types.DomainMode] } It 'Converts an Microsoft.ActiveDirectory.Management.DomainMode to the correct Microsoft.DirectoryServices.Deployment.Types.DomainMode' { - ConvertTo-DeploymentDomainMode -Mode Windows2012Domain | Should Be ([Microsoft.DirectoryServices.Deployment.Types.DomainMode]::Win2012) + ConvertTo-DeploymentDomainMode -Mode Windows2012Domain | Should -Be ([Microsoft.DirectoryServices.Deployment.Types.DomainMode]::Win2012) } It 'Converts valid integer to Microsoft.DirectoryServices.Deployment.Types.DomainMode' { - ConvertTo-DeploymentDomainMode -ModeId 5 | Should BeOfType [Microsoft.DirectoryServices.Deployment.Types.DomainMode] + ConvertTo-DeploymentDomainMode -ModeId 5 | Should -BeOfType [Microsoft.DirectoryServices.Deployment.Types.DomainMode] } It 'Converts a valid integer to the correct Microsoft.DirectoryServices.Deployment.Types.DomainMode' { - ConvertTo-DeploymentDomainMode -ModeId 5 | Should Be ([Microsoft.DirectoryServices.Deployment.Types.DomainMode]::Win2012) + ConvertTo-DeploymentDomainMode -ModeId 5 | Should -Be ([Microsoft.DirectoryServices.Deployment.Types.DomainMode]::Win2012) } It 'Throws an exception when an invalid domain mode is selected' { - { ConvertTo-DeploymentDomainMode -Mode Nonexistant } | Should Throw + { ConvertTo-DeploymentDomainMode -Mode Nonexistant } | Should -Throw } It 'Throws no exception when a null value is passed' { - { ConvertTo-DeploymentDomainMode -Mode $null } | Should Not Throw + { ConvertTo-DeploymentDomainMode -Mode $null } | Should -Not -Throw } It 'Throws no exception when an invalid mode id is selected' { - { ConvertTo-DeploymentDomainMode -ModeId 666 } | Should Not Throw + { ConvertTo-DeploymentDomainMode -ModeId 666 } | Should -Not -Throw } It 'Returns $null when a null value is passed' { - ConvertTo-DeploymentDomainMode -Mode $null | Should Be $null + ConvertTo-DeploymentDomainMode -Mode $null | Should -Be $null } It 'Returns $null when an invalid mode id is selected' { - ConvertTo-DeploymentDomainMode -ModeId 666 | Should Be $null + ConvertTo-DeploymentDomainMode -ModeId 666 | Should -Be $null } }