Skip to content

Commit

Permalink
Fixed unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ykuijs committed Jan 18, 2022
1 parent e2b8113 commit 8acb583
Showing 1 changed file with 16 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ try
InModuleScope -ModuleName $script:DSCResourceFullName -ScriptBlock {
Describe -Name $Global:SPDscHelper.DescribeHeader -Fixture {
BeforeAll {
Invoke-Command -ScriptBlock $Global:SPDscHelper.InitializeScript -NoNewScope
Invoke-Command -Scriptblock $Global:SPDscHelper.InitializeScript -NoNewScope

Mock -CommandName Remove-SPTrustedRootAuthority -MockWith { }
Mock -CommandName Set-SPTrustedRootAuthority -MockWith { }
Expand Down Expand Up @@ -166,7 +166,7 @@ try
Ensure = "Present"
}

Mock -CommandName Get-Item -MockWith {
Mock -CommandName Get-ChildItem -MockWith {
return @{
Subject = "CN=CertName"
Thumbprint = $testParams.CertificateThumbprint
Expand Down Expand Up @@ -208,7 +208,7 @@ try
Ensure = "Present"
}

Mock -CommandName Get-Item -MockWith {
Mock -CommandName Get-ChildItem -MockWith {
return @{
Subject = "CN=CertName"
Thumbprint = $testParams.CertificateThumbprint
Expand Down Expand Up @@ -250,7 +250,7 @@ try
Ensure = "Present"
}

Mock -CommandName Get-Item -MockWith {
Mock -CommandName Get-ChildItem -MockWith {
return @{
Subject = "CN=CertName"
Thumbprint = $testParams.CertificateThumbprint
Expand Down Expand Up @@ -396,7 +396,7 @@ try
}
}

Mock -CommandName Get-Item -MockWith {
Mock -CommandName Get-ChildItem -MockWith {
return @{
Subject = "CN=CertName"
Thumbprint = $testParams.CertificateThumbprint
Expand Down Expand Up @@ -440,7 +440,7 @@ try
return $true
}

Mock -CommandName Get-Item -MockWith {
Mock -CommandName Get-ChildItem -MockWith {
return @{
Subject = "CN=CertName"
Thumbprint = $testParams.CertificateThumbprint
Expand Down Expand Up @@ -540,7 +540,7 @@ try
}
}

Mock -CommandName Get-Item -MockWith {
Mock -CommandName Get-ChildItem -MockWith {
return $null
}
}
Expand Down Expand Up @@ -570,7 +570,7 @@ try
return $null
}

Mock -CommandName Get-Item -MockWith {
Mock -CommandName Get-ChildItem -MockWith {
return $null
}
}
Expand All @@ -596,7 +596,7 @@ try
Ensure = "Present"
}

Mock -CommandName Get-Item -MockWith {
Mock -CommandName Get-ChildItem -MockWith {
return @{
Subject = "CN=CertIdentifier"
Thumbprint = $testParams.CertificateThumbprint
Expand All @@ -618,7 +618,7 @@ try

It "Should create a new trusted root authority in the set method" {
Set-TargetResource @testParams
Assert-MockCalled Get-Item -Times 1
Assert-MockCalled Get-ChildItem -Times 1
Assert-MockCalled New-SPTrustedRootAuthority -Times 1
}
}
Expand All @@ -635,7 +635,7 @@ try
return $true
}

Mock -CommandName Get-Item -MockWith {
Mock -CommandName Get-ChildItem -MockWith {
return @{
Subject = "CN=CertName"
Thumbprint = $testParams.CertificateThumbprint
Expand Down Expand Up @@ -685,7 +685,7 @@ try
return $true
}

Mock -CommandName Get-Item -MockWith {
Mock -CommandName Get-ChildItem -MockWith {
return @{
Subject = "CN=CertName"
Thumbprint = $testParams.CertificateThumbprint
Expand Down Expand Up @@ -731,7 +731,7 @@ try
Ensure = "Present"
}

Mock -CommandName Get-Item -MockWith {
Mock -CommandName Get-ChildItem -MockWith {
$retVal = [pscustomobject]@{
Subject = "CN=CertIdentifier"
Thumbprint = $testParams.CertificateThumbprint
Expand Down Expand Up @@ -780,7 +780,7 @@ try

It "Should create a new Trusted Root Authority in the set method" {
Set-TargetResource @testParams
Assert-MockCalled Get-Item -Times 1
Assert-MockCalled Get-ChildItem -Times 1
Assert-MockCalled Set-SPTrustedRootAuthority -Times 1
Assert-MockCalled New-Object -Times 1
}
Expand All @@ -794,7 +794,7 @@ try
Ensure = "Absent"
}

Mock -CommandName Get-Item -MockWith {
Mock -CommandName Get-ChildItem -MockWith {
return @{
Subject = "CN=CertIdentifier"
Thumbprint = $testParams.CertificateThumbprint
Expand Down Expand Up @@ -833,7 +833,7 @@ try
Ensure = "Absent"
}

Mock -CommandName Get-Item -MockWith {
Mock -CommandName Get-ChildItem -MockWith {
return @{
Subject = "CN=CertIdentifier"
Thumbprint = $testParams.CertificateThumbprint
Expand Down

0 comments on commit 8acb583

Please sign in to comment.