Skip to content

Commit

Permalink
updating merge to fix the test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
slorello89 committed Jun 10, 2020
1 parent 9dcbf94 commit 3c160c1
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 47 deletions.
21 changes: 10 additions & 11 deletions Nexmo.Api.Test.Unit/EndpointTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,34 +4,33 @@
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Xunit;
using Nexmo.Api.Voice;
using Nexmo.Api.Voice.Nccos.Endpoints;
using Newtonsoft.Json;

namespace Nexmo.Api.Test.Unit
{
[TestClass]
{
public class EndpointTest
{

[TestMethod]
[Fact]
public void TestWebhookEndpoint()
{
var expected = "{\"type\":\"websocket\",\"uri\":\"wss://www.example.com/ws\",\"content-type\":\"audio/l16;rate=16000\",\"headers\":{\"Bar\":\"bar\"}}";
var websocketEndpoint = new Call.Endpoint
{
type = "websocket",
uri = "wss://www.example.com/ws",
headers = new Foo { Bar = "bar" },
contentType = "audio/l16;rate=16000"
Type = "websocket",
Uri = "wss://www.example.com/ws",
Headers = new Foo { Bar = "bar" },
ContentType = "audio/l16;rate=16000"
};
string json = JsonConvert.SerializeObject(websocketEndpoint,
Formatting.None, new JsonSerializerSettings { DefaultValueHandling = DefaultValueHandling.Ignore });
Assert.IsTrue(json ==expected);
Assert.Equal(expected, json);
}

[TestMethod]
[Fact]
public void TestNccoEndpoint()
{
var expected = "{\"uri\":\"wss://www.example.com/ws\",\"content-type\":\"audio/l16;rate=16000\",\"headers\":{\"Bar\":\"bar\"},\"type\":\"websocket\"}";
Expand All @@ -43,7 +42,7 @@ public void TestNccoEndpoint()
};
string json = JsonConvert.SerializeObject(websocketEndpoint,
Formatting.None, new JsonSerializerSettings { DefaultValueHandling = DefaultValueHandling.Ignore });
Assert.AreEqual(expected, json);
Assert.Equal(expected, json);
}

public class Foo
Expand Down
8 changes: 4 additions & 4 deletions Nexmo.Api.Test.Unit/Legacy/CallTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,16 @@ public void CreateCall(bool passCreds)
{
new Voice.Call.Endpoint
{
number="14155550100",
dtmfAnswer="p*123#",
Number="14155550100",
DtmfAnswer="p*123#",
Type="phone"
}
},
from = new Voice.Call.Endpoint
{
Type = "phone",
number = "14155550100",
dtmfAnswer = "p*123#"
Number = "14155550100",
DtmfAnswer = "p*123#"
},
Ncco = new Voice.Nccos.Ncco(new Voice.Nccos.TalkAction { Text = "Hello World" }),
answer_url = new[] { "https://example.com/answer" },
Expand Down
43 changes: 21 additions & 22 deletions Nexmo.Api.Test.Unit/MultiInputTests.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Xunit;
using System;
using System.Collections.Generic;
using System.Linq;
Expand All @@ -9,11 +9,10 @@
using Newtonsoft.Json;

namespace Nexmo.Api.Test.Unit
{
[TestClass]
public class MultiInputTests
{
public class MultiInputTests : TestBase
{
[TestMethod]
[Fact]
public void TestSerializeNccoKitchenSink()
{
// arrage
Expand All @@ -35,9 +34,9 @@ public void TestSerializeNccoKitchenSink()
var actual = ncco.ToString();

//assert
Assert.AreEqual(expected, actual);
Assert.Equal(expected, actual);
}
[TestMethod]
[Fact]
public void TestSerializeNccoKitchenEmpty()
{
// arrage
Expand All @@ -53,10 +52,10 @@ public void TestSerializeNccoKitchenEmpty()
var actual = ncco.ToString();

//assert
Assert.AreEqual(expected, actual);
Assert.Equal(expected, actual);
}

[TestMethod]
[Fact]
public void TestWebhookSerialization()
{
//ARRANGE
Expand Down Expand Up @@ -89,17 +88,17 @@ public void TestWebhookSerialization()

var serialized = JsonConvert.DeserializeObject<MultiInput>(inboundString);

Assert.AreEqual("aaaaaaaa-bbbb-cccc-dddd-0123456789ab", serialized.Uuid);
Assert.AreEqual("end_on_silence_timeout", serialized.Speech.TimeoutReason);
Assert.AreEqual("0.9405097", serialized.Speech.SpeechResults[0].Confidence);
Assert.AreEqual("Sales", serialized.Speech.SpeechResults[0].Text);
Assert.AreEqual("0.5949854", serialized.Speech.SpeechResults[2].Confidence);
Assert.AreEqual("Sale", serialized.Speech.SpeechResults[2].Text);
Assert.AreEqual(null, serialized.Dtmf.Digits);
Assert.AreEqual(false, serialized.Dtmf.TimedOut);
Assert.Equal("aaaaaaaa-bbbb-cccc-dddd-0123456789ab", serialized.Uuid);
Assert.Equal("end_on_silence_timeout", serialized.Speech.TimeoutReason);
Assert.Equal("0.9405097", serialized.Speech.SpeechResults[0].Confidence);
Assert.Equal("Sales", serialized.Speech.SpeechResults[0].Text);
Assert.Equal("0.5949854", serialized.Speech.SpeechResults[2].Confidence);
Assert.Equal("Sale", serialized.Speech.SpeechResults[2].Text);
Assert.Null(serialized.Dtmf.Digits);
Assert.False(serialized.Dtmf.TimedOut);
}

[TestMethod]
[Fact]
public void TestWebhookSerializationSpeechOveridden()
{
//ARRANGE
Expand All @@ -118,10 +117,10 @@ public void TestWebhookSerializationSpeechOveridden()

var serialized = JsonConvert.DeserializeObject<MultiInput>(inboundString);

Assert.AreEqual("aaaaaaaa-bbbb-cccc-dddd-0123456789ab", serialized.Uuid);
Assert.AreEqual("Speech overridden by DTMF", serialized.Speech.Error);
Assert.AreEqual("1234", serialized.Dtmf.Digits);
Assert.AreEqual(false, serialized.Dtmf.TimedOut);
Assert.Equal("aaaaaaaa-bbbb-cccc-dddd-0123456789ab", serialized.Uuid);
Assert.Equal("Speech overridden by DTMF", serialized.Speech.Error);
Assert.Equal("1234", serialized.Dtmf.Digits);
Assert.False(serialized.Dtmf.TimedOut);
}
}
}
9 changes: 4 additions & 5 deletions Nexmo.Api.Test.Unit/StreamActionTest.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Xunit;
using Newtonsoft.Json;
using Nexmo.Api.Voice.Nccos;

namespace Nexmo.Api.Test.Unit
{
[TestClass]
{
public class StreamActionTest
{
[TestMethod]
[Fact]
public void TestStreamUrl()
{
//Arrange
Expand All @@ -17,7 +16,7 @@ public void TestStreamUrl()
var serialized = JsonConvert.SerializeObject(action, Formatting.None,
new JsonSerializerSettings { DefaultValueHandling = DefaultValueHandling.Ignore });
//Assert
Assert.AreEqual(expected, serialized);
Assert.Equal(expected, serialized);
}
}
}
14 changes: 9 additions & 5 deletions Nexmo.Api/Voice/Call.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,13 @@ public class Endpoint
/// <summary>
/// The phone number to connect to in E.164 format.
/// </summary>
public string number { get; set; }
[JsonProperty("number")]
public string Number { get; set; }
/// <summary>
/// Set the digits that are sent to the user as soon as the Call is answered. The * and # digits are respected. You create pauses using p. Each pause is 500ms.
/// </summary>
public string dtmfAnswer { get; set; }
[JsonProperty("dtmfAnswer")]
public string DtmfAnswer { get; set; }

// websocket/sip:

Expand All @@ -37,20 +39,22 @@ public class Endpoint
/// OR
/// The SIP URI to the endpoint you are connecting to in the format sip:rebekka@sip.example.com.
/// </summary>
public string uri { get; set; }
[JsonProperty("uri")]
public string Uri { get; set; }

// websocket:

/// <summary>
/// The internet media type for the audio you are streaming.Possible values are: audio/l16; rate=16000
/// </summary>
[JsonProperty("content-type")]
public string contentType { get; set; }
public string ContentType { get; set; }

/// <summary>
/// A JSON object containing any metadata you want.
/// </summary>
public object headers { get; set; }
[JsonProperty("headers")]
public object Headers { get; set; }
}

[JsonConverter(typeof(CallCommandConverter))]
Expand Down

0 comments on commit 3c160c1

Please sign in to comment.