public void DeserializesNoneFromNullWhenNested() { const string json = @"{""BloodType"":""B-"",""EmergencyContact"":null}"; var expectedObject = new MedicalId(bloodType: "B-", emergencyContact: Option <Person> .None()); Assert.Equal(expectedObject, JsonConvert.DeserializeObject <MedicalId>(json, Settings)); }
public void DeserializesInnerObjectWhenNested() { const string json = @"{""BloodType"":""B-"",""EmergencyContact"":{""FirstName"":""Peter"",""LastName"":""Pan""}}"; var expectedObject = new MedicalId(bloodType: "B-", emergencyContact: Option.Some(new Person("Peter", "Pan"))); Assert.Equal(expectedObject, JsonConvert.DeserializeObject <MedicalId>(json, Settings)); }
public void SerializesNoneAsNullWhenNested() { const string expectedJson = @"{""BloodType"":""B-"",""EmergencyContact"":null}"; var @object = new MedicalId(bloodType: "B-", emergencyContact: Option <Person> .None()); var json = JsonConvert.SerializeObject(@object, Settings); Assert.Equal(expectedJson, json); }