Skip to content

Commit

Permalink
improve tests and increase code coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
Yvand committed Jan 14, 2022
1 parent b7896c1 commit d58282a
Showing 1 changed file with 32 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -569,19 +569,30 @@ try
}

Mock -CommandName Get-SPTrustedIdentityTokenIssuer -MockWith {
return $null
}

Mock -CommandName New-SPTrustedIdentityTokenIssuer -MockWith {
$sptrust = [pscustomobject]@{
Name = $testParams.Name
ClaimProviderName = $testParams.ClaimProviderName
ImportTrustCertificate = $null
Name = ""
Description = ""
Realm = ""
SignInUrl = ""
UseWReply = ""
ProviderSignOutUri = ""
IdentifierClaim = ""
ClaimsMappings = $null
ClaimProviderName = ""
}
$sptrust | Add-Member -Name Update -MemberType ScriptMethod -Value { }
return $sptrust
}
}

It "Should create the SPTrustedLoginProvider with claims provider set" {
It "Should call cmdlet New-SPTrustedIdentityTokenIssuer" {
Set-TargetResource @testParams
$getResults = Get-TargetResource @testParams
$getResults.ClaimProviderName | Should -Be $testParams.ClaimProviderName
Assert-MockCalled New-SPTrustedIdentityTokenIssuer
}
}

Expand Down Expand Up @@ -615,19 +626,30 @@ try
}

Mock -CommandName Get-SPTrustedIdentityTokenIssuer -MockWith {
return $null
}

Mock -CommandName New-SPTrustedIdentityTokenIssuer -MockWith {
$sptrust = [pscustomobject]@{
Name = $testParams.Name
ClaimProviderName = $testParams.ClaimProviderName
ImportTrustCertificate = $null
Name = ""
Description = ""
RegisteredIssuerName = ""
AuthorizationEndPointUri = ""
DefaultClientIdentifier = ""
SignOutUrl = ""
IdentifierClaim = ""
ClaimsMappings = $null
ClaimProviderName = ""
}
$sptrust | Add-Member -Name Update -MemberType ScriptMethod -Value { }
return $sptrust
}
}

It "Should create the SPTrustedLoginProvider with claims provider set" {
It "Should call cmdlet New-SPTrustedIdentityTokenIssuer" {
Set-TargetResource @testParams
$getResults = Get-TargetResource @testParams
$getResults.ClaimProviderName | Should -Be $testParams.ClaimProviderName
Assert-MockCalled New-SPTrustedIdentityTokenIssuer
}
}
}
Expand Down

0 comments on commit d58282a

Please sign in to comment.