From 18941d95b99fccc990871eba4cf59de61fa5ebb9 Mon Sep 17 00:00:00 2001 From: Mike Hamer Date: Mon, 13 Sep 2021 15:57:15 -0400 Subject: [PATCH] Add create call test with machine detection --- .../Voice/CreateCallTests.cs | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/Bandwidth.StandardTests/Voice/CreateCallTests.cs b/Bandwidth.StandardTests/Voice/CreateCallTests.cs index 8c7f2f48..f40dafa6 100644 --- a/Bandwidth.StandardTests/Voice/CreateCallTests.cs +++ b/Bandwidth.StandardTests/Voice/CreateCallTests.cs @@ -1,3 +1,4 @@ +using System; using System.Threading.Tasks; using Bandwidth.Standard; using Bandwidth.Standard.Voice.Exceptions; @@ -44,6 +45,42 @@ public async Task CreateCallReturnsCreated() Assert.Equal(from, createCallResponse.Data.From); } + [Fact] + public async Task CreateCallWithMachineDetectionReturnsCreated() + { + var accountId = TestConstants.AccountId; + var to = TestConstants.To; + var from = TestConstants.From; + var applicationId = TestConstants.VoiceApplicationId; + var answerUrl = string.Concat(TestConstants.BaseCallbackUrl, "/callbacks/answer"); + var machineDetectionRequest = new MachineDetectionRequest() + { + CallbackUrl = string.Concat(TestConstants.BaseCallbackUrl, "/callbacks/machine-detection") + }; + + var request = new CreateCallRequest() + { + ApplicationId = applicationId, + To = to, + From = from, + AnswerUrl = answerUrl, + MachineDetection = machineDetectionRequest + }; + + var createCallResponse = await _client.Voice.APIController.CreateCallAsync(accountId, request); + + Assert.Equal(201, createCallResponse.StatusCode); + + Assert.Equal(accountId, createCallResponse.Data.AccountId); + Assert.Equal(applicationId, createCallResponse.Data.ApplicationId); + Assert.Equal(to, createCallResponse.Data.To); + Assert.Equal(from, createCallResponse.Data.From); + Assert.True(Uri.IsWellFormedUriString(createCallResponse.Data.CallUrl, UriKind.Absolute)); + Assert.Equal(answerUrl, createCallResponse.Data.AnswerUrl); + Assert.Equal(AnswerMethodEnum.POST, createCallResponse.Data.AnswerMethod); + Assert.Equal(DisconnectMethodEnum.POST, createCallResponse.Data.DisconnectMethod); + } + [Fact] public async Task CreateCallInvalidToPhoneNumberThrows() {