Commits

Anonymous committed 40c47d6

BUG FIX: Parsing failure reports incorrect index.
Added serialization option for case-sensitivity.
Added serialization option to always include type name.
Added abstraction map option to also map base and interface types.
Rename files to conform with Manatee.* projects.

  • Participants
  • Parent commits ff4c691

Comments (0)

Files changed (200)

File ECMA-404.pdf

Binary file added.

File Json.Tests/DevTest.cs

-/***************************************************************************************
-
-	Copyright 2012 Greg Dennis
-
-	   Licensed under the Apache License, Version 2.0 (the "License");
-	   you may not use this file except in compliance with the License.
-	   You may obtain a copy of the License at
-
-		 http://www.apache.org/licenses/LICENSE-2.0
-
-	   Unless required by applicable law or agreed to in writing, software
-	   distributed under the License is distributed on an "AS IS" BASIS,
-	   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-	   See the License for the specific language governing permissions and
-	   limitations under the License.
- 
-	File Name:		DevTest.cs
-	Namespace:		Manatee.Tests
-	Class Name:		DevTest
-	Purpose:		Provides a single method through which one can test any specific
-					scenario.  Should be marked [Ignore] when committing to the
-					repository.
-
-***************************************************************************************/
-
-using System;
-using Manatee.Json;
-using Manatee.Json.Serialization;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-
-namespace Manatee.Tests
-{
-	[TestClass]
-	public class DevTest
-	{
-		[TestMethod]
-		[Ignore]
-		public void Test1()
-		{
-		}
-	}
-}

File Json.Tests/Json/Extensions/JsonArrayExtensionsTest.cs

-/***************************************************************************************
-
-	Copyright 2012 Greg Dennis
-
-	   Licensed under the Apache License, Version 2.0 (the "License");
-	   you may not use this file except in compliance with the License.
-	   You may obtain a copy of the License at
-
-		 http://www.apache.org/licenses/LICENSE-2.0
-
-	   Unless required by applicable law or agreed to in writing, software
-	   distributed under the License is distributed on an "AS IS" BASIS,
-	   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-	   See the License for the specific language governing permissions and
-	   limitations under the License.
- 
-	File Name:		JsonArrayExtensionsTest.cs
-	Namespace:		Manatee.Tests.Json.Extensions
-	Class Name:		JsonArrayExtensionsTest
-	Purpose:		Tests for the JsonArray extension methods for the Json library.
-
-***************************************************************************************/
-using Manatee.Json;
-using Manatee.Json.Enumerations;
-using Manatee.Json.Extensions;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-
-namespace Manatee.Tests.Json.Extensions
-{
-	[TestClass]
-	public class JsonArrayExtensionsTest
-	{
-		[TestMethod]
-		public void OfType_ReturnsOnlyRequestType()
-		{
-			var json = new JsonArray {6, "string", false, 42, JsonValue.Null, true};
-			var expected = new JsonArray {6, 42};
-			var values = json.OfType(JsonValueType.Number);
-
-			Assert.AreEqual(expected, values);
-		}
-	}
-}

File Json.Tests/Json/Extensions/JsonObjectExtensionsTest.cs

-/***************************************************************************************
-
-	Copyright 2012 Greg Dennis
-
-	   Licensed under the Apache License, Version 2.0 (the "License");
-	   you may not use this file except in compliance with the License.
-	   You may obtain a copy of the License at
-
-		 http://www.apache.org/licenses/LICENSE-2.0
-
-	   Unless required by applicable law or agreed to in writing, software
-	   distributed under the License is distributed on an "AS IS" BASIS,
-	   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-	   See the License for the specific language governing permissions and
-	   limitations under the License.
- 
-	File Name:		JsonObjectExtensionsTest.cs
-	Namespace:		Manatee.Tests.Json.Extensions
-	Class Name:		JsonObjectExtensionsTest
-	Purpose:		Tests for the JsonObject extension methods for the Json library.
-
-***************************************************************************************/
-using System;
-using System.Text;
-using System.Collections.Generic;
-using System.Linq;
-using Manatee.Json;
-using Manatee.Json.Extensions;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-
-namespace Manatee.Tests.Json.Extensions
-{
-	[TestClass]
-	public class JsonObjectExtensionsTest
-	{
-		[TestMethod]
-		public void TryGetString_ReturnsRequested()
-		{
-			var json = new JsonObject
-				{
-					{"string", "test"},
-					{"number", 6},
-					{"boolean", true}
-				};
-
-			var value = json.TryGetString("string");
-
-			Assert.AreEqual("test", value);
-		}
-		[TestMethod]
-		public void TryGetString_NullObjectReturnsNull()
-		{
-			JsonObject json = null;
-
-			var value = json.TryGetString("string");
-
-			Assert.IsNull(value);
-		}
-		[TestMethod]
-		public void TryGetString_ValueNotFoundReturnsNull()
-		{
-			var json = new JsonObject
-				{
-					{"number", 6},
-					{"boolean", true}
-				};
-			var value = json.TryGetString("string");
-
-			Assert.IsNull(value);
-		}
-		[TestMethod]
-		public void TryGetString_ValueNotStringReturnsNull()
-		{
-			var json = new JsonObject
-				{
-					{"string", "test"},
-					{"number", 6},
-					{"boolean", true}
-				};
-			var value = json.TryGetString("number");
-
-			Assert.IsNull(value);
-		}
-		[TestMethod]
-		public void TryGetNumber_ReturnsRequested()
-		{
-			var json = new JsonObject
-				{
-					{"string", "test"},
-					{"number", 6},
-					{"boolean", true}
-				};
-
-			var value = json.TryGetNumber("number");
-
-			Assert.AreEqual(6.0, value);
-		}
-		[TestMethod]
-		public void TryGetNumber_NullObjectReturnsNull()
-		{
-			JsonObject json = null;
-
-			var value = json.TryGetNumber("number");
-
-			Assert.IsNull(value);
-		}
-		[TestMethod]
-		public void TryGetNumber_ValueNotFoundReturnsNull()
-		{
-			var json = new JsonObject
-				{
-					{"string", "test"},
-					{"boolean", true}
-				};
-			var value = json.TryGetNumber("number");
-
-			Assert.IsNull(value);
-		}
-		[TestMethod]
-		public void TryGetNumber_ValueNotNumberReturnsNull()
-		{
-			var json = new JsonObject
-				{
-					{"string", "test"},
-					{"number", 6},
-					{"boolean", true}
-				};
-			var value = json.TryGetNumber("string");
-
-			Assert.IsNull(value);
-		}
-		[TestMethod]
-		public void TryGetBoolean_ReturnsRequested()
-		{
-			var json = new JsonObject
-				{
-					{"string", "test"},
-					{"number", 6},
-					{"boolean", true}
-				};
-
-			var value = json.TryGetBoolean("boolean");
-
-			Assert.AreEqual(true, value);
-		}
-		[TestMethod]
-		public void TryGetBoolean_NullObjectReturnsNull()
-		{
-			JsonObject json = null;
-
-			var value = json.TryGetBoolean("boolean");
-
-			Assert.IsNull(value);
-		}
-		[TestMethod]
-		public void TryGetBoolean_ValueNotFoundReturnsNull()
-		{
-			var json = new JsonObject
-				{
-					{"string", "test"},
-					{"number", 6}
-				};
-			var value = json.TryGetBoolean("boolean");
-
-			Assert.IsNull(value);
-		}
-		[TestMethod]
-		public void TryGetBoolean_ValueNotBooleanReturnsNull()
-		{
-			var json = new JsonObject
-				{
-					{"string", "test"},
-					{"number", 6},
-					{"boolean", true}
-				};
-			var value = json.TryGetBoolean("string");
-
-			Assert.IsNull(value);
-		}
-		[TestMethod]
-		public void TryGetArray_ReturnsRequested()
-		{
-			var json = new JsonObject
-				{
-					{"string", "test"},
-					{"number", 6},
-					{"array", new JsonArray()}
-				};
-
-			var value = json.TryGetArray("array");
-
-			Assert.AreEqual(new JsonArray(), value);
-		}
-		[TestMethod]
-		public void TryGetArray_NullObjectReturnsNull()
-		{
-			JsonObject json = null;
-
-			var value = json.TryGetArray("array");
-
-			Assert.IsNull(value);
-		}
-		[TestMethod]
-		public void TryGetArray_ValueNotFoundReturnsNull()
-		{
-			var json = new JsonObject
-				{
-					{"string", "test"},
-					{"number", 6}
-				};
-			var value = json.TryGetArray("array");
-
-			Assert.IsNull(value);
-		}
-		[TestMethod]
-		public void TryGetArray_ValueNotBooleanReturnsNull()
-		{
-			var json = new JsonObject
-				{
-					{"string", "test"},
-					{"number", 6},
-					{"array", new JsonArray()}
-				};
-			var value = json.TryGetArray("string");
-
-			Assert.IsNull(value);
-		}
-		[TestMethod]
-		public void TryGetObject_ReturnsRequested()
-		{
-			var json = new JsonObject
-				{
-					{"string", "test"},
-					{"number", 6},
-					{"object", new JsonObject()}
-				};
-
-			var value = json.TryGetObject("object");
-
-			Assert.AreEqual(new JsonObject(), value);
-		}
-		[TestMethod]
-		public void TryGetObject_NullObjectReturnsNull()
-		{
-			JsonObject json = null;
-
-			var value = json.TryGetObject("object");
-
-			Assert.IsNull(value);
-		}
-		[TestMethod]
-		public void TryGetObject_ValueNotFoundReturnsNull()
-		{
-			var json = new JsonObject
-				{
-					{"string", "test"},
-					{"number", 6}
-				};
-			var value = json.TryGetObject("object");
-
-			Assert.IsNull(value);
-		}
-		[TestMethod]
-		public void TryGetObject_ValueNotBooleanReturnsNull()
-		{
-			var json = new JsonObject
-				{
-					{"string", "test"},
-					{"number", 6},
-					{"object", new JsonObject()}
-				};
-			var value = json.TryGetObject("string");
-
-			Assert.IsNull(value);
-		}
-	}
-}

