-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added unit test for recording apis (#21578)
Co-authored-by: Paresh Arvind Patil <papati@microsoft.com>
- Loading branch information
1 parent
a25d550
commit b5090cd
Showing
2 changed files
with
144 additions
and
117 deletions.
There are no files selected for viewing
44 changes: 44 additions & 0 deletions
44
...ure.Communication.Calling.Server/tests/ConversationClients/ConversationClientBaseTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
using System; | ||
using Azure.Core; | ||
using Azure.Core.TestFramework; | ||
|
||
namespace Azure.Communication.Calling.Server.Tests.ConversationClients | ||
{ | ||
public class ConversationClientBaseTests | ||
{ | ||
private const string dummyAccessKey = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9+eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ+SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV+adQssw5c="; | ||
public ConversationClient CreateMockConversationClient(int statusCode, object? content = null, HttpHeader[]? httpHeaders = null) | ||
{ | ||
var uri = new Uri("https://acs.dummyresource.com"); | ||
var communicationTokenCredential = | ||
new AzureKeyCredential(dummyAccessKey); | ||
var mockResponse = new MockResponse(statusCode); | ||
if (content != null) | ||
{ | ||
if (content.GetType() == typeof(string)) | ||
mockResponse.SetContent((string)content); | ||
else if (content.GetType() == typeof(byte[])) | ||
mockResponse.SetContent((byte[])content); | ||
} | ||
|
||
if (httpHeaders != null) | ||
{ | ||
for (int i = 0; i < httpHeaders.Length; i++) | ||
{ | ||
mockResponse.AddHeader(httpHeaders[i]); | ||
} | ||
} | ||
|
||
var callClientOptions = new CallClientOptions | ||
{ | ||
Transport = new MockTransport(mockResponse) | ||
}; | ||
|
||
var convClient = new ConversationClient(uri, communicationTokenCredential, callClientOptions); | ||
return convClient; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters