コード例 #1
0
        public void ResumeRecording_Return200Ok(string sampleConversationId, string sampleRecordingId)
        {
            ConversationClient _convClient = CreateMockConversationClient(200);
            Response           response    = _convClient.ResumeRecording(sampleConversationId, sampleRecordingId);

            Assert.AreEqual((int)HttpStatusCode.OK, response.Status);
        }
コード例 #2
0
        public async Task StartRecordingAsync_Returns200Ok(string sampleConversationId, Uri sampleCallBackUri)
        {
            ConversationClient _convClient = CreateMockConversationClient(200, DummyStartRecordingResponse);
            Response <StartCallRecordingResponse> response = await _convClient.StartRecordingAsync(sampleConversationId, sampleCallBackUri);

            Assert.AreEqual("dummyRecordingId", response.Value.RecordingId);
        }
コード例 #3
0
        public async Task PauseRecordingAsync_Return200Ok(string sampleConversationId, string sampleRecordingId)
        {
            ConversationClient _convClient = CreateMockConversationClient(200);
            Response           response    = await _convClient.PauseRecordingAsync(sampleConversationId, sampleRecordingId);

            Assert.AreEqual((int)HttpStatusCode.OK, response.Status);
        }
コード例 #4
0
        public async Task PlayAudioAsync_Return202Accepted(string sampleConversationId, Uri sampleAudioFileUri, string sampleAudioFileId, Uri sampleCallbackUri, string sampleOperationContext)
        {
            ConversationClient           _convClient = CreateMockConversationClient(202, DummyPlayAudioResponse);
            Response <PlayAudioResponse> response    = await _convClient.PlayAudioAsync(sampleConversationId, sampleAudioFileUri, sampleAudioFileId, sampleCallbackUri, sampleOperationContext);

            VerifyPlayAudioResponse(response);
        }
コード例 #5
0
        public void StartRecording_Returns200Ok(string sampleConversationId, Uri sampleCallBackUri)
        {
            ConversationClient         _convClient = CreateMockConversationClient(200, DummyStartRecordingResponse);
            StartCallRecordingResponse response    = _convClient.StartRecording(sampleConversationId, sampleCallBackUri);

            Assert.AreEqual("dummyRecordingId", response.RecordingId);
        }
コード例 #6
0
        public async Task GetRecordingStateAsync_Return200Ok(string sampleConversationId, string sampleRecordingId)
        {
            ConversationClient _convClient = CreateMockConversationClient(200, DummyRecordingStateResponse);
            Response <GetCallRecordingStateResponse> response = await _convClient.GetRecordingStateAsync(sampleConversationId, sampleRecordingId);

            Assert.AreEqual(CallRecordingState.Active, response.Value.RecordingState);
        }
コード例 #7
0
        public void PlayAudio_Return202Accepted(string sampleConversationId, Uri sampleAudioFileUri, string sampleAudioFileId, Uri sampleCallbackUri, string sampleOperationContext)
        {
            ConversationClient _convClient = CreateMockConversationClient(202, DummyPlayAudioResponse);
            PlayAudioResponse  response    = _convClient.PlayAudio(sampleConversationId, sampleAudioFileUri, sampleAudioFileId, sampleCallbackUri, sampleOperationContext);

            VerifyPlayAudioResponse(response);
        }
コード例 #8
0
        public void GetRecordingState_Return200Ok(string sampleConversationId, string sampleRecordingId)
        {
            ConversationClient            _convClient = CreateMockConversationClient(200, DummyRecordingStateResponse);
            GetCallRecordingStateResponse response    = _convClient.GetRecordingState(sampleConversationId, sampleRecordingId);

            Assert.AreEqual(CallRecordingState.Active, response.RecordingState);
        }
コード例 #9
0
        public ConversationClient CreateMockConversationClient(MockResponse[] mockResponses)
        {
            var uri = new Uri("https://acs.dummyresource.com");
            var communicationTokenCredential =
                new AzureKeyCredential(dummyAccessKey);

            var callClientOptions = new CallClientOptions
            {
                Transport = new MockTransport(mockResponses)
            };

            var convClient = new ConversationClient(uri, communicationTokenCredential, callClientOptions);

            return(convClient);
        }
コード例 #10
0
        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);
        }
コード例 #11
0
 public ConversationService(ConversationClient client, MessageClient msgClient)
 {
     this.msgClient = msgClient;
     this.client    = client;
 }
コード例 #12
0
        protected override void Seed(MicroTcp.DAL.ApplicationContext context)
        {
            var isClients = context.Clients.Any();

            if (!isClients)
            {
                for (int i = 1; i < _itemNumbers; i++)
                {
                    var newClient = new Client {
                        Id = i, NickName = i.ToString(), Password = i.ToString()
                    };
                    context.Clients.Add(newClient);
                }
                context.SaveChanges();
            }
            var isConversations = context.Conversations.Any();

            if (!isConversations)
            {
                for (int i = 1; i < _itemNumbers; i++)
                {
                    var newConversation = new Conversation {
                        Id = i, Name = i.ToString(), StartDateTime = DateTime.Now
                    };
                    context.Conversations.Add(newConversation);
                }
                context.SaveChanges();
            }
            var isConversationClients = context.ConversationClients.Any();

            if (!isConversationClients)
            {
                var id = 1;
                for (int i = 1; i < _itemNumbers; i++)
                {
                    var client = context.Clients.FirstOrDefault(x => x.Id == i);
                    for (int k = 1; k < _itemNumbers; k++)
                    {
                        var conversation          = context.Conversations.FirstOrDefault(x => x.Id == k);
                        var newConversationClient = new ConversationClient
                        {
                            Id = id,
                            AddToConversation    = DateTime.Now,
                            Client               = client,
                            Conversation         = conversation,
                            DeleteToConversation = DateTime.Now
                        };
                        context.ConversationClients.Add(newConversationClient);
                        ++id;
                    }
                }
                context.SaveChanges();
            }
            var isMessages = context.Messages.Any();

            if (!isMessages)
            {
                var id = 1;
                for (int i = 1; i < _itemNumbers; i++)
                {
                    var client = context.Clients.FirstOrDefault(x => x.Id == i);
                    for (int k = 1; k < _itemNumbers; k++)
                    {
                        var conversation = context.Conversations.FirstOrDefault(x => x.Id == k);
                        var newMessage   = new Message
                        {
                            Id              = id,
                            Client          = client,
                            Conversation    = conversation,
                            MessageType     = (int)MessageType.ToAnotherClient,
                            PostingDateTime = DateTime.Now,
                            Text            = $"ClientId: {i} ConversationId {k}"
                        };
                        context.Messages.Add(newMessage);
                        ++id;
                    }
                }
                context.SaveChanges();
            }
        }