Skip to content

Commit

Permalink
Zihzhan/fix (#21805)
Browse files Browse the repository at this point in the history
* 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.
  • Loading branch information
zihzhan-msft authored Jun 10, 2021
1 parent 0161219 commit c310ffe
Show file tree
Hide file tree
Showing 6 changed files with 126 additions and 139 deletions.
4 changes: 2 additions & 2 deletions sdk/communication/Azure.Communication.CallingServer/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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> { CallModality.Audio },
new List<EventSubscriptionType>
new[] { CallModality.Audio },
new[]
{
EventSubscriptionType.ParticipantsUpdated,
EventSubscriptionType.DtmfReceived
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -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> { CallModality.Audio },
new List<EventSubscriptionType>
new[] { CallModality.Audio },
new[]
{
EventSubscriptionType.ParticipantsUpdated,
EventSubscriptionType.DtmfReceived
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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> { CallModality.Audio },
new List<EventSubscriptionType>
new[] { CallModality.Audio },
new[]
{
EventSubscriptionType.ParticipantsUpdated,
EventSubscriptionType.DtmfReceived
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

using System;
using System.Collections.Generic;
using System.Net;
using System.Threading.Tasks;
using NUnit.Framework;

Expand Down Expand Up @@ -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)
Expand All @@ -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))]
Expand All @@ -69,47 +78,47 @@ 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))]
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))]
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))]
public async Task PlayAudioAsync_Passes(Uri sampleAudioFileUri, string sampleAudioFileId, Uri sampleCallbackUri, string sampleOperationContext)
{
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))]
public void PlayAudio_Passes(Uri sampleAudioFileUri, string sampleAudioFileId, Uri sampleCallbackUri, string sampleOperationContext)
{
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))]
Expand All @@ -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))]
Expand All @@ -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))]
Expand All @@ -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))]
Expand All @@ -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))]
Expand All @@ -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))]
Expand All @@ -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")
Expand Down
Loading

0 comments on commit c310ffe

Please sign in to comment.