File Json.Tests/Json/Extensions/LinqExtensionsTest.cs

-/***************************************************************************************
-
-	Copyright 2012 Greg Dennis
-
-	   Licensed under the Apache License, Version 2.0 (the "License");
-	   you may not use this file except in compliance with the License.
-	   You may obtain a copy of the License at
-
-		 http://www.apache.org/licenses/LICENSE-2.0
-
-	   Unless required by applicable law or agreed to in writing, software
-	   distributed under the License is distributed on an "AS IS" BASIS,
-	   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-	   See the License for the specific language governing permissions and
-	   limitations under the License.
- 
-	File Name:		LinqExtensionsTest.cs
-	Namespace:		Manatee.Tests.Json.Extensions
-	Class Name:		LinqExtensionsTest
-	Purpose:		Tests for the LINQ extension methods for the Json library.
-
-***************************************************************************************/
-using System.Linq;
-using Manatee.Json;
-using Manatee.Json.Enumerations;
-using Manatee.Json.Extensions;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-
-namespace Manatee.Tests.Json.Extensions
-{
-	[TestClass]
-	public class LinqExtensionsTest
-	{
-		[TestMethod]
-		public void ToJson_FilteringArray_ReturnsArray()
-		{
-			var json = new JsonArray {false, 42, "a string", "another string"};
-			var expected = new JsonArray {"a string", "another string"};
-			var actual = json.Where(jv => jv.Type == JsonValueType.String).ToJson();
-			Assert.AreEqual(expected, actual);
-		}
-		[TestMethod]
-		public void ToJson_FilteringObject_ReturnsObject()
-		{
-			var json = new JsonObject {{"bool", false}, {"int", 42}, {"string", "a string"}, {"string2", "another string"}};
-			var expected = new JsonObject {{"string", "a string"}, {"string2", "another string"}};
-			var actual = json.Where(jv => jv.Value.Type == JsonValueType.String).ToJson();
-			Assert.AreEqual(expected, actual);
-		}
-		[TestMethod]
-		public void ToJson_FilteringObjectExtractValues_ReturnsArray()
-		{
-			var json = new JsonObject {{"bool", false}, {"int", 42}, {"string", "a string"}, {"string2", "another string"}};
-			var expected = new JsonArray {"a string", "another string"};
-			var actual = json.Where(jv => jv.Value.Type == JsonValueType.String)
-							 .Select(jv => jv.Value).ToJson();
-			Assert.AreEqual(expected, actual);
-		}
-	}
-}

File Json.Tests/Json/Extensions/XmlExtensionsTest.cs

