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