Skip to content

Commit

Permalink
Add create call test with machine detection
Browse files Browse the repository at this point in the history
  • Loading branch information
hamermike committed Sep 13, 2021
1 parent aa31b1e commit 18941d9
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions Bandwidth.StandardTests/Voice/CreateCallTests.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System;
using System.Threading.Tasks;
using Bandwidth.Standard;
using Bandwidth.Standard.Voice.Exceptions;
Expand Down Expand Up @@ -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()
{
Expand Down

0 comments on commit 18941d9

Please sign in to comment.