|
| 1 | +using System.Collections.Generic; |
| 2 | +using NUnit.Framework; |
| 3 | +using Twilio.Converters; |
| 4 | + |
| 5 | +namespace Twilio.Tests.Converters |
| 6 | +{ |
| 7 | + [TestFixture] |
| 8 | + public class SerializersTest : TwilioTest { |
| 9 | + |
| 10 | + [Test] |
| 11 | + public void TestJsonObjectSerializesDictionary() |
| 12 | + { |
| 13 | + var inputDict = new Dictionary<string, string> {{"twilio", "rocks"}}; |
| 14 | + var result = Serializers.JsonObject(inputDict); |
| 15 | + Assert.AreEqual("{\"twilio\":\"rocks\"}", result); |
| 16 | + } |
| 17 | + |
| 18 | + [Test] |
| 19 | + public void TestJsonObjectSerializesList() |
| 20 | + { |
| 21 | + var inputDict = new List<object>{ |
| 22 | + "twilio", |
| 23 | + new Dictionary<string, string> {{"join", "us"}} |
| 24 | + }; |
| 25 | + var result = Serializers.JsonObject(inputDict); |
| 26 | + Assert.AreEqual("[\"twilio\",{\"join\":\"us\"}]", result); |
| 27 | + } |
| 28 | + |
| 29 | + [Test] |
| 30 | + public void TestJsonObjectSerializesArray() |
| 31 | + { |
| 32 | + string[] inputDict = new string[2] {"twilio", "rocks"}; |
| 33 | + var result = Serializers.JsonObject(inputDict); |
| 34 | + Assert.AreEqual("[\"twilio\",\"rocks\"]", result); |
| 35 | + } |
| 36 | + |
| 37 | + [Test] |
| 38 | + public void TestJsonObjectPassesThroughString() |
| 39 | + { |
| 40 | + var input = "{\"twilio\":\"is dope\"}"; |
| 41 | + var result = Serializers.JsonObject(input); |
| 42 | + Assert.AreEqual(input, result); |
| 43 | + } |
| 44 | + } |
| 45 | +} |
0 commit comments