diff --git a/sdk/communication/Azure.Communication.Calling.Server/src/CallClient.cs b/sdk/communication/Azure.Communication.Calling.Server/src/CallClient.cs index 73f67452249f..28da37c09871 100644 --- a/sdk/communication/Azure.Communication.Calling.Server/src/CallClient.cs +++ b/sdk/communication/Azure.Communication.Calling.Server/src/CallClient.cs @@ -248,15 +248,16 @@ public virtual Response HangupCall(string callLegId, CancellationToken cancellat /// Cancel all media operations in the call. /// The call leg id. + /// The operation context. /// The cancellation token. /// The server returned an error. See for details returned from the server. - public virtual async Task> CancelAllMediaOperationsAsync(string callLegId, CancellationToken cancellationToken = default) + public virtual async Task> CancelAllMediaOperationsAsync(string callLegId, string operationContext = null, CancellationToken cancellationToken = default) { using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(CallClient)}.{nameof(CancelAllMediaOperationsAsync)}"); scope.Start(); try { - return await RestClient.CancelAllMediaOperationsAsync(callLegId, cancellationToken: cancellationToken).ConfigureAwait(false); + return await RestClient.CancelAllMediaOperationsAsync(callLegId, operationContext, cancellationToken: cancellationToken).ConfigureAwait(false); } catch (Exception ex) { @@ -267,15 +268,16 @@ public virtual async Task> CancelAllM /// Cancel all media operations in the call. /// The call leg id. + /// The operation context. /// The cancellation token. /// The server returned an error. See for details returned from the server. - public virtual Response CancelAllMediaOperations(string callLegId, CancellationToken cancellationToken = default) + public virtual Response CancelAllMediaOperations(string callLegId, string operationContext = null, CancellationToken cancellationToken = default) { using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(CallClient)}.{nameof(CancelAllMediaOperations)}"); scope.Start(); try { - return RestClient.CancelAllMediaOperations(callLegId, cancellationToken: cancellationToken); + return RestClient.CancelAllMediaOperations(callLegId, operationContext, cancellationToken: cancellationToken); } catch (Exception ex) { diff --git a/sdk/communication/Azure.Communication.Calling.Server/tests/ServerCallingClients/CallingServerClientsTests.cs b/sdk/communication/Azure.Communication.Calling.Server/tests/ServerCallingClients/CallingServerClientsTests.cs index aee2548e2aa4..3a7703634662 100644 --- a/sdk/communication/Azure.Communication.Calling.Server/tests/ServerCallingClients/CallingServerClientsTests.cs +++ b/sdk/communication/Azure.Communication.Calling.Server/tests/ServerCallingClients/CallingServerClientsTests.cs @@ -85,24 +85,25 @@ public async Task HangupCallAsyncOverload_Passes(string expectedCallLegId) Assert.AreEqual(expectedResponse, actualResponse); } - [TestCaseSource(nameof(TestData_CancelMediaOperations))] - public async Task CancelMediaOperationsAsyncOverload_Passes(string expectedCallLegId) + [TestCaseSource(nameof(TestData_CancelAllMediaOperations))] + public async Task CancelMediaOperationsAsyncOverload_Passes(string expectedCallLegId, string expectedOperationContext) { Mock mockClient = new Mock() { CallBase = true }; Response? expectedResponse = default; CancellationToken cancellationToken = new CancellationTokenSource().Token; - var callExpression = BuildExpression(x => x.CancelAllMediaOperationsAsync(It.IsAny(), It.IsAny())); + var callExpression = BuildExpression(x => x.CancelAllMediaOperationsAsync(It.IsAny(), It.IsAny(), It.IsAny())); mockClient .Setup(callExpression) .ReturnsAsync((string callLegId, string operationContext, CancellationToken token) => { Assert.AreEqual(expectedCallLegId, callLegId); + Assert.AreEqual(expectedOperationContext, operationContext); Assert.AreEqual(cancellationToken, token); return expectedResponse = new Mock>().Object; }); - Response actualResponse = await mockClient.Object.CancelAllMediaOperationsAsync(expectedCallLegId, cancellationToken); + Response actualResponse = await mockClient.Object.CancelAllMediaOperationsAsync(expectedCallLegId, expectedOperationContext, cancellationToken); mockClient.Verify(callExpression, Times.Once()); Assert.AreEqual(expectedResponse, actualResponse); @@ -161,7 +162,7 @@ public async Task PlayAudioAsyncOverload_Passes(string expectedCallLegId, Uri ex } [TestCaseSource(nameof(TestData_InviteParticipants))] - public async Task InviteParticipantsAsyncOverload_Passes(string expectedCallLegId, CommunicationIdentifier expectedParticipant, string expectedOperationContext, string? expectedAlternateCallerId = null) + public async Task InviteParticipantsAsyncOverload_Passes(string expectedCallLegId, CommunicationIdentifier expectedParticipant, string expectedAlternateCallerId, string expectedOperationContext) { Mock mockClient = new Mock() { CallBase = true }; Response? expectedResponse = default; @@ -170,7 +171,7 @@ public async Task InviteParticipantsAsyncOverload_Passes(string expectedCallLegI mockClient .Setup(callExpression) - .ReturnsAsync((string callLegId, IEnumerable participants, string operationContext, string alternateCallerId, CancellationToken token) => + .ReturnsAsync((string callLegId, CommunicationIdentifier participants, string operationContext, string alternateCallerId, CancellationToken token) => { Assert.AreEqual(expectedCallLegId, callLegId); Assert.AreEqual(expectedParticipant, participants); @@ -221,11 +222,12 @@ public async Task RemoveParticipantAsyncOverload_Passes(string expectedCallLegId }; } - private static IEnumerable TestData_CancelMediaOperations() + private static IEnumerable TestData_CancelAllMediaOperations() { return new List(){ new object?[] { "4ab31d78-a189-4e50-afaa-f9610975b6cb", + "af82480b-6df3-4f4c-a58c-a6a78b614b36" }, }; } @@ -275,15 +277,15 @@ public async Task RemoveParticipantAsyncOverload_Passes(string expectedCallLegId return new List(){ new object?[] { "4ab31d78-a189-4e50-afaa-f9610975b6cb", - new List() { new PhoneNumberIdentifier("+14052882361"), new CommunicationUserIdentifier("50125645-5dca-4193-877d-4608ed2a0bc2"), }, - "af82480b-6df3-4f4c-a58c-a6a78b614b36", - "+14052882362" + new CommunicationUserIdentifier("50125645-5dca-4193-877d-4608ed2a0bc2"), + "+14052882362", + "af82480b-6df3-4f4c-a58c-a6a78b614b36" }, new object?[] { "4ab31d78-a189-4e50-afaa-f9610975b6cb", - new List() { new PhoneNumberIdentifier("+14052882361"), new CommunicationUserIdentifier("50125645-5dca-4193-877d-4608ed2a0bc2"), }, - "af82480b-6df3-4f4c-a58c-a6a78b614b36", - null + new CommunicationUserIdentifier("50125645-5dca-4193-877d-4608ed2a0bc2"), + null, + "af82480b-6df3-4f4c-a58c-a6a78b614b36" }, }; }