-/***************************************************************************************
-
-	Copyright 2012 Greg Dennis
-
-	   Licensed under the Apache License, Version 2.0 (the "License");
-	   you may not use this file except in compliance with the License.
-	   You may obtain a copy of the License at
-
-		 http://www.apache.org/licenses/LICENSE-2.0
-
-	   Unless required by applicable law or agreed to in writing, software
-	   distributed under the License is distributed on an "AS IS" BASIS,
-	   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-	   See the License for the specific language governing permissions and
-	   limitations under the License.
- 
-	File Name:		XmlExtensionsTest.cs
-	Namespace:		Manatee.Tests.Json.Extensions
-	Class Name:		XmlExtensionsTest
-	Purpose:		Tests for the XML extension methods for the Json library.
-
-***************************************************************************************/
-using System;
-using System.Collections.Generic;
-using System.Xml.Linq;
-using Manatee.Json;
-using Manatee.Json.Extensions;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-
-namespace Manatee.Tests.Json.Extensions
-{
-	[TestClass]
-	public class XmlExtensionsTest
-	{
-		#region Number
-		[TestMethod]
-		[ExpectedException(typeof(ArgumentException))]
-		public void ToXElement_NumberNullKey_ThrowsArgumentException()
-		{
-			JsonValue json = 42;
-			var actual = json.ToXElement(null);
-		}
-		[TestMethod]
-		public void ToXElement_NumberWithKey_MapsCorrectly()
-		{
-			var value = 42;
-			var key = "aKey";
-			JsonValue json = value;
-			var expected = new XElement(key, value);
-
-			var actual = json.ToXElement(key);
-
-			Assert.IsTrue(XNode.DeepEquals(expected, actual));
-		}
-		[TestMethod]
-		public void ToJson_ElementWithNumberValue_MapsCorrectly()
-		{
-			var value = 42;
-			var key = "aKey";
-			var xml = new XElement(key, value);
-			JsonValue expected = new JsonObject {{key, value}};
-
-			var actual = xml.ToJson();
-
-			Assert.AreEqual(expected, actual);
-		}
-		#endregion
-		#region String
-		[TestMethod]
-		[ExpectedException(typeof(ArgumentException))]
-		public void ToXElement_StringNullKey_ThrowsArgumentException()
-		{
-			JsonValue json = "a string";
-			var actual = json.ToXElement(null);
-		}
-		[TestMethod]
-		public void ToXElement_StringWithKey_MapsCorrectly()
-		{
-			var value = "a string";
-			var key = "aKey";
-			JsonValue json = value;
-			var expected = new XElement(key, value);
-
-			var actual = json.ToXElement(key);
-
-			Assert.IsTrue(XNode.DeepEquals(expected, actual));
-		}
-		[TestMethod]
-		public void ToXElement_NumericStringWithKey_MapsCorrectly()
-		{
-			var value = "42";
-			var key = "aKey";
-			JsonValue json = value;
-			var expected = new XElement(key, value);
-			expected.SetAttributeValue("type", "String");
-
-			var actual = json.ToXElement(key);
-
-			Assert.AreEqual(expected.ToString(), actual.ToString());
-		}
-		[TestMethod]
-		public void ToXElement_BooleanStringWithKey_MapsCorrectly()
-		{
-			var value = "true";
-			var key = "aKey";
-			JsonValue json = value;
-			var expected = new XElement(key, value);
-			expected.SetAttributeValue("type", "String");
-
-			var actual = json.ToXElement(key);
-
-			Assert.AreEqual(expected.ToString(), actual.ToString());
-		}
-		[TestMethod]
-		public void ToJson_ElementWithStringValue_MapsCorrectly()
-		{
-			var value = "a string";
-			var key = "aKey";
-			var xml = new XElement(key, value);
-			JsonValue expected = new JsonObject {{key, value}};
-
-			var actual = xml.ToJson();
-
-			Assert.AreEqual(expected, actual);
-		}
-		[TestMethod]
-		public void ToJson_ElementWithNumericStringValue_MapsCorrectly()
-		{
-			var value = "42";
-			var key = "aKey";
-			var xml = new XElement(key, value);
-			xml.SetAttributeValue("type", "String");
-			JsonValue expected = new JsonObject {{key, value}};
-
-			var actual = xml.ToJson();
-
-			Assert.AreEqual(expected, actual);
-		}
-		[TestMethod]
-		public void ToJson_ElementWithBooleanStringValue_MapsCorrectly()
-		{
-			var value = "true";
-			var key = "aKey";
-			var xml = new XElement(key, value);
-			xml.SetAttributeValue("type", "String");
-			JsonValue expected = new JsonObject {{key, value}};
-
-			var actual = xml.ToJson();
-
-			Assert.AreEqual(expected, actual);
-		}
-		#endregion
-		#region Boolean
-		[TestMethod]
-		[ExpectedException(typeof(ArgumentException))]
-		public void ToXElement_BooleanNullKey_ThrowsArgumentException()
-		{
-			JsonValue json = true;
-			var actual = json.ToXElement(null);
-		}
-		[TestMethod]
-		public void ToXElement_BooleanWithKey_MapsCorrectly()
-		{
-			var value = true;
-			var key = "aKey";
-			JsonValue json = value;
-			var expected = new XElement(key, value);
-
-			var actual = json.ToXElement(key);
-
-			Assert.IsTrue(XNode.DeepEquals(expected, actual));
-		}
-		[TestMethod]
-		public void ToJson_ElementWithBooleanValue_MapsCorrectly()
-		{
-			var value = true;
-			var key = "aKey";
-			var xml = new XElement(key, value);
-			JsonValue expected = new JsonObject {{key, value}};
-
-			var actual = xml.ToJson();
-
-			Assert.AreEqual(expected, actual);
-		}
-		#endregion
-		#region Object
-		[TestMethod]
-		[ExpectedException(typeof(ArgumentException))]
-		public void ToXElement_ObjectNullKeyMultiplePairs_ThrowsArgumentException()
-		{
-			JsonValue json = new JsonObject {{"bool", false}, {"int", 42}, {"string", "a string"}};
-			var actual = json.ToXElement(null);
-		}
-		[TestMethod]
-		public void ToXElement_ObjectNullKeySinglePair_MapsCorrectly()
-		{
-			JsonValue json = new JsonObject {{"root", new JsonObject {{"bool", false}, {"int", 42}, {"string", "a string"}}}};
-			var key = "root";
-			var expected = new XElement(key);
-			var xml = new XElement("bool", false);
-			expected.Add(xml);
-			xml = new XElement("int", 42);
-			expected.Add(xml);
-			xml = new XElement("string", "a string");
-			expected.Add(xml);
-
-			var actual = json.ToXElement(null);
-
-			Assert.IsTrue(XNode.DeepEquals(expected, actual));
-		}
-		[TestMethod]
-		public void ToXElement_ObjectWithKey_MapsCorrectly()
-		{
-			JsonValue json = new JsonObject {{"bool", false}, {"int", 42}, {"string", "a string"}};
-			var key = "aKey";
-			var expected = new XElement(key);
-			var xml = new XElement("bool", false);
-			expected.Add(xml);
-			xml = new XElement("int", 42);
-			expected.Add(xml);
-			xml = new XElement("string", "a string");
-			expected.Add(xml);
-
-			var actual = json.ToXElement(key);
-
-			Assert.IsTrue(XNode.DeepEquals(expected, actual));
-		}
-		[TestMethod]
-		public void ToJson_SingleRootElementSimpleContents_MapsCorrectly()
-		{
-			var key = "aKey";
-			var xml = new XElement(key);
-			var element = new XElement("bool", false);
-			xml.Add(element);
-			element = new XElement("int", 42);
-			xml.Add(element);
-			element = new XElement("string", "a string");
-			xml.Add(element);
-			JsonValue expected = new JsonObject {{"aKey", new JsonObject {{"bool", false}, {"int", 42}, {"string", "a string"}}}};
-
-			var actual = xml.ToJson();
-
-			Assert.AreEqual(expected, actual);
-		}
-		[TestMethod]
-		public void ToJson_MultipleRootElementsSimpleContents_MapsCorrectly()
-		{
-			var list = new List<XElement>();
-			var element = new XElement("bool", false);
-			list.Add(element);
-			element = new XElement("int", 42);
-			list.Add(element);
-			element = new XElement("string", "a string");
-			list.Add(element);
-			JsonValue expected = new JsonObject {{"bool", false}, {"int", 42}, {"string", "a string"}};
-
-			var actual = list.ToJson();
-
-			Assert.AreEqual(expected, actual);
-		}
-		[TestMethod]
-		public void ToJson_SingleRootElementComplexContents_MapsCorrectly()
-		{
-			var key = "aKey";
-			var xml = new XElement(key);
-			var element = new XElement("bool", false);
-			xml.Add(element);
-			element = new XElement("int", 42);
-			xml.Add(element);
-			element = new XElement("object");
-			var inner = new XElement("string", "a string");
-			element.Add(inner);
-			xml.Add(element);
-			JsonValue expected = new JsonObject
-			                     	{
-			                     		{
-			                     			"aKey",
-			                     			new JsonObject
-			                     				{
-			                     					{"bool", false},
-			                     					{"int", 42},
-			                     					{"object", new JsonObject {{"string", "a string"}}}
-			                     				}
-			                     			}
-			                     	};
-
-			var actual = xml.ToJson();
-
-			Assert.AreEqual(expected, actual);
-		}
-		#endregion
-		#region Array
-		[TestMethod]
-		[ExpectedException(typeof(ArgumentException))]
-		public void ToXElement_ArrayNullKey_ThrowsArgumentException()
-		{
-			JsonValue json = new JsonArray {false, 42, "a string"};
-			var actual = json.ToXElement(null);
-		}
-		[TestMethod]
-		public void ToXElement_ArrayWithKey_MapsCorrectly()
-		{
-			var key = "aKey";
-			JsonValue json = new JsonArray {false, 42, "a string"};
-			var expected = new XElement(key);
-			var xml = new XElement(key, false);
-			expected.Add(xml);
-			xml = new XElement(key, 42);
-			expected.Add(xml);
-			xml = new XElement(key, "a string");
-			expected.Add(xml);
-
-			var actual = json.ToXElement(key);
-
-			Assert.IsTrue(XNode.DeepEquals(expected, actual));
-		}
-		[TestMethod]
-		public void ToXElement_ArrayWithNestedArray_MapsCorrectly()
-		{
-			var key = "aKey";
-			JsonValue json = new JsonArray {false, 42, new JsonArray {"a string"}};
-			var expected = new XElement(key);
-			var xml = new XElement(key, false);
-			expected.Add(xml);
-			xml = new XElement(key, 42);
-			expected.Add(xml);
-			xml = new XElement(key);
-			var inner = new XElement(key, "a string");
-			xml.Add(inner);
-			xml.SetAttributeValue("nest", true);
-			expected.Add(xml);
-
-			var actual = json.ToXElement(key);
-
-			Assert.IsTrue(XNode.DeepEquals(expected, actual));
-		}
-		[TestMethod]
-		public void ToXElement_ArrayWithNestedArrayWithNestedObjectContainingSameKey_MapsCorrectly()
-		{
-			var key = "aKey";
-			JsonValue json = new JsonArray {false, 42, new JsonArray {"a string", new JsonObject {{key, 6}}}};
-			var expected = new XElement(key);
-			var xml = new XElement(key, false);
-			expected.Add(xml);
-			xml = new XElement(key, 42);
-			expected.Add(xml);
-			xml = new XElement(key);
-			var inner = new XElement(key, "a string");
-			xml.Add(inner);
-			inner = new XElement(key);
-			var obj = new XElement(key, 6);
-			inner.Add(obj);
-			xml.Add(inner);
-			xml.SetAttributeValue("nest", true);
-			expected.Add(xml);
-
-			var actual = json.ToXElement(key);
-
-			Assert.IsTrue(XNode.DeepEquals(expected, actual));
-		}
-		#endregion
-		#region Null
-		[TestMethod]
-		[ExpectedException(typeof(ArgumentException))]
-		public void ToXElement_NullNullKey_ThrowsArgumentException()
-		{
-			JsonValue json = true;
-			var actual = json.ToXElement(null);
-		}
-		[TestMethod]
-		public void ToXElement_NullWithKey_MapsCorrectly()
-		{
-			var key = "aKey";
-			JsonValue json = JsonValue.Null;
-			var expected = new XElement(key);
-
-			var actual = json.ToXElement(key);
-
-			Assert.IsTrue(XNode.DeepEquals(expected, actual));
-		}
-		[TestMethod]
-		public void ToJson_ElementWithNullValue_MapsCorrectly()
-		{
-			var key = "aKey";
-			var xml = new XElement(key);
-			JsonValue expected = new JsonObject {{key, JsonValue.Null}};
-
-			var actual = xml.ToJson();
-
-			Assert.AreEqual(expected, actual);
-		}
-		#endregion
-		#region Complex
-		[TestMethod]
-		public void ToXElement_ComplexObject_MapsCorrectly()
-		{
-			JsonValue json = new JsonObject
-			           			{
-			           				{"string","a string"},
-									{"number", 42},
-									{"array", new JsonArray{-6, JsonValue.Null, true, new JsonArray{Math.PI, false, "another string"}}},
-									{"object", new JsonObject
-							           			{
-							           				{"string", "yet another string"},
-													{"object", new JsonObject{{"number", 263.5},{"array",new JsonArray{1,2,new JsonObject{{"single",1}}}}}}
-							           			}}
-			           			};
-			var expected = new XElement("root");
-			var element1 = new XElement("string", "a string");
-			expected.Add(element1);
-			element1 = new XElement("number", 42);
-			expected.Add(element1);
-			element1 = new XElement("array", -6);
-			expected.Add(element1);
-			element1 = new XElement("array");
-			expected.Add(element1);
-			element1 = new XElement("array", true);
-			expected.Add(element1);
-			element1 = new XElement("array");
-			element1.SetAttributeValue("nest", true);
-			var element2 = new XElement("array", Math.PI);
-			element1.Add(element2);
-			element2 = new XElement("array", false);
-			element1.Add(element2);
-			element2 = new XElement("array", "another string");
-			element1.Add(element2);
-			expected.Add(element1);
-			element1 = new XElement("object");
-			element2 = new XElement("string", "yet another string");
-			element1.Add(element2);
-			element2 = new XElement("object");
-			var element3 = new XElement("number", 263.5);
-			element2.Add(element3);
-			element3 = new XElement("array", 1);
-			element2.Add(element3);
-			element3 = new XElement("array", 2);
-			element2.Add(element3);
-			element3 = new XElement("array");
-			var element4 = new XElement("single", 1);
-			element3.Add(element4);
-			element2.Add(element3);
-			element1.Add(element2);
-			expected.Add(element1);
-
-			var actual = json.ToXElement("root");
-
-			Assert.IsTrue(XNode.DeepEquals(expected, actual));
-		}
-		[TestMethod]
-		public void ToJson_ComplexElement_MapsCorrectly()
-		{
-			var list = new List<XElement>();
-			var element1 = new XElement("string", "a string");
-			list.Add(element1);
-			element1 = new XElement("number", 42);
-			list.Add(element1);
-			element1 = new XElement("array", -6);
-			list.Add(element1);
-			element1 = new XElement("array");
-			list.Add(element1);
-			element1 = new XElement("array", true);
-			list.Add(element1);
-			element1 = new XElement("array");
-			element1.SetAttributeValue("nest", true);
-			var element2 = new XElement("array", Math.PI);
-			element1.Add(element2);
-			element2 = new XElement("array", false);
-			element1.Add(element2);
-			element2 = new XElement("array", "another string");
-			element1.Add(element2);
-			list.Add(element1);
-			element1 = new XElement("object");
-			element2 = new XElement("string", "yet another string");
-			element1.Add(element2);
-			element2 = new XElement("object");
-			var element3 = new XElement("number", 263.5);
-			element2.Add(element3);
-			element3 = new XElement("array", 1);
-			element2.Add(element3);
-			element3 = new XElement("array", 2);
-			element2.Add(element3);
-			element3 = new XElement("array");
-			var element4 = new XElement("single", 1);
-			element3.Add(element4);
-			element2.Add(element3);
-			element1.Add(element2);
-			list.Add(element1);
-			JsonValue expected = new JsonObject
-			           				{
-			           					{"string","a string"},
-										{"number", 42},
-										{"array", new JsonArray{-6, JsonValue.Null, true, new JsonArray{Math.PI, false, "another string"}}},
-										{"object", new JsonObject
-							           				{
-							           					{"string", "yet another string"},
-														{"object", new JsonObject{{"number", 263.5},{"array",new JsonArray{1,2,new JsonObject{{"single",1}}}}}}
-							           				}}
-			           				};
-
-			var actual = list.ToJson();
-
-			Assert.AreEqual(expected, actual);
-		}
-		[TestMethod]
-		public void RoundTrip_StartingWithJson()
-		{
-			JsonValue json = new JsonObject
-			           			{
-			           				{"string","a string"},
-									{"number", 42},
-									{"array", new JsonArray{-6, JsonValue.Null, true, new JsonArray{Math.PI, false, "another string"}}},
-									{"object", new JsonObject
-							           			{
-							           				{"string", "yet another string"},
-													{"object", new JsonObject{{"number", 263.5},{"array",new JsonArray{1,2,new JsonObject{{"single",1}}}}}}
-							           			}}
-			           			};
-			var expected = new JsonObject {{"root", json}};
-
-			var toXElement = json.ToXElement("root");
-			var actual = toXElement.ToJson();
-
-			Assert.AreEqual(expected, actual);
-		}
-		[TestMethod]
-		public void RoundTrip_StartingWithXml()
-		{
-			var expected = XElement.Parse(@"<Requests><Request><SearchCustomerRequest xmlns:i=""http://www.w3.org/2001/XMLSchema-instance"" xmlns=""http://www.manatee.com/services/""><MachineName xmlns=""http://www.manatee.com/services/sub/"">USA02415-2</MachineName><SearchContext xmlns:d2p1=""http://www.manatee.com/services/""><d2p1:CustomerId i:nil=""true"" /><d2p1:EdgeId /><d2p1:EmailAddress /><d2p1:LastName /><d2p1:LoyaltyCardNumber>1234567890123</d2p1:LoyaltyCardNumber><d2p1:MaxRows i:nil=""true"" /><d2p1:PhoneNumber /><d2p1:ZipCode /></SearchContext></SearchCustomerRequest></Request></Requests>");
-			var expectedJson = JsonValue.Parse(@"{""Requests"":{""Request"":{""SearchCustomerRequest"":[{""-xmlns:i"":""http:\/\/www.w3.org\/2001\/XMLSchema-instance"",""-xmlns"":""http:\/\/www.manatee.com\/services\/""},{""MachineName"":[{""-xmlns"":""http:\/\/www.manatee.com\/services\/sub\/""},""USA02415-2""],""d2p1:SearchContext"":[{""-xmlns:d2p1"":""http:\/\/www.manatee.com\/services\/""},{""d2p1:CustomerId"":[{""-i:nil"":true},null],""d2p1:EdgeId"":null,""d2p1:EmailAddress"":null,""d2p1:LastName"":null,""d2p1:LoyaltyCardNumber"":1234567890123,""d2p1:MaxRows"":[{""-i:nil"":true},null],""d2p1:PhoneNumber"":null,""d2p1:ZipCode"":null}]}]}}}");
-
-			var toJson = expected.ToJson();
-			Assert.AreEqual(expectedJson, toJson);
-
-			var actual = toJson.ToXElement(null);
-
-			Assert.AreEqual(expected.ToString(), actual.ToString());
-		}
-		#endregion
-	}
-}

