Functions/Compare-MSPCompleteUser.Tests.ps1
describe "BitTitan.Runbooks.MSPComplete/Compare-MSPCompleteUser" -Tag "module", "unit" { # Import the function to test . "$($PSScriptRoot)\Compare-MSPCompleteUser.ps1" it "returns true for identical objects" { # Declare the function inputs $referenceUser = [PSCustomObject]@{ FirstName = "firstName" LastName = "lastName" DisplayName = "displayName" FullName = "fullName" PrimaryEmailAddress = "primaryEmailAddress" UserPrincipalName = "userPrincipalName" ExtendedProperties = @{ AddressLine1 = "addressLine1" AddressLine2 = "addressLine2" City = "city" StateOrProvince = "stateOrProvince" PostalOrZipCode = "postalOrZipCode" CountryOrRegion = "countryOrRegion" MobilePhoneNumber = "mobilePhoneNumber" TelephoneNumber = "telephoneNumber" CompanyName = "companyName" Department = "department" JobTitle = "jobTitle" Salutation = "salutation" ManagerEmailAddress = "managerEmailAddress" } } # Call the function $output = Compare-MSPCompleteUser -ReferenceUser $referenceUser -ComparisonUser $referenceUser ` -ErrorAction SilentlyContinue -ErrorVariable errorVariable # Verify the output $errorVariable | Should BeNullOrEmpty $output | Should Be $true } it "returns false for objects with different property values" { # Declare the function inputs $referenceUser = [PSCustomObject]@{ FirstName = "firstName" LastName = "lastName" DisplayName = "displayName" FullName = "fullName" PrimaryEmailAddress = "primaryEmailAddress" UserPrincipalName = "userPrincipalName" ExtendedProperties = @{ AddressLine1 = "addressLine1" AddressLine2 = "addressLine2" City = "city" StateOrProvince = "stateOrProvince" PostalOrZipCode = "postalOrZipCode" CountryOrRegion = "countryOrRegion" MobilePhoneNumber = "mobilePhoneNumber" TelephoneNumber = "telephoneNumber" CompanyName = "companyName" Department = "department" JobTitle = "jobTitle" Salutation = "salutation" ManagerEmailAddress = "managerEmailAddress" } } $comparisonUser = [PSCustomObject]@{ FirstName = "firstName1" LastName = "lastName" DisplayName = "displayName" FullName = "fullName" PrimaryEmailAddress = "primaryEmailAddress" UserPrincipalName = "userPrincipalName" ExtendedProperties = @{ AddressLine1 = "addressLine1" AddressLine2 = "addressLine2" City = "city" StateOrProvince = "stateOrProvince" PostalOrZipCode = "postalOrZipCode" CountryOrRegion = "countryOrRegion" MobilePhoneNumber = "mobilePhoneNumber" TelephoneNumber = "telephoneNumber" CompanyName = "companyName" Department = "department" JobTitle = "jobTitle" Salutation = "salutation" ManagerEmailAddress = "managerEmailAddress" } } # Call the function $output = Compare-MSPCompleteUser -ReferenceUser $referenceUser -ComparisonUser $comparisonUser ` -ErrorAction SilentlyContinue -ErrorVariable errorVariable # Verify the output $errorVariable | Should Not BeNullOrEmpty $output | Should Be $false # Declare the function inputs $comparisonUser = [PSCustomObject]@{ FirstName = "firstName" LastName = "lastName" DisplayName = "displayName" FullName = "fullName" PrimaryEmailAddress = "primaryEmailAddress" UserPrincipalName = "userPrincipalName" ExtendedProperties = @{ AddressLine1 = "addressLine1" AddressLine2 = "addressLine2" City = "city" StateOrProvince = "stateOrProvince" PostalOrZipCode = "postalOrZipCode" CountryOrRegion = "countryOrRegion" MobilePhoneNumber = "mobilePhoneNumber" TelephoneNumber = "telephoneNumber" CompanyName = "companyName" Department = "department" JobTitle = "jobTitle" Salutation = "salutation" ManagerEmailAddress = "managerEmailAddress1" } } # Call the function $output = Compare-MSPCompleteUser -ReferenceUser $referenceUser -ComparisonUser $comparisonUser ` -ErrorAction SilentlyContinue -ErrorVariable errorVariable # Verify the output $errorVariable | Should Not BeNullOrEmpty $output | Should Be $false } } |