Functions/Compare-MSPCompleteGroup.Tests.ps1
describe "BitTitan.Runbooks.MSPComplete/Compare-MSPCompleteGroup" -Tag "module", "unit" { # Import the function to test . "$($PSScriptRoot)\Compare-MSPCompleteGroup.ps1" it "returns true for identical objects" { # Declare the function inputs $referenceGroup = [PSCustomObject]@{ Name = "name" Members = @( "member1@domain.com" ) ExtendedProperties = @{ PrimaryEmailAddress = "primaryemailaddress@domain.com" } } # Call the function $output = Compare-MSPCompleteGroup -ReferenceGroup $referenceGroup -ComparisonGroup $referenceGroup ` -ErrorAction SilentlyContinue -ErrorVariable errorVariable # Verify the output $errorVariable | Should BeNullOrEmpty $output | Should Be $true } it "returns false for groups with different property values" { # Declare the function inputs $referenceGroup = [PSCustomObject]@{ Name = "name" Members = @( "member1@domain.com" ) ExtendedProperties = @{ PrimaryEmailAddress = "primaryemailaddress@domain.com" } } $comparisonGroup = [PSCustomObject]@{ Name = "name2" Members = @( "member1@domain.com" ) ExtendedProperties = @{ PrimaryEmailAddress = "primaryemailaddress@domain.com" } } # Call the function $output = Compare-MSPCompleteGroup -ReferenceGroup $referenceGroup -ComparisonGroup $comparisonGroup ` -ErrorAction SilentlyContinue -ErrorVariable errorVariable # Verify the output $errorVariable | Should Not BeNullOrEmpty $output | Should Be $false } it "returns false for groups with different extended property values" { # Declare the function inputs $referenceGroup = [PSCustomObject]@{ Name = "name" Members = @( "member1@domain.com" ) ExtendedProperties = @{ PrimaryEmailAddress = "primaryemailaddress@domain.com" } } $comparisonGroup = [PSCustomObject]@{ Name = "name" Members = @( "member1@domain.com" ) ExtendedProperties = @{ PrimaryEmailAddress = "primaryemailaddress2@domain.com" } } # Call the function $output = Compare-MSPCompleteGroup -ReferenceGroup $referenceGroup -ComparisonGroup $comparisonGroup ` -ErrorAction SilentlyContinue -ErrorVariable errorVariable # Verify the output $errorVariable | Should Not BeNullOrEmpty $output | Should Be $false } it "returns false for groups with different members" { # Declare the function inputs $referenceGroup = [PSCustomObject]@{ Name = "name" Members = @( "member1@domain.com" ) ExtendedProperties = @{ PrimaryEmailAddress = "primaryemailaddress@domain.com" } } $comparisonGroup = [PSCustomObject]@{ Name = "name" Members = @( "member2@domain.com" ) ExtendedProperties = @{ PrimaryEmailAddress = "primaryemailaddress@domain.com" } } # Call the function $output = Compare-MSPCompleteGroup -ReferenceGroup $referenceGroup -ComparisonGroup $comparisonGroup ` -ErrorAction SilentlyContinue -ErrorVariable errorVariable # Verify the output $errorVariable | Should Not BeNullOrEmpty $output | Should Be $false } } |