public void MetadataPropertyHandlingIgnore() { MetadataPropertyDisabledTestClass c1 = new MetadataPropertyDisabledTestClass { Id = "Id!", Ref = "Ref!", Type = "Type!", Value = "Value!", Values = "Values!" }; string json = JsonConvert.SerializeObject(c1, Formatting.Indented); StringAssert.AreEqual(@"{ ""$id"": ""Id!"", ""$ref"": ""Ref!"", ""$value"": ""Value!"", ""$values"": ""Values!"", ""$type"": ""Type!"" }", json); MetadataPropertyDisabledTestClass c2 = JsonConvert.DeserializeObject <MetadataPropertyDisabledTestClass>(json, new JsonSerializerSettings { MetadataPropertyHandling = MetadataPropertyHandling.Ignore }); Assert.AreEqual("Id!", c2.Id); Assert.AreEqual("Ref!", c2.Ref); Assert.AreEqual("Type!", c2.Type); Assert.AreEqual("Value!", c2.Value); Assert.AreEqual("Values!", c2.Values); }
public void MetadataPropertyHandlingIgnore_EmptyObject() { string json = @"{}"; MetadataPropertyDisabledTestClass c = JsonConvert.DeserializeObject <MetadataPropertyDisabledTestClass>(json, new JsonSerializerSettings { MetadataPropertyHandling = MetadataPropertyHandling.Ignore }); Assert.AreEqual(null, c.Id); }
public void DeserializeCircularReferencesWithConverter() { string json = @"{ ""$id"": ""1"", ""$type"": ""CircularReferenceClass"" }"; MetadataPropertyDisabledTestClass c = new MetadataPropertyDisabledTestClass(); JsonConvert.PopulateObject(json, c, new JsonSerializerSettings { MetadataPropertyHandling = MetadataPropertyHandling.Ignore }); Assert.AreEqual("1", c.Id); Assert.AreEqual("CircularReferenceClass", c.Type); }
public void DeserializeCircularReferencesWithConverter() { string json = @"{ ""$id"": ""1"", ""$type"": ""CircularReferenceClass"" }"; MetadataPropertyDisabledTestClass c = new MetadataPropertyDisabledTestClass(); JsonConvert.PopulateObject(json, c, new JsonSerializerSettings { MetadataPropertyHandling = MetadataPropertyHandling.Ignore }); Assert.AreEqual("1", c.Id); Assert.AreEqual("CircularReferenceClass", c.Type); }
public void MetadataPropertyHandlingIgnore() { MetadataPropertyDisabledTestClass c1 = new MetadataPropertyDisabledTestClass { Id = "Id!", Ref = "Ref!", Type = "Type!", Value = "Value!", Values = "Values!" }; string json = JsonConvert.SerializeObject(c1, Formatting.Indented); StringAssert.AreEqual(@"{ ""$id"": ""Id!"", ""$ref"": ""Ref!"", ""$value"": ""Value!"", ""$values"": ""Values!"", ""$type"": ""Type!"" }", json); MetadataPropertyDisabledTestClass c2 = JsonConvert.DeserializeObject<MetadataPropertyDisabledTestClass>(json, new JsonSerializerSettings { MetadataPropertyHandling = MetadataPropertyHandling.Ignore }); Assert.AreEqual("Id!", c2.Id); Assert.AreEqual("Ref!", c2.Ref); Assert.AreEqual("Type!", c2.Type); Assert.AreEqual("Value!", c2.Value); Assert.AreEqual("Values!", c2.Values); }