public void Deserialize() { MemoryStream stream = new MemoryStream(); (new BinaryFormatter()).Serialize(stream, 12345.6789D); byte[] bytes = SqlObject.AddSerializationHeader(stream.ToArray()); bool isJavaObject = true; object obj = SqlObject.Deserialize(bytes, out isJavaObject); Assert.IsFalse(isJavaObject); Assert.AreEqual(12345.6789D, obj); Assert.IsInstanceOfType(typeof(double), obj); }
public void AddSerializationHeader() { byte[] actual = SqlObject.AddSerializationHeader(new byte[] { 1, 2, 3, 4 }); Guid header = SqlObject.SerializationHeader; byte[] headerBytes = header.ToByteArray(); Assert.AreEqual(headerBytes.Length + 4, actual.Length); for (int i = 0; i < headerBytes.Length; i++) { Assert.AreEqual(headerBytes[i], actual[i]); } for (int i = headerBytes.Length, j = 1; i < headerBytes.Length + 4; i++, j++) { Assert.AreEqual(j, actual[i]); } }