Skip to content

Commit

Permalink
DX-2281 Add answer call for voice's ring BXML (#40)
Browse files Browse the repository at this point in the history
* Add answer call for voice's ring BXML

* Remove assert warnings
  • Loading branch information
hamermike authored Oct 28, 2021
1 parent 613bcca commit cbb3c9f
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 0 deletions.
7 changes: 7 additions & 0 deletions Bandwidth.Standard/Voice/Bxml/Ring.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,19 @@ public class Ring : IVerb
[XmlAttribute("duration")]
public double Duration { get; set; }

/// <summary>
/// (optional) A boolean indicating whether or not to answer the call when Ring is executed on an unanswered incoming call. Default value is 'true'.
/// </summary>
[XmlAttribute("answerCall")]
public bool AnswerCall { get; set; }

/// <summary>
/// Initialize the double fields to Bandwidth's default value
/// </summary>
public Ring()
{
Duration = 5;
AnswerCall = true;
}
}
}
66 changes: 66 additions & 0 deletions Bandwidth.StandardTests/Voice/Bxml/RingTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
using Bandwidth.Standard.Voice.Bxml;
using Xunit;

namespace Bandwidth.StandardTests.Voice.Bxml
{
public class RingTests
{
[Fact]
public void RingShouldBeDefaults()
{
var ring = new Ring();

Assert.Equal(5, ring.Duration);
Assert.True(ring.AnswerCall);
}

[Fact]
public void RingDurationShouldBeTen()
{
var ring = new Ring();
ring.Duration = 10;

Assert.Equal(10, ring.Duration);
}

[Fact]
public void RingAnswerCallShouldBeFalse()
{
var ring = new Ring();
ring.AnswerCall = false;

Assert.False(ring.AnswerCall);
}

[Fact]
public void RingResponseToBXMLShouldBeDefaults()
{
var ring = new Ring();
var response = new Response(ring);

Assert.Equal("<?xml version=\"1.0\" encoding=\"utf-8\"?><Response> <Ring duration=\"5\" answerCall=\"true\" /></Response>", response.ToBXML());
}

[Fact]
public void RingDurationResponseToBXMLShouldBeThirty()
{
var ring = new Ring();
ring.Duration = 30;

var response = new Response(ring);

Assert.Equal("<?xml version=\"1.0\" encoding=\"utf-8\"?><Response> <Ring duration=\"30\" answerCall=\"true\" /></Response>", response.ToBXML());
}

[Fact]
public void RingAnswerCallResponseToBXMLShouldBeFalse()
{
var ring = new Ring();
ring.AnswerCall = false;

var response = new Response(ring);

Assert.Equal("<?xml version=\"1.0\" encoding=\"utf-8\"?><Response> <Ring duration=\"5\" answerCall=\"false\" /></Response>", response.ToBXML());
}
}
}

0 comments on commit cbb3c9f

Please sign in to comment.