File Json.Tests/Json/JsonArrayTest.cs

-/***************************************************************************************
-
-	Copyright 2012 Greg Dennis
-
-	   Licensed under the Apache License, Version 2.0 (the "License");
-	   you may not use this file except in compliance with the License.
-	   You may obtain a copy of the License at
-
-		 http://www.apache.org/licenses/LICENSE-2.0
-
-	   Unless required by applicable law or agreed to in writing, software
-	   distributed under the License is distributed on an "AS IS" BASIS,
-	   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-	   See the License for the specific language governing permissions and
-	   limitations under the License.
- 
-	File Name:		JsonArrayTest.cs
-	Namespace:		Manatee.Tests.Json
-	Class Name:		JsonArrayTest
-	Purpose:		Tests for JsonArray.
-
-***************************************************************************************/
-using Manatee.Json;
-using Manatee.Json.Exceptions;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-
-namespace Manatee.Tests.Json
-{
-	[TestClass]
-	public class JsonArrayTest
-	{
-		[TestMethod]
-		public void ToString_ReturnsCorrectString()
-		{
-			var json = new JsonArray {false, 42, "a string"};
-			var expected = "[false,42,\"a string\"]";
-			var actual = json.ToString();
-			Assert.AreEqual(expected, actual);
-		}
-		[TestMethod]
-		public void Equals_SameValuesSameOrder_ReturnsTrue()
-		{
-			var json1 = new JsonArray { false, 42, "a string" };
-			var json2 = new JsonArray { false, 42, "a string" };
-			Assert.IsTrue(json1.Equals(json2));
-		}
-		[TestMethod]
-		public void Equals_SameValuesDifferentOrder_ReturnsTrue()
-		{
-			var json1 = new JsonArray { false, 42, "a string" };
-			var json2 = new JsonArray { 42, false, "a string" };
-			Assert.IsTrue(json1.Equals(json2));
-		}
-		[TestMethod]
-		public void Equals_DifferentValues_ReturnsFalse()
-		{
-			var json1 = new JsonArray { false, 42, "a string" };
-			var json2 = new JsonArray { false, "42", "a string" };
-			Assert.IsFalse(json1.Equals(json2));
-		}
-		[TestMethod]
-		public void Parse_ValidString_ReturnsCorrectArray()
-		{
-			var s = "[false,42,\"a string\"]";
-			var expected = new JsonArray { false, 42, "a string" };
-			var i = 0;
-			var actual = new JsonArray(s, ref i);
-			Assert.AreEqual(expected, actual);
-		}
-		[TestMethod]
-		public void Parse_EmptyArray_ReturnsEmptyArray()
-		{
-			var s = "[]";
-			var expected = new JsonArray();
-			var i = 0;
-			var actual = new JsonArray(s, ref i);
-			Assert.AreEqual(expected, actual);
-		}
-		[TestMethod]
-		[ExpectedException(typeof(JsonSyntaxException))]
-		public void Parse_StringMissingValue_ThrowsJsonSyntaxException()
-		{
-			var s = "[false,,\"a string\"]";
-			var i = 0;
-			var actual = new JsonArray(s, ref i);
-		}
-		[TestMethod]
-		[ExpectedException(typeof(JsonSyntaxException))]
-		public void Parse_StringMissingOpenBracket_ThrowsJsonSyntaxException()
-		{
-			var s = "false,42,\"a string\"]";
-			var i = 0;
-			var actual = new JsonArray(s, ref i);
-		}
-		[TestMethod]
-		[ExpectedException(typeof(JsonSyntaxException))]
-		public void Parse_StringMissingCloseBracket_ThrowsJsonSyntaxException()
-		{
-			var s = "[false,42,\"a string\"";
-			var i = 0;
-			var actual = new JsonArray(s, ref i);
-		}
-	}
-}

