@@ -33,7 +33,7 @@ function Invoke-TestSetup
3333
3434 $script :testEnvironment = Initialize-TestEnvironment `
3535 - DSCModuleName $script :DSCModuleName `
36- - DSCResourceName $script :DSCResourceFullName `
36+ - DscResourceName $script :DSCResourceFullName `
3737 - ResourceType ' Mof' `
3838 - TestType ' Unit'
3939}
260260 CertificateExpirationWarningThresholdDays = 15
261261 CertificateExpirationErrorThresholdDays = 15
262262 CertificateNotificationContacts = @ (
263- @ {
263+ [ PSCustomObject ] @ {
264264 Address = ' wrong@contoso.com'
265265 }
266266 )
270270 Mock - CommandName Get-SPFarm - MockWith { return @ { } }
271271 Mock - CommandName Get-SPCertificateNotificationContact - MockWith {
272272 return @ (
273- @ {
273+ [ PSCustomObject ] @ {
274274 Address = ' wrong@contoso.com'
275275 }
276276 )
295295 }
296296 }
297297
298+ Context - Name " The server is in a farm and zero contacts have been applied" - Fixture {
299+ BeforeAll {
300+ $testParams = @ {
301+ IsSingleInstance = ' Yes'
302+ CertificateNotificationContacts = ' admin@contoso.com'
303+ }
304+
305+ Mock - CommandName Get-SPCertificateSettings - MockWith {
306+ $returnVal = @ {
307+ DefaultOrganizationalUnit = ' '
308+ DefaultOrganization = ' '
309+ DefaultLocality = ' '
310+ DefaultState = ' '
311+ DefaultCountry = ' '
312+ DefaultKeyAlgorithm = ' RSA'
313+ DefaultRsaKeySize = 2048
314+ DefaultEllipticCurve = ' nistP256'
315+ DefaultHashAlgorithm = ' SHA256'
316+ DefaultRsaSignaturePadding = ' Pkcs1'
317+ CertificateExpirationAttentionThresholdDays = 60
318+ CertificateExpirationWarningThresholdDays = 15
319+ CertificateExpirationErrorThresholdDays = 15
320+ CertificateNotificationContacts = [System.Net.Mail.MailAddressCollection ]::new()
321+ }
322+ return $returnVal
323+ }
324+ Mock - CommandName Get-SPFarm - MockWith { return @ { } }
325+ Mock - CommandName Get-SPCertificateNotificationContact - MockWith {
326+ return [System.Net.Mail.MailAddressCollection ]::new()
327+ }
328+ Mock - CommandName Add-SPCertificateNotificationContact - MockWith {}
329+ Mock - CommandName Remove-SPCertificateNotificationContact - MockWith {}
330+ }
331+
332+ It " Should return values from the get method" {
333+ $result = Get-TargetResource @testParams
334+ $result.CertificateNotificationContacts.Count | Should - Be 0
335+ }
336+
337+ It " Should return false from the test method" {
338+ Test-TargetResource @testParams | Should - Be $false
339+ }
340+
341+ It " Should update the certificate settings" {
342+ Set-TargetResource @testParams
343+ Assert-MockCalled Add-SPCertificateNotificationContact
344+ }
345+ }
346+
298347 Context - Name " The server is in a farm and the correct settings have been applied" - Fixture {
299348 BeforeAll {
300349 $testParams = @ {
0 commit comments