@@ -65,7 +65,7 @@ Describe 'New-SqlDscAudit' -Tag 'Public' {
6565 }
6666 @ {
6767 MockParameterSetName = ' FileWithMaxFiles'
68- MockExpectedParameters = ' -ServerObject <Server> -Name <string> -Path <string> -MaximumFiles <uint> [-AuditFilter <string>] [-OnFailure <string>] [-QueueDelay <uint>] [-AuditGuid <string>] [-Force] [-Refresh] [-PassThru] [-ReserveDiskSpace] [- WhatIf] [-Confirm] [<CommonParameters>]'
68+ MockExpectedParameters = ' -ServerObject <Server> -Name <string> -Path <string> -MaximumFiles <uint> [-AuditFilter <string>] [-OnFailure <string>] [-QueueDelay <uint>] [-AuditGuid <string>] [-Force] [-Refresh] [-PassThru] [-WhatIf] [-Confirm] [<CommonParameters>]'
6969 }
7070 @ {
7171 MockParameterSetName = ' FileWithMaxRolloverFiles'
@@ -493,74 +493,6 @@ Describe 'New-SqlDscAudit' -Tag 'Public' {
493493 }
494494 }
495495
496- Context ' When passing file audit optional parameters MaximumFiles and ReserveDiskSpace' {
497- BeforeAll {
498- $script :mockCreateAuditObject = $null
499-
500- Mock - CommandName New-Object - ParameterFilter {
501- $TypeName -eq ' Microsoft.SqlServer.Management.Smo.Audit'
502- } - MockWith {
503- <#
504- The Audit object is created in the script scope so that the
505- properties can be validated.
506- #>
507- $script :mockCreateAuditObject = New-Object - TypeName ' Microsoft.SqlServer.Management.Smo.Audit' - ArgumentList @ (
508- $PesterBoundParameters.ArgumentList [0 ],
509- $PesterBoundParameters.ArgumentList [1 ]
510- ) |
511- Add-Member - MemberType ' ScriptMethod' - Name ' Create' - Value {
512- $script :mockMethodCreateCallCount += 1
513- } - PassThru - Force
514-
515- return $script :mockCreateAuditObject
516- }
517-
518- Mock - CommandName Get-SqlDscAudit
519-
520- $mockServerObject = New-Object - TypeName ' Microsoft.SqlServer.Management.Smo.Server'
521- $mockServerObject.InstanceName = ' TestInstance'
522-
523- $mockDefaultParameters = @ {
524- ServerObject = $mockServerObject
525- Name = ' Log1'
526- Path = Get-TemporaryFolder
527- Force = $true
528- }
529- }
530-
531- BeforeEach {
532- $script :mockMethodCreateCallCount = 0
533- }
534-
535- It ' Should call the mocked method and have correct values in the object' {
536- New-SqlDscAudit - MaximumFiles 2 - ReserveDiskSpace @mockDefaultParameters
537-
538- # This is the object created by the mock and modified by the command.
539- $mockCreateAuditObject.Name | Should - Be ' Log1'
540- $mockCreateAuditObject.DestinationType | Should - Be ' File'
541- $mockCreateAuditObject.FilePath | Should - Be (Get-TemporaryFolder )
542- $mockCreateAuditObject.MaximumFiles | Should - Be 2
543- $mockCreateAuditObject.ReserveDiskSpace | Should - BeTrue
544-
545- $mockMethodCreateCallCount | Should - Be 1
546- }
547-
548- Context ' When ReserveDiskSpace is set to $false' {
549- It ' Should call the mocked method and have correct values in the object' {
550- New-SqlDscAudit - MaximumFiles 2 - ReserveDiskSpace:$false @mockDefaultParameters
551-
552- # This is the object created by the mock and modified by the command.
553- $mockCreateAuditObject.Name | Should - Be ' Log1'
554- $mockCreateAuditObject.DestinationType | Should - Be ' File'
555- $mockCreateAuditObject.FilePath | Should - Be (Get-TemporaryFolder )
556- $mockCreateAuditObject.MaximumFiles | Should - Be 2
557- $mockCreateAuditObject.ReserveDiskSpace | Should - BeFalse
558-
559- $mockMethodCreateCallCount | Should - Be 1
560- }
561- }
562- }
563-
564496 Context ' When passing file audit optional parameters MaximumRolloverFiles' {
565497 BeforeAll {
566498 $script :mockCreateAuditObject = $null
0 commit comments