Skip to content

Commit

Permalink
Corrected unit tests and updated changelog
Browse files Browse the repository at this point in the history
  • Loading branch information
ykuijs committed Apr 25, 2023
1 parent 1147615 commit 096edc9
Show file tree
Hide file tree
Showing 3 changed files with 88 additions and 0 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Added

- SPDistributedCacheClientSettings
- Added additional parameters for SP2019 and SPSE

### Changed

- SPFarm
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -910,6 +910,56 @@ function Set-TargetResource
}
}

if ($PSBoundParameters.ContainsKey("DDBFCMaxConnectionsToServer") -eq $true -or
$PSBoundParameters.ContainsKey("DDBFCRequestTimeout") -eq $true -or
$PSBoundParameters.ContainsKey("DDBFCChannelOpenTimeOut") -eq $true -or
$PSBoundParameters.ContainsKey("DEHCMaxConnectionsToServer") -eq $true -or
$PSBoundParameters.ContainsKey("DEHCRequestTimeout") -eq $true -or
$PSBoundParameters.ContainsKey("DEHCChannelOpenTimeOut") -eq $true -or
$PSBoundParameters.ContainsKey("DFSPTCMaxConnectionsToServer") -eq $true -or
$PSBoundParameters.ContainsKey("DFSPTCRequestTimeout") -eq $true -or
$PSBoundParameters.ContainsKey("DFSPTCChannelOpenTimeOut") -eq $true -or
$PSBoundParameters.ContainsKey("DSPABSCMaxConnectionsToServer") -eq $true -or
$PSBoundParameters.ContainsKey("DSPABSCRequestTimeout") -eq $true -or
$PSBoundParameters.ContainsKey("DSPABSCChannelOpenTimeOut") -eq $true -or
$PSBoundParameters.ContainsKey("DSPCVCMaxConnectionsToServer") -eq $true -or
$PSBoundParameters.ContainsKey("DSPCVCRequestTimeout") -eq $true -or
$PSBoundParameters.ContainsKey("DSPCVCChannelOpenTimeOut") -eq $true -or
$PSBoundParameters.ContainsKey("DSPOATCMaxConnectionsToServer") -eq $true -or
$PSBoundParameters.ContainsKey("DSPOATCRequestTimeout") -eq $true -or
$PSBoundParameters.ContainsKey("DSPOATCChannelOpenTimeOut") -eq $true -or
$PSBoundParameters.ContainsKey("DSGCMaxConnectionsToServer") -eq $true -or
$PSBoundParameters.ContainsKey("DSGCRequestTimeout") -eq $true -or
$PSBoundParameters.ContainsKey("DSGCChannelOpenTimeOut") -eq $true -or
$PSBoundParameters.ContainsKey("DUACMaxConnectionsToServer") -eq $true -or
$PSBoundParameters.ContainsKey("DUACRequestTimeout") -eq $true -or
$PSBoundParameters.ContainsKey("DUACChannelOpenTimeOut") -eq $true -or
$PSBoundParameters.ContainsKey("DUAuCMaxConnectionsToServer") -eq $true -or
$PSBoundParameters.ContainsKey("DUAuCRequestTimeout") -eq $true -or
$PSBoundParameters.ContainsKey("DUAuCChannelOpenTimeOut") -eq $true)
{
$installedVersion = Get-SPDscInstalledProductVersion
if ($installedVersion.FileMajorPart -eq 15 -or `
$installedVersion.ProductBuildPart.ToString().Length -eq 4)
{
$message = ("The following parameters are only supported in SharePoint 2019 and above: " + `
"DDBFCMaxConnectionsToServer, DDBFCRequestTimeout, DDBFCChannelOpenTimeOut, " + `
"DEHCMaxConnectionsToServer, DEHCRequestTimeout, DEHCChannelOpenTimeOut, " + `
"DFSPTCMaxConnectionsToServer, DFSPTCRequestTimeout, DFSPTCChannelOpenTimeOut, " + `
"DSPABSCMaxConnectionsToServer, DSPABSCRequestTimeout, DSPABSCChannelOpenTimeOut, " + `
"DSPCVCMaxConnectionsToServer, DSPCVCRequestTimeout, DSPCVCChannelOpenTimeOut, " + `
"DSPOATCMaxConnectionsToServer, DSPOATCRequestTimeout, DSPOATCChannelOpenTimeOut, " + `
"DSGCMaxConnectionsToServer, DSGCRequestTimeout, DSGCChannelOpenTimeOut, " + `
"DUACMaxConnectionsToServer, DUACRequestTimeout, DUACChannelOpenTimeOut, " + `
"DUAuCMaxConnectionsToServer, DUAuCRequestTimeout, DUAuCChannelOpenTimeOut")
Add-SPDscEvent -Message $message `
-EntryType 'Error' `
-EventID 100 `
-Source $MyInvocation.MyCommand.Source
throw $message
}
}

Invoke-SPDscCommand -Arguments $PSBoundParameters `
-ScriptBlock {
$params = $args[0]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,39 @@ try
}
}
}

if ($Global:SPDscHelper.CurrentStubBuildNumber.Build.ToString().Length -lt 5)
{
Context -Name "SP2019+ parameters specified with older versions" -Fixture {
BeforeAll {
Mock -CommandName Get-SPDistributedCacheClientSetting -MockWith {
return @{
MaxConnectionsToServer = 1
RequestTimeout = 3000
ChannelOpenTimeOut = 3000
}
}
$testParams = @{
IsSingleInstance = "Yes"
DUAuCMaxConnectionsToServer = 1
DUAuCRequestTimeout = 3000
DUAuCChannelOpenTimeOut = 3000
}
}

It "Should throw exception in the Get method" {
{ Get-TargetResource @testParams } | Should -Throw "The following parameters are only supported in SharePoint 2019 and above"
}

It "Should throw exception in the Set method" {
{ Set-TargetResource @testParams } | Should -Throw "The following parameters are only supported in SharePoint 2019 and above"
}

It "Should throw exception in the Test method" {
{ Test-TargetResource @testParams } | Should -Throw "The following parameters are only supported in SharePoint 2019 and above"
}
}
}
}
}
}
Expand Down

0 comments on commit 096edc9

Please sign in to comment.