public void Serialize_NullObject_IntegerNull() { // arrange var node = JSON.Parse(JsonObjectStringWithAllNull); var memoryStream = new MemoryStream(); var binaryWriter = new BinaryWriter(memoryStream); var binaryReader = new BinaryReader(memoryStream); // act node.Serialize(binaryWriter); memoryStream.Seek(0, SeekOrigin.Begin); node = JSONNode.Deserialize(binaryReader); // assert Assert.IsTrue(node["integer"].IsNull); }
public void Serialize_SimpleObject_NegativeExponentialSuccess() { // arrange var node = JSON.Parse(JsonObjectStringWithAllTypes); var memoryStream = new MemoryStream(); var binaryWriter = new BinaryWriter(memoryStream); var binaryReader = new BinaryReader(memoryStream); // act node.Serialize(binaryWriter); memoryStream.Seek(0, SeekOrigin.Begin); node = JSONNode.Deserialize(binaryReader); // assert Assert.AreEqual(0.0003, node["exponential"]["negative"].AsFloat, 0.000001); }
public void Serialize_SimpleObject_NegativeLongSuccess() { // arrange var node = JSON.Parse(JsonObjectStringWithAllTypes); var memoryStream = new MemoryStream(); var binaryWriter = new BinaryWriter(memoryStream); var binaryReader = new BinaryReader(memoryStream); // act node.Serialize(binaryWriter); memoryStream.Seek(0, SeekOrigin.Begin); node = JSONNode.Deserialize(binaryReader); // assert Assert.AreEqual(-1234567890000, node["long"]["negative"].AsLong); }
public void Serialize_SimpleObject_DoubleNegativeSuccess() { // arrange var node = JSON.Parse(JsonObjectStringWithAllTypes); var memoryStream = new MemoryStream(); var binaryWriter = new BinaryWriter(memoryStream); var binaryReader = new BinaryReader(memoryStream); // act node.Serialize(binaryWriter); memoryStream.Seek(0, SeekOrigin.Begin); node = JSONNode.Deserialize(binaryReader); // assert Assert.AreEqual(-3.14159265359, node["double"]["negative"].AsDouble, 0.000000000001); }
public void Serialize_SimpleObject_SpecialStringSuccess() { // arrange var node = JSON.Parse(JsonObjectStringWithAllTypes); var memoryStream = new MemoryStream(); var binaryWriter = new BinaryWriter(memoryStream); var binaryReader = new BinaryReader(memoryStream); // act node.Serialize(binaryWriter); memoryStream.Seek(0, SeekOrigin.Begin); node = JSONNode.Deserialize(binaryReader); // assert Assert.AreEqual(@":,[]{}""\\t\n\r\bA\f\m/", node["string"]["special"].Value); }
public void Serialize_SimpleObject_ExplicitPositiveIntegerSuccess() { // arrange var node = JSON.Parse(JsonObjectStringWithAllTypes); var memoryStream = new MemoryStream(); var binaryWriter = new BinaryWriter(memoryStream); var binaryReader = new BinaryReader(memoryStream); // act node.Serialize(binaryWriter); memoryStream.Seek(0, SeekOrigin.Begin); node = JSONNode.Deserialize(binaryReader); // assert Assert.AreEqual(1, node["integer"]["explicitPositive"].AsInt); }
public void Serialize_SimpleObject_PopulatedArrayObjectAtFive() { // arrange var node = JSON.Parse(JsonObjectStringWithAllTypes); var memoryStream = new MemoryStream(); var binaryWriter = new BinaryWriter(memoryStream); var binaryReader = new BinaryReader(memoryStream); // act node.Serialize(binaryWriter); memoryStream.Seek(0, SeekOrigin.Begin); node = JSONNode.Deserialize(binaryReader); // assert Assert.IsNotNull(node["array"]["populated"].AsArray[5].AsObject); }
public void Serialize_SimpleObject_PopulatedArrayStringAtThree() { // arrange var node = JSON.Parse(JsonObjectStringWithAllTypes); var memoryStream = new MemoryStream(); var binaryWriter = new BinaryWriter(memoryStream); var binaryReader = new BinaryReader(memoryStream); // act node.Serialize(binaryWriter); memoryStream.Seek(0, SeekOrigin.Begin); node = JSONNode.Deserialize(binaryReader); // assert Assert.AreEqual("string", node["array"]["populated"].AsArray[3].Value); }
public void Serialize_SimpleObject_EmptyArrayCountZero() { // arrange var node = JSON.Parse(JsonObjectStringWithAllTypes); var memoryStream = new MemoryStream(); var binaryWriter = new BinaryWriter(memoryStream); var binaryReader = new BinaryReader(memoryStream); // act node.Serialize(binaryWriter); memoryStream.Seek(0, SeekOrigin.Begin); node = JSONNode.Deserialize(binaryReader); // assert Assert.AreEqual(0, node["array"]["empty"].AsArray.Count); }
public void Serialize_SimpleObject_NullSuccess() { // arrange var node = JSON.Parse(JsonObjectStringWithAllTypes); var memoryStream = new MemoryStream(); var binaryWriter = new BinaryWriter(memoryStream); var binaryReader = new BinaryReader(memoryStream); // act node.Serialize(binaryWriter); memoryStream.Seek(0, SeekOrigin.Begin); node = JSONNode.Deserialize(binaryReader); // assert Assert.IsTrue(node["null"].IsNull); }
public void Serialize_SimpleObject_FalseBoolSuccess() { // arrange var node = JSON.Parse(JsonObjectStringWithAllTypes); var memoryStream = new MemoryStream(); var binaryWriter = new BinaryWriter(memoryStream); var binaryReader = new BinaryReader(memoryStream); // act node.Serialize(binaryWriter); memoryStream.Seek(0, SeekOrigin.Begin); node = JSONNode.Deserialize(binaryReader); // assert Assert.AreEqual(false, node["boolean"]["negative"].AsBool); }
public void Serialize_NullObject_StringNull() { // arrange var node = JSON.Parse(JsonObjectStringWithAllNull); var memoryStream = new MemoryStream(); var binaryWriter = new BinaryWriter(memoryStream); var binaryReader = new BinaryReader(memoryStream); // act node.Serialize(binaryWriter); memoryStream.Seek(0, SeekOrigin.Begin); node = JSONNode.Deserialize(binaryReader); // assert Assert.AreEqual("null", node["string"].Value); }