コード例 #1
0
        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);
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        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);
        }
コード例 #4
0
    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);
    }
コード例 #5
0
        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);
        }