From c310ffe141c521e1547e7c13a06a2aa4aa3822c0 Mon Sep 17 00:00:00 2001 From: Zihan Zhang <43592314+zihzhan-msft@users.noreply.github.com> Date: Thu, 10 Jun 2021 15:54:28 -0700 Subject: [PATCH] Zihzhan/fix (#21805) * Update Snippet and Export-API. * remove calloption override in servercall client. * Nit for params and arguments handling. * Merge Downloader updates. * Merge Downloader updates test cases. * Update AutoGen Content. * Nit clean on Unit Tests. * Updating and renaming. --- .../README.md | 4 +- ...munication.CallingServer.netstandard2.0.cs | 71 +++++------- .../samples/Sample1_CreateCall.md | 4 +- .../samples/Sample1_CreateCallAsync.md | 4 +- .../CallConnectionTests.cs | 73 +++++++----- .../CallingServerClients/ServerCallTests.cs | 109 ++++++++---------- 6 files changed, 126 insertions(+), 139 deletions(-) diff --git a/sdk/communication/Azure.Communication.CallingServer/README.md b/sdk/communication/Azure.Communication.CallingServer/README.md index b47aecd6e8f91..7cfed06cb8e92 100644 --- a/sdk/communication/Azure.Communication.CallingServer/README.md +++ b/sdk/communication/Azure.Communication.CallingServer/README.md @@ -41,8 +41,8 @@ To make an outbound call, call the `CreateCallConnection` or `CreateCallConnecti ```C# Snippet:Azure_Communication_Call_Tests_CreateCallOptions var createCallOption = new CreateCallOptions( new Uri(TestEnvironment.AppCallbackUrl), - new List { CallModality.Audio }, - new List + new[] { CallModality.Audio }, + new[] { EventSubscriptionType.ParticipantsUpdated, EventSubscriptionType.DtmfReceived diff --git a/sdk/communication/Azure.Communication.CallingServer/api/Azure.Communication.CallingServer.netstandard2.0.cs b/sdk/communication/Azure.Communication.CallingServer/api/Azure.Communication.CallingServer.netstandard2.0.cs index 8328de08dfced..a228b741b26ad 100644 --- a/sdk/communication/Azure.Communication.CallingServer/api/Azure.Communication.CallingServer.netstandard2.0.cs +++ b/sdk/communication/Azure.Communication.CallingServer/api/Azure.Communication.CallingServer.netstandard2.0.cs @@ -1,29 +1,19 @@ namespace Azure.Communication.CallingServer { - public static partial class AzureCommunicationCallingServerServiceModelFactory - { - public static Azure.Communication.CallingServer.CancelAllMediaOperationsResponse CancelAllMediaOperationsResponse(string id = null, Azure.Communication.CallingServer.OperationStatus? status = default(Azure.Communication.CallingServer.OperationStatus?), string operationContext = null, Azure.Communication.CallingServer.ResultInfo resultInfo = null) { throw null; } - public static Azure.Communication.CallingServer.CreateCallResponse CreateCallResponse(string callConnectionId = null) { throw null; } - public static Azure.Communication.CallingServer.GetCallRecordingStateResponse GetCallRecordingStateResponse(Azure.Communication.CallingServer.CallRecordingState? recordingState = default(Azure.Communication.CallingServer.CallRecordingState?)) { throw null; } - public static Azure.Communication.CallingServer.JoinCallResponse JoinCallResponse(string callConnectionId = null) { throw null; } - public static Azure.Communication.CallingServer.PlayAudioResponse PlayAudioResponse(string id = null, Azure.Communication.CallingServer.OperationStatus? status = default(Azure.Communication.CallingServer.OperationStatus?), string operationContext = null, Azure.Communication.CallingServer.ResultInfo resultInfo = null) { throw null; } - public static Azure.Communication.CallingServer.ResultInfo ResultInfo(int? code = default(int?), int? subcode = default(int?), string message = null) { throw null; } - public static Azure.Communication.CallingServer.StartCallRecordingResponse StartCallRecordingResponse(string recordingId = null) { throw null; } - } public partial class CallConnection { protected CallConnection() { } public virtual string CallConnectionId { get { throw null; } } public virtual Azure.Response AddParticipant(Azure.Communication.CommunicationIdentifier participant, string alternateCallerId = null, string operationContext = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual System.Threading.Tasks.Task AddParticipantAsync(Azure.Communication.CommunicationIdentifier participant, string alternateCallerId = null, string operationContext = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - public virtual Azure.Response CancelAllMediaOperations(string operationContext = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - public virtual System.Threading.Tasks.Task> CancelAllMediaOperationsAsync(string operationContext = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response CancelAllMediaOperations(string operationContext = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> CancelAllMediaOperationsAsync(string operationContext = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual Azure.Response Hangup(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual System.Threading.Tasks.Task HangupAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - public virtual Azure.Response PlayAudio(Azure.Communication.CallingServer.PlayAudioOptions options, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - public virtual Azure.Response PlayAudio(System.Uri audioFileUri, bool? loop, string audioFileId, System.Uri callbackUri, string operationContext = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - public virtual System.Threading.Tasks.Task> PlayAudioAsync(Azure.Communication.CallingServer.PlayAudioOptions options, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - public virtual System.Threading.Tasks.Task> PlayAudioAsync(System.Uri audioFileUri, bool? loop, string audioFileId, System.Uri callbackUri, string operationContext = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response PlayAudio(Azure.Communication.CallingServer.PlayAudioOptions options, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response PlayAudio(System.Uri audioFileUri, bool? loop, string audioFileId, System.Uri callbackUri, string operationContext = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> PlayAudioAsync(Azure.Communication.CallingServer.PlayAudioOptions options, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> PlayAudioAsync(System.Uri audioFileUri, bool? loop, string audioFileId, System.Uri callbackUri, string operationContext = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual Azure.Response RemoveParticipant(string participantId, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual System.Threading.Tasks.Task RemoveParticipantAsync(string participantId, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } } @@ -66,18 +56,15 @@ public partial class CallingServerClient { protected CallingServerClient() { } public CallingServerClient(string connectionString, Azure.Communication.CallingServer.CallingServerClientOptions options = null) { } - public CallingServerClient(System.Uri endpoint, Azure.AzureKeyCredential keyCredential, Azure.Communication.CallingServer.CallingServerClientOptions options = null) { } - public CallingServerClient(System.Uri endpoint, Azure.Core.TokenCredential tokenCredential, Azure.Communication.CallingServer.CallingServerClientOptions options = null) { } public virtual Azure.Response CreateCallConnection(Azure.Communication.CommunicationIdentifier source, System.Collections.Generic.IEnumerable targets, Azure.Communication.CallingServer.CreateCallOptions options, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual System.Threading.Tasks.Task> CreateCallConnectionAsync(Azure.Communication.CommunicationIdentifier source, System.Collections.Generic.IEnumerable targets, Azure.Communication.CallingServer.CreateCallOptions options, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual Azure.Communication.CallingServer.CallConnection GetCallConnection(string callConnectionId) { throw null; } public virtual Azure.Communication.CallingServer.ServerCall InitializeServerCall(string serverCallId) { throw null; } - public virtual Azure.Response JoinCallConnection(string serverCallId, Azure.Communication.CommunicationIdentifier source, Azure.Communication.CallingServer.JoinCallOptions callOptions, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - public virtual System.Threading.Tasks.Task> JoinCallConnectionAsync(string serverCallId, Azure.Communication.CommunicationIdentifier source, Azure.Communication.CallingServer.JoinCallOptions callOptions, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response JoinCall(string serverCallId, Azure.Communication.CommunicationIdentifier source, Azure.Communication.CallingServer.JoinCallOptions callOptions, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> JoinCallAsync(string serverCallId, Azure.Communication.CommunicationIdentifier source, Azure.Communication.CallingServer.JoinCallOptions callOptions, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } } public partial class CallingServerClientOptions : Azure.Core.ClientOptions { - public const Azure.Communication.CallingServer.CallingServerClientOptions.ServiceVersion LatestVersion = Azure.Communication.CallingServer.CallingServerClientOptions.ServiceVersion.V2021_06_15_Preview; public CallingServerClientOptions(Azure.Communication.CallingServer.CallingServerClientOptions.ServiceVersion version = Azure.Communication.CallingServer.CallingServerClientOptions.ServiceVersion.V2021_06_15_Preview) { } public enum ServiceVersion { @@ -154,9 +141,14 @@ public CallRecordingStateChangeEvent() { } public Azure.Communication.CallingServer.CallRecordingState? State { get { throw null; } set { } } public static Azure.Communication.CallingServer.CallRecordingStateChangeEvent Deserialize(string content) { throw null; } } - public partial class CancelAllMediaOperationsResponse + public partial class CallRecordingStateResult + { + internal CallRecordingStateResult() { } + public Azure.Communication.CallingServer.CallRecordingState? RecordingState { get { throw null; } } + } + public partial class CancelAllMediaOperationsResult { - internal CancelAllMediaOperationsResponse() { } + internal CancelAllMediaOperationsResult() { } public string Id { get { throw null; } } public string OperationContext { get { throw null; } } public Azure.Communication.CallingServer.ResultInfo ResultInfo { get { throw null; } } @@ -196,9 +188,9 @@ public CreateCallOptions(System.Uri callbackUri, System.Collections.Generic.IEnu public System.Collections.Generic.IList RequestedMediaTypes { get { throw null; } } public string Subject { get { throw null; } set { } } } - public partial class CreateCallResponse + public partial class CreateCallResult { - internal CreateCallResponse() { } + internal CreateCallResult() { } public string CallConnectionId { get { throw null; } } } public static partial class DownloadExtentions @@ -228,11 +220,6 @@ public static partial class DownloadExtentions public static bool operator !=(Azure.Communication.CallingServer.EventSubscriptionType left, Azure.Communication.CallingServer.EventSubscriptionType right) { throw null; } public override string ToString() { throw null; } } - public partial class GetCallRecordingStateResponse - { - internal GetCallRecordingStateResponse() { } - public Azure.Communication.CallingServer.CallRecordingState? RecordingState { get { throw null; } } - } public partial class InviteParticipantsResultEvent : Azure.Communication.CallingServer.CallingServerEventBase { public InviteParticipantsResultEvent() { } @@ -249,9 +236,9 @@ public JoinCallOptions(System.Uri callbackUri, System.Collections.Generic.IEnume public System.Collections.Generic.IList RequestedMediaTypes { get { throw null; } } public string Subject { get { throw null; } set { } } } - public partial class JoinCallResponse + public partial class JoinCallResult { - internal JoinCallResponse() { } + internal JoinCallResult() { } public string CallConnectionId { get { throw null; } } } [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] @@ -290,9 +277,9 @@ public PlayAudioOptions() { } public bool? Loop { get { throw null; } set { } } public string OperationContext { get { throw null; } set { } } } - public partial class PlayAudioResponse + public partial class PlayAudioResult { - internal PlayAudioResponse() { } + internal PlayAudioResult() { } public string Id { get { throw null; } } public string OperationContext { get { throw null; } } public Azure.Communication.CallingServer.ResultInfo ResultInfo { get { throw null; } } @@ -318,24 +305,24 @@ public partial class ServerCall protected ServerCall() { } public virtual Azure.Response AddParticipant(Azure.Communication.CommunicationIdentifier participant, System.Uri callbackUri, string alternateCallerId = null, string operationContext = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual System.Threading.Tasks.Task AddParticipantAsync(Azure.Communication.CommunicationIdentifier participant, System.Uri callbackUri, string alternateCallerId = null, string operationContext = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - public virtual Azure.Response GetRecordingState(string recordingId, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - public virtual System.Threading.Tasks.Task> GetRecordingStateAsync(string recordingId, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response GetRecordingState(string recordingId, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> GetRecordingStateAsync(string recordingId, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual Azure.Response PauseRecording(string recordingId, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual System.Threading.Tasks.Task PauseRecordingAsync(string recordingId, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - public virtual Azure.Response PlayAudio(System.Uri audioFileUri, string audioFileId, System.Uri callbackUri, string operationContext = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - public virtual System.Threading.Tasks.Task> PlayAudioAsync(System.Uri audioFileUri, string audioFileId, System.Uri callbackUri, string operationContext = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response PlayAudio(System.Uri audioFileUri, string audioFileId, System.Uri callbackUri, string operationContext = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> PlayAudioAsync(System.Uri audioFileUri, string audioFileId, System.Uri callbackUri, string operationContext = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual Azure.Response RemoveParticipant(string participantId, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual System.Threading.Tasks.Task RemoveParticipantAsync(string participantId, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual Azure.Response ResumeRecording(string recordingId, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual System.Threading.Tasks.Task ResumeRecordingAsync(string recordingId, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - public virtual Azure.Response StartRecording(System.Uri recordingStateCallbackUri, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - public virtual System.Threading.Tasks.Task> StartRecordingAsync(System.Uri recordingStateCallbackUri, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response StartRecording(System.Uri recordingStateCallbackUri, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> StartRecordingAsync(System.Uri recordingStateCallbackUri, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual Azure.Response StopRecording(string recordingId, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual System.Threading.Tasks.Task StopRecordingAsync(string recordingId, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } } - public partial class StartCallRecordingResponse + public partial class StartCallRecordingResult { - internal StartCallRecordingResponse() { } + internal StartCallRecordingResult() { } public string RecordingId { get { throw null; } } } public partial class ToneInfo diff --git a/sdk/communication/Azure.Communication.CallingServer/samples/Sample1_CreateCall.md b/sdk/communication/Azure.Communication.CallingServer/samples/Sample1_CreateCall.md index a22e1ee4c9f07..65c11bdeb294a 100644 --- a/sdk/communication/Azure.Communication.CallingServer/samples/Sample1_CreateCall.md +++ b/sdk/communication/Azure.Communication.CallingServer/samples/Sample1_CreateCall.md @@ -19,8 +19,8 @@ To make a call, call the `CreateCall` or `CreateCallAsync` function from the `Ca ```C# Snippet:Azure_Communication_Call_Tests_CreateCallOptions var createCallOption = new CreateCallOptions( new Uri(TestEnvironment.AppCallbackUrl), - new List { CallModality.Audio }, - new List + new[] { CallModality.Audio }, + new[] { EventSubscriptionType.ParticipantsUpdated, EventSubscriptionType.DtmfReceived diff --git a/sdk/communication/Azure.Communication.CallingServer/samples/Sample1_CreateCallAsync.md b/sdk/communication/Azure.Communication.CallingServer/samples/Sample1_CreateCallAsync.md index aa896a3d7e66f..0f34563ff8181 100644 --- a/sdk/communication/Azure.Communication.CallingServer/samples/Sample1_CreateCallAsync.md +++ b/sdk/communication/Azure.Communication.CallingServer/samples/Sample1_CreateCallAsync.md @@ -19,8 +19,8 @@ To make a Call, call the `CreateCall` or `CreateCallAsync` function from the `Ca ```C# Snippet:Azure_Communication_Call_Tests_CreateCallOptions var createCallOption = new CreateCallOptions( new Uri(TestEnvironment.AppCallbackUrl), - new List { CallModality.Audio }, - new List + new[] { CallModality.Audio }, + new[] { EventSubscriptionType.ParticipantsUpdated, EventSubscriptionType.DtmfReceived diff --git a/sdk/communication/Azure.Communication.CallingServer/tests/CallingServerClients/CallConnectionTests.cs b/sdk/communication/Azure.Communication.CallingServer/tests/CallingServerClients/CallConnectionTests.cs index 069122cd47c8e..7d792dcb3b9af 100644 --- a/sdk/communication/Azure.Communication.CallingServer/tests/CallingServerClients/CallConnectionTests.cs +++ b/sdk/communication/Azure.Communication.CallingServer/tests/CallingServerClients/CallConnectionTests.cs @@ -3,6 +3,7 @@ using System; using System.Collections.Generic; +using System.Net; using System.Threading.Tasks; using NUnit.Framework; @@ -48,9 +49,17 @@ public class CallConnectionTests : CallingServerTestBase "{ \"identifier\": {\"rawId\": \"4:+14251234567\", \"phoneNumber\": {\"value\":\"+14251234567\"}}, \"participantId\": \"e44ca273-079f-4759-8d6e-284ee8322625\", \"isMuted\": false }" + "]"; - private const string GetParticipantPayload1 = "{ \"identifier\": {\"rawId\": \"8:acs:024a7064-0581-40b9-be73-6dde64d69d89_00000008-ddad-a008-b8ba-a43a0d00d371\", \"communicationUser\": {\"id\":\"8:acs:024a7064-0581-40b9-be73-6dde64d69d89_00000008-ddad-a008-b8ba-a43a0d00d371\"}}, \"participantId\": \"ef70f6b0-c052-4ab7-9fdc-2dedb5fd16ac\", \"isMuted\": true }"; + private const string GetParticipantPayload1 = "{ " + + "\"identifier\": {\"rawId\": \"8:acs:024a7064-0581-40b9-be73-6dde64d69d89_00000008-ddad-a008-b8ba-a43a0d00d371\", \"communicationUser\": {\"id\":\"8:acs:024a7064-0581-40b9-be73-6dde64d69d89_00000008-ddad-a008-b8ba-a43a0d00d371\"}}, " + + "\"participantId\": \"ef70f6b0-c052-4ab7-9fdc-2dedb5fd16ac\", " + + "\"isMuted\": true " + + "}"; - private const string GetParticipantPayload2 = "{ \"identifier\": {\"rawId\": \"4:+14251234567\", \"phoneNumber\": {\"value\":\"+14251234567\"}}, \"participantId\": \"e44ca273-079f-4759-8d6e-284ee8322625\", \"isMuted\": false }"; + private const string GetParticipantPayload2 = "{ " + + "\"identifier\": {\"rawId\": \"4:+14251234567\", \"phoneNumber\": {\"value\":\"+14251234567\"}}, " + + "\"participantId\": \"e44ca273-079f-4759-8d6e-284ee8322625\", " + + "\"isMuted\": false " + + "}"; [TestCaseSource(nameof(TestData_CallConnectionId))] public async Task HangupCallAsync_Passes(string callConnectionId) @@ -59,7 +68,7 @@ public async Task HangupCallAsync_Passes(string callConnectionId) var response = await callConnection.HangupAsync().ConfigureAwait(false); - Assert.AreEqual((int)response.Status, 202); + Assert.AreEqual((int)HttpStatusCode.Accepted, response.Status); } [TestCaseSource(nameof(TestData_CallConnectionId))] @@ -69,7 +78,7 @@ public void HangupCall_Passes(string callConnectionId) var response = callConnection.Hangup(); - Assert.AreEqual((int)response.Status, 202); + Assert.AreEqual((int)HttpStatusCode.Accepted, response.Status); } [TestCaseSource(nameof(TestData_CallConnectionId))] @@ -77,9 +86,9 @@ public async Task CancelAllMediaOperationsAsync_Passes(string callConnectionId) { var callConnection = CreateMockCallConnection(200, CancelAllMediaOperaionsResponsePayload, callConnectionId: callConnectionId); - var response = await callConnection.CancelAllMediaOperationsAsync().ConfigureAwait(false); + var result = await callConnection.CancelAllMediaOperationsAsync().ConfigureAwait(false); - VerifyCancelAllMediaOperationsResponse(response); + VerifyCancelAllMediaOperationsResult(result); } [TestCaseSource(nameof(TestData_CallConnectionId))] @@ -87,9 +96,9 @@ public void CancelAllMediaOperations_Passes(string callConnectionId) { var callConnection = CreateMockCallConnection(200, CancelAllMediaOperaionsResponsePayload, callConnectionId: callConnectionId); - var response = callConnection.CancelAllMediaOperations(); + var result = callConnection.CancelAllMediaOperations(); - VerifyCancelAllMediaOperationsResponse(response); + VerifyCancelAllMediaOperationsResult(result); } [TestCaseSource(nameof(TestData_PlayAudio))] @@ -97,9 +106,9 @@ public async Task PlayAudioAsync_Passes(Uri sampleAudioFileUri, string sampleAud { var callConnection = CreateMockCallConnection(202, PlayAudioResponsePayload); - var response = await callConnection.PlayAudioAsync(sampleAudioFileUri, false, sampleAudioFileId, sampleCallbackUri, sampleOperationContext).ConfigureAwait(false); + var result = await callConnection.PlayAudioAsync(sampleAudioFileUri, false, sampleAudioFileId, sampleCallbackUri, sampleOperationContext).ConfigureAwait(false); - VerifyPlayAudioResponse(response); + VerifyPlayAudioResult(result); } [TestCaseSource(nameof(TestData_PlayAudio))] @@ -107,9 +116,9 @@ public void PlayAudio_Passes(Uri sampleAudioFileUri, string sampleAudioFileId, U { var callConnection = CreateMockCallConnection(202, PlayAudioResponsePayload); - var response = callConnection.PlayAudio(sampleAudioFileUri, false, sampleAudioFileId, sampleCallbackUri, sampleOperationContext); + var result = callConnection.PlayAudio(sampleAudioFileUri, false, sampleAudioFileId, sampleCallbackUri, sampleOperationContext); - VerifyPlayAudioResponse(response); + VerifyPlayAudioResult(result); } [TestCaseSource(nameof(TestData_PlayAudio))] @@ -126,9 +135,9 @@ public async Task PlayAudioAsyncOverload_Passes(Uri sampleAudioFileUri, string s OperationContext = sampleOperationContext }; - var response = await callConnection.PlayAudioAsync(playAudio).ConfigureAwait(false); + var result = await callConnection.PlayAudioAsync(playAudio).ConfigureAwait(false); - VerifyPlayAudioResponse(response); + VerifyPlayAudioResult(result); } [TestCaseSource(nameof(TestData_PlayAudio))] @@ -145,9 +154,9 @@ public void PlayAudioOverload_Passes(Uri sampleAudioFileUri, string sampleAudioF OperationContext = sampleOperationContext }; - var response = callConnection.PlayAudio(playAudio); + var result = callConnection.PlayAudio(playAudio); - VerifyPlayAudioResponse(response); + VerifyPlayAudioResult(result); } [TestCaseSource(nameof(TestData_AddParticipant))] @@ -157,7 +166,7 @@ public async Task AddParticipantsAsync_Passes(CommunicationIdentifier participan var response = await callConnection.AddParticipantAsync(participant, alternateCallerId, operationContext).ConfigureAwait(false); - Assert.AreEqual((int)response.Status, 202); + Assert.AreEqual((int)HttpStatusCode.Accepted, response.Status); } [TestCaseSource(nameof(TestData_AddParticipant))] @@ -167,7 +176,7 @@ public void AddParticipants_Passes(CommunicationIdentifier participant, string a var response = callConnection.AddParticipant(participant, alternateCallerId, operationContext); - Assert.AreEqual((int)response.Status, 202); + Assert.AreEqual((int)HttpStatusCode.Accepted, response.Status); } [TestCaseSource(nameof(TestData_ParticipantId))] @@ -177,7 +186,7 @@ public async Task RemoveParticipantsAsync_Passes(string callConnectionId, string var response = await callConnection.RemoveParticipantAsync(participantId).ConfigureAwait(false); - Assert.AreEqual((int)response.Status, 202); + Assert.AreEqual((int)HttpStatusCode.Accepted, response.Status); } [TestCaseSource(nameof(TestData_ParticipantId))] @@ -187,25 +196,25 @@ public void RemoveParticipants_Passes(string callConnectionId, string participan var response = callConnection.RemoveParticipant(participantId); - Assert.AreEqual((int)response.Status, 202); + Assert.AreEqual((int)HttpStatusCode.Accepted, response.Status); } - private void VerifyCancelAllMediaOperationsResponse(CancelAllMediaOperationsResult response) + private void VerifyCancelAllMediaOperationsResult(CancelAllMediaOperationsResult result) { - Assert.AreEqual("dummyId", response.Id); - Assert.AreEqual(OperationStatus.Completed, response.Status); - Assert.AreEqual("dummyOperationContext", response.OperationContext); - Assert.AreEqual(200, response.ResultInfo.Code); - Assert.AreEqual("dummyMessage", response.ResultInfo.Message); + Assert.AreEqual("dummyId", result.Id); + Assert.AreEqual(OperationStatus.Completed, result.Status); + Assert.AreEqual("dummyOperationContext", result.OperationContext); + Assert.AreEqual(200, result.ResultInfo.Code); + Assert.AreEqual("dummyMessage", result.ResultInfo.Message); } - private void VerifyPlayAudioResponse(PlayAudioResult response) + private void VerifyPlayAudioResult(PlayAudioResult result) { - Assert.AreEqual("dummyId", response.Id); - Assert.AreEqual(OperationStatus.Running, response.Status); - Assert.AreEqual("dummyOperationContext", response.OperationContext); - Assert.AreEqual(200, response.ResultInfo.Code); - Assert.AreEqual("dummyMessage", response.ResultInfo.Message); + Assert.AreEqual("dummyId", result.Id); + Assert.AreEqual(OperationStatus.Running, result.Status); + Assert.AreEqual("dummyOperationContext", result.OperationContext); + Assert.AreEqual(200, result.ResultInfo.Code); + Assert.AreEqual("dummyMessage", result.ResultInfo.Message); } private CallConnection CreateMockCallConnection(int responseCode, string? responseContent = null, string callConnectionId = "9ec7da16-30be-4e74-a941-285cfc4bffc5") diff --git a/sdk/communication/Azure.Communication.CallingServer/tests/CallingServerClients/ServerCallTests.cs b/sdk/communication/Azure.Communication.CallingServer/tests/CallingServerClients/ServerCallTests.cs index 5f2836bab77cd..384eddc0bba12 100644 --- a/sdk/communication/Azure.Communication.CallingServer/tests/CallingServerClients/ServerCallTests.cs +++ b/sdk/communication/Azure.Communication.CallingServer/tests/CallingServerClients/ServerCallTests.cs @@ -30,143 +30,142 @@ public class ServerCallTests : CallingServerTestBase "}"; [TestCaseSource(nameof(TestData_StartRecording))] - public void StartRecording_Returns200Ok(string sampleConversationId, Uri sampleCallBackUri) + public void StartRecording_Returns200Ok(Uri sampleCallBackUri) { - ServerCall serverCall = CreateMockServerCall(sampleConversationId, 200, DummyStartRecordingResponse); - StartCallRecordingResult response = serverCall.StartRecording(sampleCallBackUri); - Assert.AreEqual("dummyRecordingId", response.RecordingId); + ServerCall serverCall = CreateMockServerCall(200, responseContent: DummyStartRecordingResponse); + StartCallRecordingResult result = serverCall.StartRecording(sampleCallBackUri); + Assert.AreEqual("dummyRecordingId", result.RecordingId); } [TestCaseSource(nameof(TestData_StartRecording))] - public async Task StartRecordingAsync_Returns200Ok(string sampleConversationId, Uri sampleCallBackUri) + public async Task StartRecordingAsync_Returns200Ok(Uri sampleCallBackUri) { - ServerCall serverCall = CreateMockServerCall(sampleConversationId, 200, DummyStartRecordingResponse); - Response response = await serverCall.StartRecordingAsync(sampleCallBackUri); - Assert.AreEqual("dummyRecordingId", response.Value.RecordingId); + ServerCall serverCall = CreateMockServerCall(200, responseContent: DummyStartRecordingResponse); + Response result = await serverCall.StartRecordingAsync(sampleCallBackUri); + Assert.AreEqual("dummyRecordingId", result.Value.RecordingId); } [TestCaseSource(nameof(TestData_StopRecording))] - public void StopRecording_Return200Ok(string sampleConversationId, string sampleRecordingId) + public void StopRecording_Return200Ok(string sampleRecordingId) { - ServerCall serverCall = CreateMockServerCall(sampleConversationId, 200); + ServerCall serverCall = CreateMockServerCall(200); Response response = serverCall.StopRecording(sampleRecordingId); - var temp = response.Status; Assert.AreEqual((int)HttpStatusCode.OK, response.Status); } [TestCaseSource(nameof(TestData_StopRecording))] - public async Task StopRecordingAsync_Return200Ok(string sampleConversationId, string sampleRecordingId) + public async Task StopRecordingAsync_Return200Ok(string sampleRecordingId) { - ServerCall serverCall = CreateMockServerCall(sampleConversationId, 200); + ServerCall serverCall = CreateMockServerCall(200); Response response = await serverCall.StopRecordingAsync(sampleRecordingId); Assert.AreEqual((int)HttpStatusCode.OK, response.Status); } [TestCaseSource(nameof(TestData_PauseRecording))] - public void PauseRecording_Return200Ok(string sampleConversationId, string sampleRecordingId) + public void PauseRecording_Return200Ok(string sampleRecordingId) { - ServerCall serverCall = CreateMockServerCall(sampleConversationId, 200); + ServerCall serverCall = CreateMockServerCall(200); Response response = serverCall.PauseRecording(sampleRecordingId); Assert.AreEqual((int)HttpStatusCode.OK, response.Status); } [TestCaseSource(nameof(TestData_PauseRecording))] - public async Task PauseRecordingAsync_Return200Ok(string sampleConversationId, string sampleRecordingId) + public async Task PauseRecordingAsync_Return200Ok(string sampleRecordingId) { - ServerCall serverCall = CreateMockServerCall(sampleConversationId, 200); + ServerCall serverCall = CreateMockServerCall(200); Response response = await serverCall.PauseRecordingAsync(sampleRecordingId); Assert.AreEqual((int)HttpStatusCode.OK, response.Status); } [TestCaseSource(nameof(TestData_ResumeRecording))] - public void ResumeRecording_Return200Ok(string sampleConversationId, string sampleRecordingId) + public void ResumeRecording_Return200Ok(string sampleRecordingId) { - ServerCall serverCall = CreateMockServerCall(sampleConversationId, 200); + ServerCall serverCall = CreateMockServerCall(200); Response response = serverCall.ResumeRecording(sampleRecordingId); Assert.AreEqual((int)HttpStatusCode.OK, response.Status); } [TestCaseSource(nameof(TestData_ResumeRecording))] - public async Task ResumeRecordingAsync_Return200Ok(string sampleConversationId, string sampleRecordingId) + public async Task ResumeRecordingAsync_Return200Ok(string sampleRecordingId) { - ServerCall serverCall = CreateMockServerCall(sampleConversationId, 200); + ServerCall serverCall = CreateMockServerCall(200); Response response = await serverCall.ResumeRecordingAsync(sampleRecordingId); Assert.AreEqual((int)HttpStatusCode.OK, response.Status); } [TestCaseSource(nameof(TestData_GetRecordingState))] - public void GetRecordingState_Return200Ok(string sampleConversationId, string sampleRecordingId) + public void GetRecordingState_Return200Ok(string sampleRecordingId) { - ServerCall serverCall = CreateMockServerCall(sampleConversationId, 200, DummyRecordingStateResponse); - CallRecordingStateResult response = serverCall.GetRecordingState(sampleRecordingId); - Assert.AreEqual(CallRecordingState.Active, response.RecordingState); + ServerCall serverCall = CreateMockServerCall(200, responseContent: DummyRecordingStateResponse); + CallRecordingStateResult result = serverCall.GetRecordingState(sampleRecordingId); + Assert.AreEqual(CallRecordingState.Active, result.RecordingState); } [TestCaseSource(nameof(TestData_GetRecordingState))] - public async Task GetRecordingStateAsync_Return200Ok(string sampleConversationId, string sampleRecordingId) + public async Task GetRecordingStateAsync_Return200Ok(string sampleRecordingId) { - ServerCall serverCall = CreateMockServerCall(sampleConversationId, 200, DummyRecordingStateResponse); - Response response = await serverCall.GetRecordingStateAsync(sampleRecordingId); - Assert.AreEqual(CallRecordingState.Active, response.Value.RecordingState); + ServerCall serverCall = CreateMockServerCall(200, responseContent: DummyRecordingStateResponse); + Response result = await serverCall.GetRecordingStateAsync(sampleRecordingId); + Assert.AreEqual(CallRecordingState.Active, result.Value.RecordingState); } [TestCaseSource(nameof(TestData_PlayAudio))] - public void PlayAudio_Return202Accepted(string sampleConversationId, Uri sampleAudioFileUri, string sampleAudioFileId, Uri sampleCallbackUri, string sampleOperationContext) + public void PlayAudio_Return202Accepted(Uri sampleAudioFileUri, string sampleAudioFileId, Uri sampleCallbackUri, string sampleOperationContext) { - ServerCall serverCall = CreateMockServerCall(sampleConversationId, 202, DummyPlayAudioResponse); - PlayAudioResult response = serverCall.PlayAudio(sampleAudioFileUri, sampleAudioFileId, sampleCallbackUri, sampleOperationContext); - VerifyPlayAudioResponse(response); + ServerCall serverCall = CreateMockServerCall(202, responseContent: DummyPlayAudioResponse); + PlayAudioResult result = serverCall.PlayAudio(sampleAudioFileUri, sampleAudioFileId, sampleCallbackUri, sampleOperationContext); + VerifyPlayAudioResult(result); } [TestCaseSource(nameof(TestData_PlayAudio))] - public async Task PlayAudioAsync_Return202Accepted(string sampleConversationId, Uri sampleAudioFileUri, string sampleAudioFileId, Uri sampleCallbackUri, string sampleOperationContext) + public async Task PlayAudioAsync_Return202Accepted(Uri sampleAudioFileUri, string sampleAudioFileId, Uri sampleCallbackUri, string sampleOperationContext) { - ServerCall serverCall = CreateMockServerCall(sampleConversationId, 202, DummyPlayAudioResponse); - Response response = await serverCall.PlayAudioAsync(sampleAudioFileUri, sampleAudioFileId, sampleCallbackUri, sampleOperationContext); - VerifyPlayAudioResponse(response); + ServerCall serverCall = CreateMockServerCall(202, responseContent: DummyPlayAudioResponse); + Response result = await serverCall.PlayAudioAsync(sampleAudioFileUri, sampleAudioFileId, sampleCallbackUri, sampleOperationContext); + VerifyPlayAudioResult(result); } [TestCaseSource(nameof(TestData_AddParticipant))] - public async Task AddParticipantsAsync_Return202Accepted(string serverCallId, CommunicationIdentifier participant, Uri callBack, string alternateCallerId, string operationContext) + public async Task AddParticipantsAsync_Return202Accepted(CommunicationIdentifier participant, Uri callBack, string alternateCallerId, string operationContext) { - var serverCall = CreateMockServerCall(serverCallId, 202); + var serverCall = CreateMockServerCall(202); var response = await serverCall.AddParticipantAsync(participant, callBack, alternateCallerId, operationContext).ConfigureAwait(false); - Assert.AreEqual((int)response.Status, 202); + Assert.AreEqual((int)HttpStatusCode.Accepted, response.Status); } [TestCaseSource(nameof(TestData_AddParticipant))] - public void AddParticipants_Return202Accepted(string serverCallId, CommunicationIdentifier participant, Uri callBack, string alternateCallerId, string operationContext) + public void AddParticipants_Return202Accepted(CommunicationIdentifier participant, Uri callBack, string alternateCallerId, string operationContext) { - var serverCall = CreateMockServerCall(serverCallId, 202); + var serverCall = CreateMockServerCall(202); var response = serverCall.AddParticipant(participant, callBack, alternateCallerId, operationContext); - Assert.AreEqual((int)response.Status, 202); + Assert.AreEqual((int)HttpStatusCode.Accepted, response.Status); } [TestCaseSource(nameof(TestData_ParticipantId))] - public async Task RemoveParticipantsAsync_Return202Accepted(string serverCallId, string participantId) + public async Task RemoveParticipantsAsync_Return202Accepted(string participantId) { - var serverCall = CreateMockServerCall(serverCallId, 202); + var serverCall = CreateMockServerCall(202); var response = await serverCall.RemoveParticipantAsync(participantId).ConfigureAwait(false); - Assert.AreEqual((int)response.Status, 202); + Assert.AreEqual((int)HttpStatusCode.Accepted, response.Status); } [TestCaseSource(nameof(TestData_ParticipantId))] - public void RemoveParticipants_Return202Accepted(string serverCallId, string participantId) + public void RemoveParticipants_Return202Accepted(string participantId) { - var serverCall = CreateMockServerCall(serverCallId, 202); + var serverCall = CreateMockServerCall(202); var response = serverCall.RemoveParticipant(participantId); - Assert.AreEqual((int)response.Status, 202); + Assert.AreEqual((int)HttpStatusCode.Accepted, response.Status); } - private void VerifyPlayAudioResponse(PlayAudioResult response) + private void VerifyPlayAudioResult(PlayAudioResult response) { Assert.AreEqual("dummyId", response.Id); Assert.AreEqual(OperationStatus.Running, response.Status); @@ -181,7 +180,6 @@ private void VerifyPlayAudioResponse(PlayAudioResult response) { new object?[] { - "sampleConversationId", new Uri("https://somecallbackurl"), }, }; @@ -193,7 +191,6 @@ private void VerifyPlayAudioResponse(PlayAudioResult response) { new object?[] { - "sampleConversationId", "sampleRecordingId", }, }; @@ -205,7 +202,6 @@ private void VerifyPlayAudioResponse(PlayAudioResult response) { new object?[] { - "sampleConversationId", "sampleRecordingId", }, }; @@ -217,7 +213,6 @@ private void VerifyPlayAudioResponse(PlayAudioResult response) { new object?[] { - "sampleConversationId", "sampleRecordingId", }, }; @@ -229,7 +224,6 @@ private void VerifyPlayAudioResponse(PlayAudioResult response) { new object?[] { - "sampleConversationId", "sampleRecordingId", }, }; @@ -241,7 +235,6 @@ private void VerifyPlayAudioResponse(PlayAudioResult response) { new object?[] { - "sampleConversationId", new Uri("https://av.ngrok.io/audio/sample-message.wav"), "sampleAudioFileId", new Uri("https://av.ngrok.io/someCallbackUri"), @@ -256,7 +249,6 @@ private void VerifyPlayAudioResponse(PlayAudioResult response) { new object?[] { - "sampleConversationId", new CommunicationUserIdentifier("8:acs:acsuserid"), new Uri("https://bot.contoso.com/callback"), "+14250000000", @@ -271,13 +263,12 @@ private void VerifyPlayAudioResponse(PlayAudioResult response) { new object?[] { - "sampleConversationId", "66c76529-3e58-45bf-9592-84eadd52bc81" }, }; } - private ServerCall CreateMockServerCall(string serverCallId, int responseCode, string? responseContent = null) + private ServerCall CreateMockServerCall(int responseCode, string? responseContent = null, string serverCallId = "sampleServerCallId") { return CreateMockCallingServerClient(responseCode, responseContent).InitializeServerCall(serverCallId); }