Skip to content

Commit

Permalink
Merge pull request #56 from PlagueHO/Issue-53
Browse files Browse the repository at this point in the history
Updated tests to meet Pester V4 guidelines - Fixes #53
  • Loading branch information
PlagueHO authored Jan 14, 2018
2 parents b024c24 + 70295b3 commit 0803d6c
Show file tree
Hide file tree
Showing 16 changed files with 1,301 additions and 1,300 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
[issue #49](https://github.com/PowerShell/xDFS/issues/49).
- Prevent unit tests from DSCResource.Tests from running during test
execution - fixes [Issue #51](https://github.com/PowerShell/xDFS/issues/51).
- Updated tests to meet Pester V4 guidelines - fixes [Issue #53](https://github.com/PowerShell/xDFS/issues/53).

## 3.2.0.0

Expand Down
42 changes: 21 additions & 21 deletions Tests/Integration/MSFT_xDFSNamespaceFolder.Integration.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ try
$productType = (Get-CimInstance Win32_OperatingSystem).ProductType
Describe 'Environment' {
Context 'Operating System' {
It 'should be a Server OS' {
$productType | Should Be 3
It 'Should be a Server OS' {
$productType | Should -Be 3
}
}
}
Expand All @@ -40,8 +40,8 @@ try
$featureInstalled = (Get-WindowsFeature -Name FS-DFS-Namespace).Installed
Describe 'Environment' {
Context 'Windows Features' {
It 'should have the DFS Namespace Feature Installed' {
$featureInstalled | Should Be $true
It 'Should have the DFS Namespace Feature Installed' {
$featureInstalled | Should -Be $true
}
}
}
Expand Down Expand Up @@ -88,36 +88,36 @@ try
-Type Standalone

#region DEFAULT TESTS
It 'should compile and apply the MOF without throwing' {
It 'Should compile and apply the MOF without throwing' {
{
& "$($script:DSCResourceName)_Config" -OutputPath $TestDrive
Start-DscConfiguration -Path $TestDrive -ComputerName localhost -Wait -Verbose -Force
} | Should not throw
} | Should -Not -Throw
}

It 'should be able to call Get-DscConfiguration without throwing' {
{ Get-DscConfiguration -Verbose -ErrorAction Stop } | Should Not throw
It 'Should be able to call Get-DscConfiguration without throwing' {
{ Get-DscConfiguration -Verbose -ErrorAction Stop } | Should -Not -Throw
}
#endregion

It 'should have set the resource and all the folder parameters should match' {
It 'Should have set the resource and all the folder parameters should match' {
# Get the Rule details
$NamespaceFolderNew = Get-DfsnFolder -Path $NamespaceFolder.Path
$NamespaceFolderNew.Path | Should Be $NamespaceFolder.Path
$NamespaceFolderNew.TimeToLiveSec | Should Be 300
$NamespaceFolderNew.State | Should Be 'Online'
$NamespaceFolderNew.Description | Should Be $NamespaceFolder.Description
$NamespaceFolderNew.NamespacePath | Should Be $NamespaceFolder.Path
$NamespaceFolderNew.Flags | Should Be @('Target Failback','Insite Referrals')
$NamespaceFolderNew.Path | Should -Be $NamespaceFolder.Path
$NamespaceFolderNew.TimeToLiveSec | Should -Be 300
$NamespaceFolderNew.State | Should -Be 'Online'
$NamespaceFolderNew.Description | Should -Be $NamespaceFolder.Description
$NamespaceFolderNew.NamespacePath | Should -Be $NamespaceFolder.Path
$NamespaceFolderNew.Flags | Should -Be @('Target Failback','Insite Referrals')
}

It 'should have set the resource and all the folder target parameters should match' {
It 'Should have set the resource and all the folder target parameters should match' {
$NamespaceFolderTargetNew = Get-DfsnFolderTarget -Path $NamespaceFolder.Path -TargetPath $NamespaceFolder.TargetPath
$NamespaceFolderTargetNew.Path | Should Be $NamespaceFolder.Path
$NamespaceFolderTargetNew.NamespacePath | Should Be $NamespaceFolder.Path
$NamespaceFolderTargetNew.TargetPath | Should Be $NamespaceFolder.TargetPath
$NamespaceFolderTargetNew.ReferralPriorityClass | Should Be $NamespaceFolder.ReferralPriorityClass
$NamespaceFolderTargetNew.ReferralPriorityRank | Should Be $NamespaceFolder.ReferralPriorityRank
$NamespaceFolderTargetNew.Path | Should -Be $NamespaceFolder.Path
$NamespaceFolderTargetNew.NamespacePath | Should -Be $NamespaceFolder.Path
$NamespaceFolderTargetNew.TargetPath | Should -Be $NamespaceFolder.TargetPath
$NamespaceFolderTargetNew.ReferralPriorityClass | Should -Be $NamespaceFolder.ReferralPriorityClass
$NamespaceFolderTargetNew.ReferralPriorityRank | Should -Be $NamespaceFolder.ReferralPriorityRank
}

# Clean up
Expand Down
44 changes: 22 additions & 22 deletions Tests/Integration/MSFT_xDFSNamespaceRoot.Integration.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ try
$productType = (Get-CimInstance Win32_OperatingSystem).ProductType
Describe 'Environment' {
Context 'Operating System' {
It 'should be a Server OS' {
$productType | Should Be 3
It 'Should be a Server OS' {
$productType | Should -Be 3
}
}
}
Expand All @@ -40,8 +40,8 @@ try
$featureInstalled = (Get-WindowsFeature -Name FS-DFS-Namespace).Installed
Describe 'Environment' {
Context 'Windows Features' {
It 'should have the DFS Namespace Feature Installed' {
$featureInstalled | Should Be $true
It 'Should have the DFS Namespace Feature Installed' {
$featureInstalled | Should -Be $true
}
}
}
Expand Down Expand Up @@ -71,37 +71,37 @@ try
-FullAccess 'Everyone'

#region DEFAULT TESTS
It 'should compile and apply the MOF without throwing' {
It 'Should compile and apply the MOF without throwing' {
{
& "$($script:DSCResourceName)_Config" -OutputPath $TestDrive
Start-DscConfiguration -Path $TestDrive -ComputerName localhost -Wait -Verbose -Force
} | Should not throw
} | Should -Not -Throw
}

It 'should be able to call Get-DscConfiguration without throwing' {
{ Get-DscConfiguration -Verbose -ErrorAction Stop } | Should Not throw
It 'Should be able to call Get-DscConfiguration without throwing' {
{ Get-DscConfiguration -Verbose -ErrorAction Stop } | Should -Not -Throw
}
#endregion

It 'should have set the resource and all the folder parameters should match' {
It 'Should have set the resource and all the folder parameters should match' {
# Get the Rule details
$NamespaceRootNew = Get-DfsnRoot -Path $NamespaceRoot.Path
$NamespaceRootNew.Path | Should Be $NamespaceRoot.Path
$NamespaceRootNew.Type | Should Be $NamespaceRoot.Type
$NamespaceRootNew.TimeToLiveSec | Should Be $NamespaceRoot.TimeToLiveSec
$NamespaceRootNew.State | Should Be 'Online'
$NamespaceRootNew.Description | Should Be $NamespaceRoot.Description
$NamespaceRootNew.NamespacePath | Should Be $NamespaceRoot.Path
$NamespaceRootNew.Flags | Should Be @('Target Failback','Site Costing','Insite Referrals','AccessBased Enumeration')
$NamespaceRootNew.Path | Should -Be $NamespaceRoot.Path
$NamespaceRootNew.Type | Should -Be $NamespaceRoot.Type
$NamespaceRootNew.TimeToLiveSec | Should -Be $NamespaceRoot.TimeToLiveSec
$NamespaceRootNew.State | Should -Be 'Online'
$NamespaceRootNew.Description | Should -Be $NamespaceRoot.Description
$NamespaceRootNew.NamespacePath | Should -Be $NamespaceRoot.Path
$NamespaceRootNew.Flags | Should -Be @('Target Failback','Site Costing','Insite Referrals','AccessBased Enumeration')
}

It 'should have set the resource and all the folder target parameters should match' {
It 'Should have set the resource and all the folder target parameters should match' {
$NamespaceRootTargetNew = Get-DfsnRootTarget -Path $NamespaceRoot.Path -TargetPath $NamespaceRoot.TargetPath
$NamespaceRootTargetNew.Path | Should Be $NamespaceRoot.Path
$NamespaceRootTargetNew.NamespacePath | Should Be $NamespaceRoot.Path
$NamespaceRootTargetNew.TargetPath | Should Be $NamespaceRoot.TargetPath
$NamespaceRootTargetNew.ReferralPriorityClass | Should Be $NamespaceRoot.ReferralPriorityClass
$NamespaceRootTargetNew.ReferralPriorityRank | Should Be $NamespaceRoot.ReferralPriorityRank
$NamespaceRootTargetNew.Path | Should -Be $NamespaceRoot.Path
$NamespaceRootTargetNew.NamespacePath | Should -Be $NamespaceRoot.Path
$NamespaceRootTargetNew.TargetPath | Should -Be $NamespaceRoot.TargetPath
$NamespaceRootTargetNew.ReferralPriorityClass | Should -Be $NamespaceRoot.ReferralPriorityClass
$NamespaceRootTargetNew.ReferralPriorityRank | Should -Be $NamespaceRoot.ReferralPriorityRank
}

# Clean up
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ try
$productType = (Get-CimInstance Win32_OperatingSystem).ProductType
Describe 'Environment' {
Context 'Operating System' {
It 'should be a Server OS' {
$productType | Should Be 3
It 'Should be a Server OS' {
$productType | Should -Be 3
}
}
}
Expand All @@ -40,8 +40,8 @@ try
$featureInstalled = (Get-WindowsFeature -Name FS-DFS-Namespace).Installed
Describe 'Environment' {
Context 'Windows Features' {
It 'should have the DFS Namespace Feature Installed' {
$featureInstalled | Should Be $true
It 'Should have the DFS Namespace Feature Installed' {
$featureInstalled | Should -Be $true
}
}
}
Expand All @@ -61,19 +61,19 @@ try

Describe "$($script:DSCResourceName)_Integration" {
#region DEFAULT TESTS
It 'should compile and apply the MOF without throwing' {
It 'Should compile and apply the MOF without throwing' {
{
& "$($script:DSCResourceName)_Config" -OutputPath $TestDrive
Start-DscConfiguration -Path $TestDrive -ComputerName localhost -Wait -Verbose -Force
} | Should not throw
} | Should -Not -Throw
}

It 'should be able to call Get-DscConfiguration without throwing' {
{ Get-DscConfiguration -Verbose -ErrorAction Stop } | Should Not throw
It 'Should be able to call Get-DscConfiguration without throwing' {
{ Get-DscConfiguration -Verbose -ErrorAction Stop } | Should -Not -Throw
}
#endregion

It 'should have set the resource and all the parameters should match' {
It 'Should have set the resource and all the parameters should match' {
# Get the Rule details
$NamespaceServerConfigurationNew = Get-DfsnServerConfiguration -ComputerName $env:COMPUTERNAME
$NamespaceServerConfigurationNew.LdapTimeoutSec = $NamespaceServerConfiguration.LdapTimeoutSec
Expand Down
24 changes: 12 additions & 12 deletions Tests/Integration/MSFT_xDFSReplicationGroup.Integration.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ try

Describe "$($script:DSCResourceName)_Integration" {
#region DEFAULT TESTS
It 'should compile and apply the MOF without throwing' {
It 'Should compile and apply the MOF without throwing' {
{
$ConfigData = @{
AllNodes = @(
Expand All @@ -79,20 +79,20 @@ try

& "$($script:DSCResourceName)_Config" -OutputPath $TestDrive -ConfigurationData $ConfigData
Start-DscConfiguration -Path $TestDrive -ComputerName localhost -Wait -Verbose -Force
} | Should not throw
} | Should -Not -Throw
}

It 'should be able to call Get-DscConfiguration without throwing' {
{ Get-DscConfiguration -Verbose -ErrorAction Stop } | Should Not throw
It 'Should be able to call Get-DscConfiguration without throwing' {
{ Get-DscConfiguration -Verbose -ErrorAction Stop } | Should -Not -Throw
}
#endregion

It 'should have set the resource and all the parameters should match' {
It 'Should have set the resource and all the parameters should match' {
$ReplicationGroupNew = Get-DfsReplicationGroup `
-GroupName $ReplicationGroup.GroupName `
-ErrorAction Stop
$ReplicationGroupNew.GroupName | Should Be $ReplicationGroup.GroupName
$ReplicationGroupNew.Description | Should Be $ReplicationGroup.Description
$ReplicationGroupNew.GroupName | Should -Be $ReplicationGroup.GroupName
$ReplicationGroupNew.Description | Should -Be $ReplicationGroup.Description

# Check the members are in the Replication Group
foreach ($Member in $ReplicationGroup.Members)
Expand All @@ -101,16 +101,16 @@ try
-GroupName $ReplicationGroup.GroupName `
-ComputerName $Member `
-ErrorAction Stop
$ReplicationGroupMemberNew.GroupName | Should Be $ReplicationGroup.GroupName
$ReplicationGroupMemberNew.GroupName | Should -Be $ReplicationGroup.GroupName

# If Member name was an FQDN then match the DNSName property, otherwise the ComputerName property
if ($Member.Contains('.'))
{
$ReplicationGroupMemberNew.DnsName | Should Be $Member
$ReplicationGroupMemberNew.DnsName | Should -Be $Member
}
else
{
$ReplicationGroupMemberNew.ComputerName | Should Be $Member
$ReplicationGroupMemberNew.ComputerName | Should -Be $Member
}
}

Expand All @@ -121,8 +121,8 @@ try
-GroupName $ReplicationGroup.GroupName `
-FolderName $Folder `
-ErrorAction Stop
$ReplicationGroupFolderNew.GroupName | Should Be $ReplicationGroup.GroupName
$ReplicationGroupFolderNew.FolderName | Should Be $Folder
$ReplicationGroupFolderNew.GroupName | Should -Be $ReplicationGroup.GroupName
$ReplicationGroupFolderNew.FolderName | Should -Be $Folder
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ try
}

#region DEFAULT TESTS
It 'should compile and apply the MOF without throwing' {
It 'Should compile and apply the MOF without throwing' {
{
$ConfigData = @{
AllNodes = @(
Expand All @@ -97,23 +97,23 @@ try

& "$($script:DSCResourceName)_Config" -OutputPath $TestDrive -ConfigurationData $ConfigData
Start-DscConfiguration -Path $TestDrive -ComputerName localhost -Wait -Verbose -Force
} | Should not throw
} | Should -Not -Throw
}

It 'should be able to call Get-DscConfiguration without throwing' {
{ Get-DscConfiguration -Verbose -ErrorAction Stop } | Should Not throw
It 'Should be able to call Get-DscConfiguration without throwing' {
{ Get-DscConfiguration -Verbose -ErrorAction Stop } | Should -Not -Throw
}
#endregion

It 'should have set the resource and all the parameters should match' {
It 'Should have set the resource and all the parameters should match' {
$ReplicationGroupConnectionNew = Get-DfsrConnection `
-GroupName $ReplicationGroupConnection.GroupName `
-SourceComputerName $ReplicationGroupConnection.SourceComputerName `
-DestinationComputerName $ReplicationGroupConnection.DestinationComputerName `
-ErrorAction Stop
$ReplicationGroupConnectionNew.GroupName | Should Be $ReplicationGroupConnection.GroupName
$ReplicationGroupConnectionNew.SourceComputerName | Should Be $ReplicationGroupConnection.SourceComputerName
$ReplicationGroupConnectionNew.DestinationComputerName | Should Be $ReplicationGroupConnection.DestinationComputerName
$ReplicationGroupConnectionNew.GroupName | Should -Be $ReplicationGroupConnection.GroupName
$ReplicationGroupConnectionNew.SourceComputerName | Should -Be $ReplicationGroupConnection.SourceComputerName
$ReplicationGroupConnectionNew.DestinationComputerName | Should -Be $ReplicationGroupConnection.DestinationComputerName
}

# Clean up
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ try
}

#region DEFAULT TESTS
It 'should compile and apply the MOF without throwing' {
It 'Should compile and apply the MOF without throwing' {
{
$ConfigData = @{
AllNodes = @(
Expand All @@ -97,24 +97,24 @@ try

& "$($script:DSCResourceName)_Config" -OutputPath $TestDrive -ConfigurationData $ConfigData
Start-DscConfiguration -Path $TestDrive -ComputerName localhost -Wait -Verbose -Force
} | Should not throw
} | Should -Not -Throw
}

It 'should be able to call Get-DscConfiguration without throwing' {
{ Get-DscConfiguration -Verbose -ErrorAction Stop } | Should Not throw
It 'Should be able to call Get-DscConfiguration without throwing' {
{ Get-DscConfiguration -Verbose -ErrorAction Stop } | Should -Not -Throw
}
#endregion

It 'should have set the resource and all the parameters should match' {
It 'Should have set the resource and all the parameters should match' {
$ReplicationGroupFolderNew = Get-DfsReplicatedFolder `
-GroupName $ReplicationGroupFolder.GroupName `
-FolderName $ReplicationGroupFolder.FolderName `
-ErrorAction Stop
$ReplicationGroupFolderNew.GroupName | Should Be $ReplicationGroupFolder.GroupName
$ReplicationGroupFolderNew.FolderName | Should Be $ReplicationGroupFolder.FolderName
$ReplicationGroupFolderNew.Description | Should Be $ReplicationGroupFolder.Description
$ReplicationGroupFolderNew.DirectoryNameToExclude | Should Be $ReplicationGroupFolder.DirectoryNameToExclude
$ReplicationGroupFolderNew.FilenameToExclude | Should Be $ReplicationGroupFolder.FilenameToExclude
$ReplicationGroupFolderNew.GroupName | Should -Be $ReplicationGroupFolder.GroupName
$ReplicationGroupFolderNew.FolderName | Should -Be $ReplicationGroupFolder.FolderName
$ReplicationGroupFolderNew.Description | Should -Be $ReplicationGroupFolder.Description
$ReplicationGroupFolderNew.DirectoryNameToExclude | Should -Be $ReplicationGroupFolder.DirectoryNameToExclude
$ReplicationGroupFolderNew.FilenameToExclude | Should -Be $ReplicationGroupFolder.FilenameToExclude
}

# Clean up
Expand Down
Loading

0 comments on commit 0803d6c

Please sign in to comment.