File Json.Tests/Json/JsonObjectTest.cs

-/***************************************************************************************
-
-	Copyright 2012 Greg Dennis
-
-	   Licensed under the Apache License, Version 2.0 (the "License");
-	   you may not use this file except in compliance with the License.
-	   You may obtain a copy of the License at
-
-		 http://www.apache.org/licenses/LICENSE-2.0
-
-	   Unless required by applicable law or agreed to in writing, software
-	   distributed under the License is distributed on an "AS IS" BASIS,
-	   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-	   See the License for the specific language governing permissions and
-	   limitations under the License.
- 
-	File Name:		JsonObjectTest.cs
-	Namespace:		Manatee.Tests.Json
-	Class Name:		JsonObjectTest
-	Purpose:		Tests for JsonObject.
-
-***************************************************************************************/
-using Manatee.Json;
-using Manatee.Json.Exceptions;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-
-namespace Manatee.Tests.Json
-{
-	[TestClass]
-	public class JsonObjectTest
-	{
-		[TestMethod]
-		public void ToString_ReturnsCorrectString()
-		{
-			var json = new JsonObject {{"bool", false}, {"int", 42}, {"string", "a string"}};
-			var expected = "{\"bool\":false,\"int\":42,\"string\":\"a string\"}";
-			var actual = json.ToString();
-			Assert.AreEqual(expected, actual);
-		}
-		[TestMethod]
-		public void Equals_SameValuesSameOrder_ReturnsTrue()
-		{
-			var json1 = new JsonObject {{"bool", false}, {"int", 42}, {"string", "a string"}};
-			var json2 = new JsonObject {{"bool", false}, {"int", 42}, {"string", "a string"}};
-			Assert.IsTrue(json1.Equals(json2));
-		}
-		[TestMethod]
-		public void Equals_SameValuesDifferentOrder_ReturnsTrue()
-		{
-			var json1 = new JsonObject {{"int", 42}, {"bool", false}, {"string", "a string"}};
-			var json2 = new JsonObject {{"bool", false}, {"int", 42}, {"string", "a string"}};
-			Assert.IsTrue(json1.Equals(json2));
-		}
-		[TestMethod]
-		public void Equals_DifferentValues_ReturnsFalse()
-		{
-			var json1 = new JsonObject {{"bool", false}, {"int", 42}, {"string", "a string"}};
-			var json2 = new JsonObject {{"bool", false}, {"int", "42"}, {"string", "a string"}};
-			Assert.IsFalse(json1.Equals(json2));
-		}
-		[TestMethod]
-		public void Parse_ValidString_ReturnsCorrectObject()
-		{
-			var s = "{\"bool\":false,\"int\":42,\"string\":\"a string\"}";
-			var expected = new JsonObject {{"bool", false}, {"int", 42}, {"string", "a string"}};
-			var actual = new JsonObject(s);
-			Assert.AreEqual(expected, actual);
-		}
-		[TestMethod]
-		public void Parse_EmptyObject_ReturnsEmptyObject()
-		{
-			var s = "{}";
-			var expected = new JsonObject();
-			var i = 0;
-			var actual = new JsonObject(s, ref i);
-			Assert.AreEqual(expected, actual);
-		}
-		[TestMethod]
-		[ExpectedException(typeof(JsonSyntaxException))]
-		public void Parse_StringMissingValue_ThrowsJsonSyntaxException()
-		{
-			var s = "{\"bool\":false,\"int\":,\"string\":\"a string\"}";
-			var actual = new JsonObject(s);
-		}
-		[TestMethod]
-		[ExpectedException(typeof(JsonSyntaxException))]
-		public void Parse_StringMissingKey_ThrowsJsonSyntaxException()
-		{
-			var s = "{\"bool\":false,:42,\"string\":\"a string\"}";
-			var actual = new JsonObject(s);
-		}
-		[TestMethod]
-		[ExpectedException(typeof(JsonSyntaxException))]
-		public void Parse_StringMissingKeyValue_ThrowsJsonSyntaxException()
-		{
-			var s = "{\"bool\":false,,\"string\":\"a string\"}";
-			var actual = new JsonObject(s);
-		}
-		[TestMethod]
-		[ExpectedException(typeof(JsonSyntaxException))]
-		public void Parse_StringMissingKeyValueDelimiter_ThrowsJsonSyntaxException()
-		{
-			var s = "{\"bool\":false,\"int\"42,\"string\":\"a string\"}";
-			var actual = new JsonObject(s);
-		}
-		[TestMethod]
-		[ExpectedException(typeof(JsonValueParseException))]
-		public void Parse_StringMissingDelimiter_ThrowsJsonValueParseException()
-		{
-			var s = "{\"bool\":false,\"int\":42\"string\":\"a string\"}";
-			var actual = new JsonObject(s);
-		}
-		[TestMethod]
-		[ExpectedException(typeof(JsonSyntaxException))]
-		public void Parse_StringMissingOpenBrace_ThrowsJsonSyntaxException()
-		{
-			var s = "\"bool\":false,\"int\":42,\"string\":\"a string\"}";
-			var actual = new JsonObject(s);
-		}
-		[TestMethod]
-		[ExpectedException(typeof(JsonSyntaxException))]
-		public void Parse_StringMissingCloseBrace_ThrowsJsonSyntaxException()
-		{
-			var s = "{\"bool\":false,\"int\":42,\"string\":\"a string\"";
-			var actual = new JsonObject(s);
-		}
-		[TestMethod]
-		public void Parse_StringFromSourceForge_kheimric()
-		{
-			var s = @"{
-  ""self"": ""self"",
-  ""name"": ""name"",
-  ""emailAddress"": ""test at test dot com"",
-  ""avatarUrls"": {
-	""16x16"": ""http://smallUrl"",
-	""48x48"": ""https://largeUrl""
-  },
-  ""displayName"": ""Display Name"",
-  ""active"": true,
-  ""timeZone"": ""Europe"",
-  ""groups"": {
-	""size"": 1,
-	""items"": [
-	  {
-		""name"": ""users""
-	  }
-	]
-  },
-  ""expand"": ""groups""
-}";
-			var actual = new JsonObject(s);
-			var newString = actual.ToString();
-		}
-		[TestMethod]
-		public void Add_NullValueAddsJsonNull()
-		{
-			var obj = new JsonObject();
-			obj.Add("null", null);
-
-			Assert.AreEqual(1, obj.Count);
-			Assert.AreEqual(JsonValue.Null, obj["null"]);
-		}
-		[TestMethod]
-		public void Indexer_NullValueAddsJsonNull()
-		{
-			var obj = new JsonObject();
-			obj["null"] = null;
-
-			Assert.AreEqual(1, obj.Count);
-			Assert.AreEqual(JsonValue.Null, obj["null"]);
-		}
-	}
-}

