@@ -647,6 +647,78 @@ public async Task PlayInvalidFileSourceWithPlayMediaTest()
647647 }
648648 }
649649
650+ [ RecordedTest ]
651+ public async Task PlayInvalidAndValidFileSourceWithPlayMediaTest ( )
652+ {
653+ // create caller and receiver
654+ CommunicationUserIdentifier user = await CreateIdentityUserAsync ( ) . ConfigureAwait ( false ) ;
655+ CommunicationUserIdentifier target = await CreateIdentityUserAsync ( ) . ConfigureAwait ( false ) ;
656+ CallAutomationClient client = CreateInstrumentedCallAutomationClientWithConnectionString ( user ) ;
657+ CallAutomationClient targetClient = CreateInstrumentedCallAutomationClientWithConnectionString ( target ) ;
658+ string ? callConnectionId = null ;
659+ try
660+ {
661+ try
662+ {
663+ // setup service bus
664+ var uniqueId = await ServiceBusWithNewCall ( user , target ) ;
665+ var result = await CreateAndAnswerCall ( client , targetClient , target , uniqueId , false ) ;
666+ callConnectionId = result . CallerCallConnectionId ;
667+ var participantToAdd = await CreateIdentityUserAsync ( ) . ConfigureAwait ( false ) ;
668+ var callConnection = client . GetCallConnection ( callConnectionId ) ;
669+
670+ // Assert multiple Text Source with wrong file source play failed event
671+ var playMultipleSources = new List < PlaySource > ( ) {
672+ new FileSource ( new Uri ( TestEnvironment . FileSourceUrl ) ) ,
673+ new FileSource ( new Uri ( "https://dummy.com/dummyurl.wav" ) )
674+ } ;
675+
676+ PlayOptions options = new PlayOptions ( playMultipleSources , new List < CommunicationUserIdentifier > ( ) { target } ) { OperationContext = "context" } ;
677+
678+ // Assert the Play with multiple Text Sources
679+ await callConnection . GetCallMedia ( ) . PlayAsync ( options ) . ConfigureAwait ( false ) ;
680+ var playFailedEvent = await WaitForEvent < PlayFailed > ( callConnectionId , TimeSpan . FromSeconds ( 20 ) ) ;
681+ Assert . IsNotNull ( playFailedEvent ) ;
682+ Assert . IsTrue ( playFailedEvent is PlayFailed ) ;
683+ Assert . AreEqual ( callConnectionId , ( ( PlayFailed ) playFailedEvent ! ) . CallConnectionId ) ;
684+ Assert . AreEqual ( 1 , ( ( PlayFailed ) playFailedEvent ! ) . FailedPlaySourceIndex ) ;
685+
686+ // try hangup
687+ await client . GetCallConnection ( callConnectionId ) . HangUpAsync ( true ) . ConfigureAwait ( false ) ;
688+ var disconnectedEvent = await WaitForEvent < CallDisconnected > ( callConnectionId , TimeSpan . FromSeconds ( 20 ) ) ;
689+ Assert . IsNotNull ( disconnectedEvent ) ;
690+ Assert . IsTrue ( disconnectedEvent is CallDisconnected ) ;
691+ Assert . AreEqual ( callConnectionId , ( ( CallDisconnected ) disconnectedEvent ! ) . CallConnectionId ) ;
692+
693+ try
694+ {
695+ // test get properties
696+ Response < CallConnectionProperties > properties = await client . GetCallConnection ( callConnectionId ) . GetCallConnectionPropertiesAsync ( ) . ConfigureAwait ( false ) ;
697+ }
698+ catch ( RequestFailedException ex )
699+ {
700+ if ( ex . Status == 404 )
701+ {
702+ callConnectionId = null ;
703+ return ;
704+ }
705+ }
706+ }
707+ catch ( Exception )
708+ {
709+ throw ;
710+ }
711+ }
712+ catch ( Exception ex )
713+ {
714+ Assert . Fail ( $ "Unexpected error: { ex } ") ;
715+ }
716+ finally
717+ {
718+ await CleanUpCall ( client , callConnectionId ) ;
719+ }
720+ }
721+
650722 [ RecordedTest ]
651723 public async Task PlayInvalidFileSourceWithPlayMediaAllTest ( )
652724 {
@@ -674,9 +746,8 @@ public async Task PlayInvalidFileSourceWithPlayMediaAllTest()
674746
675747 PlayToAllOptions options = new PlayToAllOptions ( playMultipleSources ) { OperationContext = "context" } ;
676748
677- // Assert the Play with multiple Text Sources
749+ // Assert the Play with invalid file source
678750 await callConnection . GetCallMedia ( ) . PlayToAllAsync ( options ) . ConfigureAwait ( false ) ;
679-
680751 var playFailedEvent = await WaitForEvent < PlayFailed > ( callConnectionId , TimeSpan . FromSeconds ( 20 ) ) ;
681752 Assert . IsNotNull ( playFailedEvent ) ;
682753 Assert . IsTrue ( playFailedEvent is PlayFailed ) ;
@@ -719,6 +790,78 @@ public async Task PlayInvalidFileSourceWithPlayMediaAllTest()
719790 }
720791 }
721792
793+ [ RecordedTest ]
794+ public async Task PlayInvalidAndInvalidFileSourceWithPlayMediaAllTest ( )
795+ {
796+ // create caller and receiver
797+ CommunicationUserIdentifier user = await CreateIdentityUserAsync ( ) . ConfigureAwait ( false ) ;
798+ CommunicationUserIdentifier target = await CreateIdentityUserAsync ( ) . ConfigureAwait ( false ) ;
799+ CallAutomationClient client = CreateInstrumentedCallAutomationClientWithConnectionString ( user ) ;
800+ CallAutomationClient targetClient = CreateInstrumentedCallAutomationClientWithConnectionString ( target ) ;
801+ string ? callConnectionId = null ;
802+ try
803+ {
804+ try
805+ {
806+ // setup service bus
807+ var uniqueId = await ServiceBusWithNewCall ( user , target ) ;
808+ var result = await CreateAndAnswerCall ( client , targetClient , target , uniqueId , false ) ;
809+ callConnectionId = result . CallerCallConnectionId ;
810+ var participantToAdd = await CreateIdentityUserAsync ( ) . ConfigureAwait ( false ) ;
811+ var callConnection = client . GetCallConnection ( callConnectionId ) ;
812+
813+ // Assert multiple Text Source with wrong file source play failed event
814+ var playMultipleSources = new List < PlaySource > ( ) {
815+ new FileSource ( new Uri ( TestEnvironment . FileSourceUrl ) ) ,
816+ new FileSource ( new Uri ( "https://dummy.com/dummyurl.wav" ) )
817+ } ;
818+
819+ PlayToAllOptions options = new PlayToAllOptions ( playMultipleSources ) { OperationContext = "context" } ;
820+
821+ // Assert the Play with multiple Text Sources
822+ await callConnection . GetCallMedia ( ) . PlayToAllAsync ( options ) . ConfigureAwait ( false ) ;
823+ var playFailedEvent = await WaitForEvent < PlayFailed > ( callConnectionId , TimeSpan . FromSeconds ( 20 ) ) ;
824+ Assert . IsNotNull ( playFailedEvent ) ;
825+ Assert . IsTrue ( playFailedEvent is PlayFailed ) ;
826+ Assert . AreEqual ( callConnectionId , ( ( PlayFailed ) playFailedEvent ! ) . CallConnectionId ) ;
827+ Assert . AreEqual ( 1 , ( ( PlayFailed ) playFailedEvent ! ) . FailedPlaySourceIndex ) ;
828+
829+ // try hangup
830+ await client . GetCallConnection ( callConnectionId ) . HangUpAsync ( true ) . ConfigureAwait ( false ) ;
831+ var disconnectedEvent = await WaitForEvent < CallDisconnected > ( callConnectionId , TimeSpan . FromSeconds ( 20 ) ) ;
832+ Assert . IsNotNull ( disconnectedEvent ) ;
833+ Assert . IsTrue ( disconnectedEvent is CallDisconnected ) ;
834+ Assert . AreEqual ( callConnectionId , ( ( CallDisconnected ) disconnectedEvent ! ) . CallConnectionId ) ;
835+
836+ try
837+ {
838+ // test get properties
839+ Response < CallConnectionProperties > properties = await client . GetCallConnection ( callConnectionId ) . GetCallConnectionPropertiesAsync ( ) . ConfigureAwait ( false ) ;
840+ }
841+ catch ( RequestFailedException ex )
842+ {
843+ if ( ex . Status == 404 )
844+ {
845+ callConnectionId = null ;
846+ return ;
847+ }
848+ }
849+ }
850+ catch ( Exception )
851+ {
852+ throw ;
853+ }
854+ }
855+ catch ( Exception ex )
856+ {
857+ Assert . Fail ( $ "Unexpected error: { ex } ") ;
858+ }
859+ finally
860+ {
861+ await CleanUpCall ( client , callConnectionId ) ;
862+ }
863+ }
864+
722865 [ Ignore ( reason : "Receiving bad request on the cognitive service will investigate and enable" ) ]
723866 [ RecordedTest ]
724867 public async Task DtmfRecognizeWithMultipleSourcesTest ( )
0 commit comments