public void SerializeSqlBinaryClass() { SqlBinaryClass sqlBinaryClass = new SqlBinaryClass(); sqlBinaryClass.SqlBinary = new SqlBinary(TestData); sqlBinaryClass.NullableSqlBinary1 = new SqlBinary(TestData); sqlBinaryClass.NullableSqlBinary2 = null; string json = JsonConvert.SerializeObject(sqlBinaryClass, Formatting.Indented, new BinaryConverter()); Assert.AreEqual("{\r\n \"SqlBinary\": \"VGhpcyBpcyBzb21lIHRlc3QgZGF0YSEhIQ==\",\r\n \"NullableSqlBinary1\": \"VGhpcyBpcyBzb21lIHRlc3QgZGF0YSEhIQ==\",\r\n \"NullableSqlBinary2\": null\r\n}", json); }
public void DeserializeSqlBinaryClass() { string json = @"{ ""SqlBinary"": ""VGhpcyBpcyBzb21lIHRlc3QgZGF0YSEhIQ=="", ""NullableSqlBinary1"": ""VGhpcyBpcyBzb21lIHRlc3QgZGF0YSEhIQ=="", ""NullableSqlBinary2"": null }"; SqlBinaryClass sqlBinaryClass = JsonConvert.DeserializeObject <SqlBinaryClass>(json, new BinaryConverter()); Assert.AreEqual(new SqlBinary(TestData), sqlBinaryClass.SqlBinary); Assert.AreEqual(new SqlBinary(TestData), sqlBinaryClass.NullableSqlBinary1); Assert.AreEqual(null, sqlBinaryClass.NullableSqlBinary2); }
public void SerializeSqlBinaryClass() { SqlBinaryClass sqlBinaryClass = new SqlBinaryClass(); sqlBinaryClass.SqlBinary = new SqlBinary(TestData); sqlBinaryClass.NullableSqlBinary1 = new SqlBinary(TestData); sqlBinaryClass.NullableSqlBinary2 = null; string json = JsonConvert.SerializeObject(sqlBinaryClass, Formatting.Indented, new BinaryConverter()); StringAssert.AreEqual(@"{ ""SqlBinary"": ""VGhpcyBpcyBzb21lIHRlc3QgZGF0YSEhIQ=="", ""NullableSqlBinary1"": ""VGhpcyBpcyBzb21lIHRlc3QgZGF0YSEhIQ=="", ""NullableSqlBinary2"": null }", json); }
public void SerializeSqlBinaryClass() { SqlBinaryClass sqlBinaryClass = new SqlBinaryClass(); sqlBinaryClass.SqlBinary = new SqlBinary(TestData); sqlBinaryClass.NullableSqlBinary1 = new SqlBinary(TestData); sqlBinaryClass.NullableSqlBinary2 = null; string json = JsonConvert.SerializeObject(sqlBinaryClass, Formatting.Indented, new BinaryConverter()); Assert.AreEqual(@"{ ""SqlBinary"": ""VGhpcyBpcyBzb21lIHRlc3QgZGF0YSEhIQ=="", ""NullableSqlBinary1"": ""VGhpcyBpcyBzb21lIHRlc3QgZGF0YSEhIQ=="", ""NullableSqlBinary2"": null }", json); }