-
Notifications
You must be signed in to change notification settings - Fork 54
Expand file tree
/
Copy pathTestUtils.cs
More file actions
61 lines (54 loc) · 1.81 KB
/
Copy pathTestUtils.cs
File metadata and controls
61 lines (54 loc) · 1.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
using System;
using System.Collections.Generic;
using NUnit.Framework;
namespace SendGrid.SmtpApi.HeaderTests
{
[TestFixture]
public class TestUtils
{
[Test]
public void TestSerialize()
{
var testcase = "foo";
String result = Utils.Serialize(testcase);
Assert.AreEqual("\"foo\"", result);
var testcase2 = 1;
result = Utils.Serialize(testcase2);
Assert.AreEqual("1", result);
}
[Test]
public void TestSerializeDictionary()
{
var test = new Dictionary<string, string>
{
{"a", "b"},
{"c", "d/e"}
};
var result = Utils.SerializeDictionary(test);
var expected = "{\"a\":\"b\",\"c\":\"d/e\"}";
Assert.AreEqual(expected, result);
}
[Test]
[ExpectedException("System.ArgumentNullException")]
public void TestSerializeNullThrowsException()
{
string test = null;
Utils.Serialize(test);
}
[Test]
[ExpectedException("System.ArgumentNullException")]
public void TestSerializeNullKeyThrowsException()
{
var test = new Dictionary<string, string> { { null, "test" } };
Utils.Serialize(test);
}
[Test]
public void TestEncodeNonAsciiCharacters()
{
var test = "私はラーメンが大好き";
var result = Utils.EncodeNonAsciiCharacters(test);
var expected = "\\u79c1\\u306f\\u30e9\\u30fc\\u30e1\\u30f3\\u304c\\u5927\\u597d\\u304d";
Assert.AreEqual(expected, result);
}
}
}