File Json.Tests/Json/JsonValueTest.cs

-/***************************************************************************************
-
-	Copyright 2012 Greg Dennis
-
-	   Licensed under the Apache License, Version 2.0 (the "License");
-	   you may not use this file except in compliance with the License.
-	   You may obtain a copy of the License at
-
-		 http://www.apache.org/licenses/LICENSE-2.0
-
-	   Unless required by applicable law or agreed to in writing, software
-	   distributed under the License is distributed on an "AS IS" BASIS,
-	   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-	   See the License for the specific language governing permissions and
-	   limitations under the License.
- 
-	File Name:		JsonValueTest.cs
-	Namespace:		Manatee.Tests.Json
-	Class Name:		JsonValueTest
-	Purpose:		Tests for JsonValue.
-
-***************************************************************************************/
-using System;
-using System.Linq;
-using Manatee.Json;
-using Manatee.Json.Enumerations;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using Manatee.Json.Exceptions;
-
-namespace Manatee.Tests.Json
-{
-	[TestClass]
-	public class JsonValueTest
-	{
-		#region Accessor Tests
-		[TestMethod]
-		public void Accessor_GetBoolWhenBool_ReturnsValue()
-		{
-			var json = new JsonValue(true);
-			var expected = true;
-			var actual = json.Boolean;
-			Assert.AreEqual(expected, actual);
-		}
-		[TestMethod]
-		public void Accessor_GetNumberWhenNumber_ReturnsValue()
-		{
-			var json = new JsonValue(42);
-			double expected = 42;
-			var actual = json.Number;
-			Assert.AreEqual(expected, actual);
-		}
-		[TestMethod]
-		public void Accessor_GetStringWhenString_ReturnsValue()
-		{
-			var json = new JsonValue("a string");
-			var expected = "a string";
-			var actual = json.String;
-			Assert.AreEqual(expected, actual);
-		}
-		[TestMethod]
-		public void Accessor_GetArrayWhenArray_ReturnsValue()
-		{
-			var json = new JsonValue(new JsonArray{false, 42, "a string"});
-			var expected = new JsonArray {false, 42, "a string"};
-			var actual = json.Array;
-			Assert.AreEqual(expected, actual);
-		}
-		[TestMethod]
-		public void Accessor_GetObjectWhenObject_ReturnsValue()
-		{
-			var json = new JsonValue(new JsonObject {{"bool", false}, {"int", 42}, {"string", "a string"}});
-			var expected = new JsonObject {{"bool", false}, {"int", 42}, {"string", "a string"}};
-			var actual = json.Object;
-			Assert.AreEqual(expected, actual);
-		}
-		[TestMethod]
-		[ExpectedException(typeof(JsonValueIncorrectTypeException))]
-		public void Accessor_GetBoolWhenNotBool_ThrowsJsonValueIncorrectTypeException()
-		{
-			var json = JsonValue.Null;
-			var actual = json.Boolean;
-		}
-		[TestMethod]
-		[ExpectedException(typeof(JsonValueIncorrectTypeException))]
-		public void Accessor_GetNumberWhenNotNumber_ThrowsJsonValueIncorrectTypeException()
-		{
-			var json = JsonValue.Null;
-			var actual = json.Number;
-		}
-		[TestMethod]
-		[ExpectedException(typeof(JsonValueIncorrectTypeException))]
-		public void Accessor_GetStringWhenNotString_ThrowsJsonValueIncorrectTypeException()
-		{
-			var json = JsonValue.Null;
-			var actual = json.String;
-		}
-		[TestMethod]
-		[ExpectedException(typeof(JsonValueIncorrectTypeException))]
-		public void Accessor_GetArrayWhenNotArray_ThrowsJsonValueIncorrectTypeException()
-		{
-			var json = JsonValue.Null;
-			var actual = json.Array;
-		}
-		[TestMethod]
-		[ExpectedException(typeof(JsonValueIncorrectTypeException))]
-		public void Accessor_GetObjectWhenNotObject_ThrowsJsonValueIncorrectTypeException()
-		{
-			var json = JsonValue.Null;
-			var actual = json.Object;
-		}
-		#endregion
-
-		#region ToString Tests
-		[TestMethod]
-		public void ToString_BoolFalse_ReturnsCorrectString()
-		{
-			var json = new JsonValue(false);
-			var expected = "false";
-			var actual = json.ToString();
-			Assert.AreEqual(expected, actual);
-		}
-		[TestMethod]
-		public void ToString_BoolTrue_ReturnsCorrectString()
-		{
-			var json = new JsonValue(true);
-			var expected = "true";
-			var actual = json.ToString();
-			Assert.AreEqual(expected, actual);
-		}
-		[TestMethod]
-		public void ToString_Number_ReturnsCorrectString()
-		{
-			var json = new JsonValue(42);
-			var expected = "42";
-			var actual = json.ToString();
-			Assert.AreEqual(expected, actual);
-		}
-		[TestMethod]
-		public void ToString_String_ReturnsCorrectString()
-		{
-			var json = new JsonValue("a string");
-			var expected = "\"a string\"";
-			var actual = json.ToString();
-			Assert.AreEqual(expected, actual);
-		}
-		[TestMethod]
-		public void ToString_Array_ReturnsCorrectString()
-		{
-			var json = new JsonValue(new JsonArray { false, 42, "a string" });
-			var expected = "[false,42,\"a string\"]";
-			var actual = json.ToString();
-			Assert.AreEqual(expected, actual);
-		}
-		[TestMethod]
-		public void ToString_Object_ReturnsCorrectString()
-		{
-			var json = new JsonValue(new JsonObject {{"bool", false}, {"int", 42}, {"string", "a string"}});
-			var expected = "{\"bool\":false,\"int\":42,\"string\":\"a string\"}";
-			var actual = json.ToString();
-			Assert.AreEqual(expected, actual);
-		}
-		[TestMethod]
-		public void ToString_Null_ReturnsCorrectString()
-		{
-			var json = new JsonValue();
-			var expected = "null";
-			var actual = json.ToString();
-			Assert.AreEqual(expected, actual);
-		}
-		[TestMethod]
-		public void ToString_EscapableCharacters_ReturnsCorrectString()
-		{
-			JsonValue json1 = new JsonValue("These\" are/ some\\ of\b the\f escapable\n characters."),
-					  json2 = new JsonValue("Here\r are\t some" + (char)0x25A0 + " more" + (char)0x009F + ".");
-			var expected1 = "\"These\\\" are\\/ some\\\\ of\\b the\\f escapable\\n characters.\"";
-			var expected2 = "\"Here\\r are\\t some" + (char)0x25A0 + " more\\u009F.\"";
-			var actual1 = json1.ToString();
-			var actual2 = json2.ToString();
-
-			Assert.AreEqual(expected1, actual1);
-			Assert.AreEqual(expected2, actual2);
-		}
-		#endregion
-
-		#region Equals Tests
-		[TestMethod]
-		public void Equals_SameTypeSameValue_ReturnsTrue()
-		{
-			var json1 = new JsonValue(42);
-			var json2 = new JsonValue(42);
-			Assert.IsTrue(json1.Equals(json2));
-		}
-		[TestMethod]
-		public void Equals_SameTypeDifferentValues_ReturnsFalse()
-		{
-			var json1 = new JsonValue(42);
-			var json2 = new JsonValue(43);
-			Assert.IsFalse(json1.Equals(json2));
-		}
-		[TestMethod]
-		public void Equals_DifferentTypeDifferentValues_ReturnsFalse()
-		{
-			var json1 = new JsonValue(42);
-			var json2 = new JsonValue("42");
-			Assert.IsFalse(json1.Equals(json2));
-		}
-		#endregion
-
-		#region Parse Tests
-		[TestMethod]
-		public void Parse_StringWithBoolFalse_ReturnsCorrectJsonValue()
-		{
-			var s = "false";
-			var expected = new JsonValue(false);
-			var actual = JsonValue.Parse(s);
-			Assert.AreEqual(expected, actual);
-		}
-		[TestMethod]
-		public void Parse_StringWithBoolTrue_ReturnsCorrectJsonValue()
-		{
-			var s = "true";
-			var expected = new JsonValue(true);
-			var actual = JsonValue.Parse(s);
-			Assert.AreEqual(expected, actual);
-		}
-		[TestMethod]
-		public void Parse_StringWithNumber_ReturnsCorrectJsonValue()
-		{
-			var s = "42";
-			var expected = new JsonValue(42);
-			var actual = JsonValue.Parse(s);
-			Assert.AreEqual(expected, actual);
-		}
-		[TestMethod]
-		public void Parse_StringWithString_ReturnsCorrectJsonValue()
-		{
-			var s = "\"a string\"";
-			var expected = new JsonValue("a string");
-			var actual = JsonValue.Parse(s);
-			Assert.AreEqual(expected, actual);
-		}
-		[TestMethod]
-		public void Parse_StringWithArray_ReturnsCorrectJsonValue()
-		{
-			var s = "[false,42,\"a string\"]";
-			var expected = new JsonValue(new JsonArray {false, 42, "a string"});
-			var actual = JsonValue.Parse(s);
-			Assert.AreEqual(expected, actual);
-		}
-		[TestMethod]
-		public void Parse_StringWithObject_ReturnsCorrectJsonValue()
-		{
-			var s = "{\"bool\":false,\"int\":42,\"string\":\"a string\"}";
-			var expected = new JsonValue(new JsonObject {{"bool", false}, {"int", 42}, {"string", "a string"}});
-			var actual = JsonValue.Parse(s);
-			Assert.AreEqual(expected, actual);
-		}
-		[TestMethod]
-		public void Parse_StringWithNull_ReturnsCorrectJsonValue()
-		{
-			var s = "null";
-			var expected = JsonValue.Null;
-			var actual = JsonValue.Parse(s);
-			Assert.AreEqual(expected, actual);
-		}
-		[TestMethod]
-		[ExpectedException(typeof(JsonValueParseException))]
-		public void Parse_StringWithBadToken_ThrowsJsonValueParseException()
-		{
-			var s = "invalid data";
-			var actual = JsonValue.Parse(s);
-		}
-		[TestMethod]
-		public void Parse_StringValueWithEscapedQuote_ReturnsCorrectJsonValue()
-		{
-			var json = "\"An \\\"escaped\\\" quote\"";
-			JsonValue expected = "An \"escaped\" quote";
-			var actual = JsonValue.Parse(json);
-
-			Assert.AreEqual(expected.String, actual.String);
-		}
-		[TestMethod]
-		public void Parse_StringValueWithEscapedSolidus_ReturnsCorrectJsonValue()
-		{
-			var json = "\"An \\\\escaped\\\\ solidus\"";
-			JsonValue expected = "An \\escaped\\ solidus";
-			var actual = JsonValue.Parse(json);
-
-			Assert.AreEqual(expected.String, actual.String);
-		}
-		[TestMethod]
-		public void Parse_StringValueWithEscapedReverseSolidus_ReturnsCorrectJsonValue()
-		{
-			var json = "\"An \\/escaped\\/ reverse solidus\"";
-			JsonValue expected = "An /escaped/ reverse solidus";
-			var actual = JsonValue.Parse(json);
-
-			Assert.AreEqual(expected.String, actual.String);
-		}
-		[TestMethod]
-		public void Parse_StringValueWithEscapedBackspace_ReturnsCorrectJsonValue()
-		{
-			var json = "\"An \\bescaped\\b backspace\"";
-			JsonValue expected = "An \bescaped\b backspace";
-			var actual = JsonValue.Parse(json);
-
-			Assert.AreEqual(expected.String, actual.String);
-		}
-		[TestMethod]
-		public void Parse_StringValueWithEscapedFormFeed_ReturnsCorrectJsonValue()
-		{
-			var json = "\"An \\fescaped\\f form feed\"";
-			JsonValue expected = "An \fescaped\f form feed";
-			var actual = JsonValue.Parse(json);
-
-			Assert.AreEqual(expected.String, actual.String);
-		}
-		[TestMethod]
-		public void Parse_StringValueWithEscapedNewLine_ReturnsCorrectJsonValue()
-		{
-			var json = "\"An \\nescaped\\n new line\"";
-			JsonValue expected = "An \nescaped\n new line";
-			var actual = JsonValue.Parse(json);
-
-			Assert.AreEqual(expected.String, actual.String);
-		}
-		[TestMethod]
-		public void Parse_StringValueWithEscapedCarriageReturn_ReturnsCorrectJsonValue()
-		{
-			var json = "\"An \\rescaped\\r carriage return\"";
-			JsonValue expected = "An \rescaped\r carriage return";
-			var actual = JsonValue.Parse(json);
-
-			Assert.AreEqual(expected.String, actual.String);
-		}
-		[TestMethod]
-		public void Parse_StringValueWithEscapedHorizontalTab_ReturnsCorrectJsonValue()
-		{
-			var json = "\"An \\tescaped\\t horizontal tab\"";
-			JsonValue expected = "An \tescaped\t horizontal tab";
-			var actual = JsonValue.Parse(json);
-
-			Assert.AreEqual(expected.String, actual.String);
-		}
-		[TestMethod]
-		public void Parse_StringValueWithEscapedHexadecimalValue_ReturnsCorrectJsonValue()
-		{
-			var json = "\"An \\u25A0escaped\\u25A0 hex value\"";
-			JsonValue expected = "An " + (char)0x25A0 + "escaped" + (char)0x25A0 + " hex value";
-			var actual = JsonValue.Parse(json);
-
-			Assert.AreEqual(expected.String, actual.String);
-		}
-		#endregion
-
-		#region Operator Tests
-		[TestMethod]
-		public void CastOperator_Bool_AssignsCorrectValue()
-		{
-			var json = new JsonValue();
-			Assert.AreEqual(JsonValueType.Null, json.Type);
-			json = false;
-			var expected = false;
-			Assert.AreEqual(JsonValueType.Boolean, json.Type);
-			Assert.AreEqual(expected, json.Boolean);
-		}
-		[TestMethod]
-		public void CastOperator_Number_AssignsCorrectValue()
-		{
-			var json = new JsonValue();
-			Assert.AreEqual(JsonValueType.Null, json.Type);
-			json = 42;
-			var expected = 42;
-			Assert.AreEqual(JsonValueType.Number, json.Type);
-			Assert.AreEqual(expected, json.Number);
-		}
-		[TestMethod]
-		public void CastOperator_String_AssignsCorrectValue()
-		{
-			var json = new JsonValue();
-			Assert.AreEqual(JsonValueType.Null, json.Type);
-			json = "a string";
-			var expected = "a string";
-			Assert.AreEqual(JsonValueType.String, json.Type);
-			Assert.AreEqual(expected, json.String);
-		}
-		[TestMethod]
-		public void CastOperator_Array_AssignsCorrectValue()
-		{
-			var json = new JsonValue();
-			Assert.AreEqual(JsonValueType.Null, json.Type);
-			json = new JsonArray {false, 42, "a string", "another string"};
-			var expected = new JsonArray {false, 42, "a string", "another string"};
-			Assert.AreEqual(JsonValueType.Array, json.Type);
-			Assert.AreEqual(expected, json.Array);
-		}
-		[TestMethod]
-		public void CastOperator_Object_AssignsCorrectValue()
-		{
-			var json = new JsonValue();
-			Assert.AreEqual(JsonValueType.Null, json.Type);
-			json = new JsonObject {{"bool", false}, {"int", 42}, {"string", "a string"}};
-			var expected = new JsonObject {{"bool", false}, {"int", 42}, {"string", "a string"}};
-			Assert.AreEqual(JsonValueType.Object, json.Type);
-			Assert.AreEqual(expected, json.Object);
-		}
-		#endregion
-	}
-}

