Tests/Unit/Public/Support/CallQueue/Checkpoint-TeamsCallQueuePrompt.Tests.ps1
# Module: Orbit.Teams # Function: Test # Author: David Eberhardt # Updated: 03-JUN 2023 # Script Analyzer Exceptions #[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUserDeclaredVarsMoreThanAssignments', '', Justification = 'Context Boundaries')] # Unit Tests Describe -Tags ('Unit', 'Acceptance') "Function '$(((Split-Path -Leaf $PsCommandPath) -replace '\.Tests\.', '.') -replace '\.ps1', '')'" { InModuleScope -ModuleName 'Orbit.Teams' { BeforeAll { # Mocking basic connection commands to avoid connectivity related errors Mock Assert-GraphConnection -MockWith { $true } Mock Test-GraphConnection -MockWith { $true } Mock Assert-MicrosoftTeamsConnection -MockWith { $true } Mock Test-MicrosoftTeamsConnection -MockWith { $true } Mock Get-CsAutoAttendantSupportedLanguage { return $LanguageObjectENUS } $AudiofileIdMatch = '^([a-f0-9]{32})$' # used to validate the Value of AudioFile IDs # Splatting Parameters $Params = @{ WarningAction = 'SilentlyContinue' InformationAction = 'SilentlyContinue' } # Dot Sourcing Mock Objects . "$(Split-Path -Parent ((Split-Path -Parent $PsScriptRoot) -split 'Tests')[0])\Orbit\Tests\Testing-MockedObjects.ps1" } Context 'Text-to-Speech' { It 'should return a TextToSpeechPrompt for Greeting' { $String = 'Welcome to Contoso' $Prompt = Checkpoint-TeamsCallQueuePrompt -Prompt Greeting -String $String @params $Prompt.Type | Should -Be 'TextToSpeechPrompt' $Prompt.Parameter | Should -Be 'WelcomeTextToSpeechPrompt' $Prompt.Prompt | Should -Be 'Greeting' $Prompt.Value | Should -Be $String } It 'should throw an error for a TextToSpeechPrompt for MusicOnHold' { # MusicOnHold - this should throw an error { Checkpoint-TeamsCallQueuePrompt -Prompt MusicOnHold -String 'This should throw' @params } | Should -Throw } It 'should return a TextToSpeechPrompt for OverflowPrompt' { $String = 'There are too many people waiting' $Prompt = Checkpoint-TeamsCallQueuePrompt -Prompt OverflowPrompt -String $String @params $Prompt.Type | Should -Be 'TextToSpeechPrompt' $Prompt.Parameter | Should -Be 'Overflow*TextToSpeechPrompt' $Prompt.Prompt | Should -Be 'OverflowPrompt' $Prompt.Value | Should -Be $String } It 'should return a TextToSpeechPrompt for TimeoutPrompt' { $String = 'Sorry, we are busy' $Prompt = Checkpoint-TeamsCallQueuePrompt -Prompt TimeoutPrompt -String $String @params $Prompt.Type | Should -Be 'TextToSpeechPrompt' $Prompt.Parameter | Should -Be 'Timeout*TextToSpeechPrompt' $Prompt.Prompt | Should -Be 'TimeoutPrompt' $Prompt.Value | Should -Be $String } } Context 'Audio File' { BeforeEach { Mock Assert-TeamsAudioFile -MockWith { $true } Mock Import-TeamsAudioFile { return $AudioFile1 } $String = 'C:\Temp\file.mp3' } It 'should return a AudioFilePrompt for Greeting' { $Prompt = Checkpoint-TeamsCallQueuePrompt -Prompt Greeting -String $String @params $Prompt.Type | Should -Be 'AudioFilePrompt' $Prompt.Parameter | Should -Be 'WelcomeMusicAudioFileId' $Prompt.Prompt | Should -Be 'Greeting' $Prompt.Value | Should -Match $AudiofileIdMatch } It 'should return a AudioFilePrompt for MusicOnHold' { $Prompt = Checkpoint-TeamsCallQueuePrompt -Prompt MusicOnHold -String $String @params $Prompt.Type | Should -Be 'AudioFilePrompt' $Prompt.Parameter | Should -Be 'MusicOnHoldAudioFileId' $Prompt.Prompt | Should -Be 'MusicOnHold' $Prompt.Value | Should -Match $AudiofileIdMatch } It 'should return a AudioFilePrompt for NoAgentPrompt' { $Prompt = Checkpoint-TeamsCallQueuePrompt -Prompt NoAgentPrompt -String $String @params $Prompt.Type | Should -Be 'AudioFilePrompt' $Prompt.Parameter | Should -Be 'NoAgent*AudioFilePrompt' $Prompt.Prompt | Should -Be 'NoAgentPrompt' $Prompt.Value | Should -Match $AudiofileIdMatch } } Context 'Execution' { # Code Logic } Context 'Output' { #Properties, Values, Types } } } |