forked from ServiceStack/ServiceStack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathConversionTests.cs
More file actions
29 lines (26 loc) · 1.08 KB
/
ConversionTests.cs
File metadata and controls
29 lines (26 loc) · 1.08 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
using System.Collections.Generic;
using NUnit.Framework;
namespace ServiceStack.Text.Tests
{
public class ConversionTests
{
[Test]
public void Converting_ObjectDictionary_ToStringDictionary_converts_collection_to_jsv()
{
var objDictionary = new Dictionary<string, object>
{
{"string", "foo,bar" },
{"intArray", new[] {1, 2} },
{"stringArray", new[] {"foo", "bar"} },
{"stringEscapeChars", "a, 'b" },
{"stringArrayEscapeChars", new[] { "a, b", "c 'd"} },
};
var strDictionary = objDictionary.ToStringDictionary();
Assert.That(strDictionary["string"], Is.EqualTo("foo,bar"));
Assert.That(strDictionary["intArray"], Is.EqualTo("[1,2]"));
Assert.That(strDictionary["stringArray"], Is.EqualTo("[foo,bar]"));
Assert.That(strDictionary["stringEscapeChars"], Is.EqualTo("a, 'b"));
Assert.That(strDictionary["stringArrayEscapeChars"], Is.EqualTo("[\"a, b\",c 'd]"));
}
}
}