File Json.Tests/Json/Serialization/Internal/TypeGeneratorTest.cs

-using System;
-using Manatee.Json.Serialization.Internal;
-using Manatee.Tests.Test_References;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-
-namespace Manatee.Tests.Json.Serialization.Internal
-{
-	[TestClass]
-	public class TypeGeneratorTest
-	{
-		[TestMethod]
-		public void TypeCreation_Success()
-		{
-			var instance = TypeGenerator.Default.Generate<IInterface>();
-
-			Assert.IsNotNull(instance);
-		}
-		[TestMethod]
-		public void PropertyReadAndWrite_Success()
-		{
-			string stringProp = "test";
-
-			var instance = TypeGenerator.Default.Generate<IInterface>();
-			instance.RequiredProp = stringProp;
-
-			Assert.AreEqual(stringProp, instance.RequiredProp);
-		}
-		[TestMethod]
-		public void MethodCall_Success()
-		{
-			var instance = TypeGenerator.Default.Generate<IInterface>();
-
-			var actual = instance.RequiredMethod<int, IConvertible>(2.0);
-
-			Assert.AreEqual(default(int), actual);
-		}
-		[TestMethod]
-		public void EventSubscription_Success()
-		{
-			var instance = TypeGenerator.Default.Generate<IInterface>();
-
-			EventHandler handler = (o, e) => { };
-
-			instance.RequiredEvent += handler;
-			instance.RequiredEvent -= handler;
-		}
-		[TestMethod]