@@ -333,3 +333,71 @@ Describe 'SqlRSSetup\Set()' -Tag 'Set' {
333333 }
334334 }
335335}
336+
337+ Describe ' SqlRSSetup\GetCurrentState()' - Tag ' GetCurrentState' {
338+ Context ' When current state is missing SSRS instance' {
339+ BeforeAll {
340+ InModuleScope - ScriptBlock {
341+ $script :mockSqlRSSetupInstance = [SqlRSSetup ] @ {
342+ InstanceName = ' SSRS'
343+ } |
344+ Add-Member - Force - MemberType ' ScriptMethod' - Name ' GetServerObject' - Value {
345+ return New-Object - TypeName ' Microsoft.SqlServer.Management.Smo.Server'
346+ } - PassThru
347+ }
348+
349+ Mock - CommandName Get-SqlDscRSSetupConfiguration
350+ }
351+
352+ It ' Should return the correct values' {
353+ InModuleScope - ScriptBlock {
354+ $currentState = $script :mockSqlRSSetupInstance.GetCurrentState (
355+ @ {
356+ Name = ' InstanceName'
357+ InstanceName = ' SSRS'
358+ }
359+ )
360+
361+ $currentState.InstanceName | Should - BeNullOrEmpty
362+ }
363+ }
364+ }
365+
366+ Context ' When current state have an SSRS instance' {
367+ BeforeAll {
368+ InModuleScope - ScriptBlock {
369+ $script :mockSqlRSSetupInstance = [SqlRSSetup ] @ {
370+ InstanceName = ' SSRS'
371+ } |
372+ Add-Member - Force - MemberType ' ScriptMethod' - Name ' GetServerObject' - Value {
373+ return New-Object - TypeName ' Microsoft.SqlServer.Management.Smo.Server'
374+ } - PassThru
375+ }
376+
377+ Mock - CommandName Get-SqlDscRSSetupConfiguration - MockWith {
378+ return @ (
379+ [PSCustomObject ] @ {
380+ InstanceName = ' SSRS'
381+ InstallFolder = ' C:\Program Files\SSRS'
382+ ProductVersion = ' 15.0.2000.5'
383+ }
384+ )
385+ }
386+ }
387+
388+ It ' Should return the correct values' {
389+ InModuleScope - ScriptBlock {
390+ $currentState = $script :mockSqlRSSetupInstance.GetCurrentState (
391+ @ {
392+ Name = ' InstanceName'
393+ InstanceName = ' SSRS'
394+ }
395+ )
396+
397+ $currentState.InstanceName | Should - Be ' SSRS'
398+ $currentState.ProductVersion | Should - Be ' 15.0.2000.5'
399+ $currentState.InstallFolder | Should - Be ' C:\Program Files\SSRS'
400+ }
401+ }
402+ }
403+ }
0 commit comments