public void JsonPropertyDerivedDataContractDeserialization()
        {
            // Verifies that given a serialized json object, it can be deserialized into the expected object
            // It also checks that deserializing an object into a different one will correctly override the
            // properties of the original
            List<Tuple<JsonPropertyDerivedDataContractType, string>> testCases = new List<Tuple<JsonPropertyDerivedDataContractType, string>>() {
                new Tuple<JsonPropertyDerivedDataContractType, string>(new JsonPropertyDerivedDataContractType(), "{\"DerivedPublicFieldDataMember\":null,\"DerivedInternalFieldDataMember\":null,\"DerivedPrivateFieldDataMember\":null,\"DerivedPublicField\":null,\"DerivedInternalField\":null,\"DerivedPrivateField\":null,\"PublicFieldJsonProperty\":null,\"InternalFieldJsonProperty\":null,\"PublicField\":null,\"InternalField\":null,\"PrivateFieldJsonProperty\":null,\"PrivateField\":null,\"DerivedPublicPropertyDataMember\":null,\"DerivedInternalPropertyDataMember\":null,\"DerivedPrivatePropertyDataMember\":null,\"DerivedPublicProperty\":null,\"DerivedInternalProperty\":null,\"DerivedPrivateProperty\":null,\"PublicPropertyJsonProperty\":null,\"InternalPropertyJsonProperty\":null,\"PublicProperty\":null,\"InternalProperty\":null,\"PrivatePropertyJsonProperty\":null,\"PrivateProperty\":null}"),
                new Tuple<JsonPropertyDerivedDataContractType, string>(new JsonPropertyDerivedDataContractType("_XYZ", onlySetSerializableMembers: true), "{\"DerivedPublicFieldDataMember\":\"DerivedPublicFieldNamedDataMember_XYZ\",\"DerivedInternalFieldDataMember\":\"DerivedInternalFieldNamedDataMember_XYZ\",\"DerivedPrivateFieldDataMember\":\"DerivedPrivateFieldNamedDataMember_XYZ\",\"DerivedPublicField\":\"DerivedPublicField_XYZ\",\"DerivedInternalField\":\"DerivedInternalField_XYZ\",\"DerivedPrivateField\":\"DerivedPrivateField_XYZ\",\"PublicFieldJsonProperty\":null,\"InternalFieldJsonProperty\":null,\"PublicField\":null,\"InternalField\":null,\"PrivateFieldJsonProperty\":null,\"PrivateField\":null,\"DerivedPublicPropertyDataMember\":\"DerivedPublicPropertyNamedDataMember_XYZ\",\"DerivedInternalPropertyDataMember\":\"DerivedInternalPropertyNamedDataMember_XYZ\",\"DerivedPrivatePropertyDataMember\":\"DerivedPrivatePropertyNamedDataMember_XYZ\",\"DerivedPublicProperty\":\"DerivedPublicProperty_XYZ\",\"DerivedInternalProperty\":\"DerivedInternalProperty_XYZ\",\"DerivedPrivateProperty\":\"DerivedPrivateProperty_XYZ\",\"PublicPropertyJsonProperty\":null,\"InternalPropertyJsonProperty\":null,\"PublicProperty\":null,\"InternalProperty\":null,\"PrivatePropertyJsonProperty\":null,\"PrivateProperty\":null}"),
            };

            // Need to ensure that the type is registered as a table to force the id property check
            DefaultSerializer.SerializerSettings.ContractResolver.ResolveTableName(typeof(JsonPropertyDerivedDataContractType));

            foreach (var testCase in testCases)
            {
                var input = JToken.Parse(testCase.Item2);
                var expected = testCase.Item1;

                JsonPropertyDerivedDataContractType actual = new JsonPropertyDerivedDataContractType();
                DefaultSerializer.Deserialize(input, actual);

                Assert.AreEqual(actual, expected);

                actual = new JsonPropertyDerivedDataContractType("_ABC", onlySetSerializableMembers: true);
                DefaultSerializer.Deserialize(input, actual);

                Assert.AreEqual(actual, expected);

                JArray json = JToken.Parse("[" + testCase.Item2 + "]") as JArray;
                actual = DefaultSerializer.Deserialize<JsonPropertyDerivedDataContractType>(json).FirstOrDefault();

                Assert.AreEqual(actual, expected);

                actual = DefaultSerializer.Deserialize<JsonPropertyDerivedDataContractType>(input);

                Assert.AreEqual(actual, expected);
            }
        }
        public void JsonPropertyDerivedDataContractPopulation()
        {
            // Verifies that given a serialized json object, it can be deserialized into the expected object
            List<Tuple<JsonPropertyDerivedDataContractType, string>> testCases = new List<Tuple<JsonPropertyDerivedDataContractType, string>>() {
                new Tuple<JsonPropertyDerivedDataContractType, string>(new JsonPropertyDerivedDataContractType(), "{\"DerivedPublicFieldDataMember\":null,\"DerivedInternalFieldDataMember\":null,\"DerivedPrivateFieldDataMember\":null,\"DerivedPublicField\":null,\"DerivedInternalField\":null,\"DerivedPrivateField\":null,\"PublicFieldJsonProperty\":null,\"InternalFieldJsonProperty\":null,\"PublicField\":null,\"InternalField\":null,\"PrivateFieldJsonProperty\":null,\"PrivateField\":null,\"DerivedPublicPropertyDataMember\":null,\"DerivedInternalPropertyDataMember\":null,\"DerivedPrivatePropertyDataMember\":null,\"DerivedPublicProperty\":null,\"DerivedInternalProperty\":null,\"DerivedPrivateProperty\":null,\"PublicPropertyJsonProperty\":null,\"InternalPropertyJsonProperty\":null,\"PublicProperty\":null,\"InternalProperty\":null,\"PrivatePropertyJsonProperty\":null,\"PrivateProperty\":null}"),
                new Tuple<JsonPropertyDerivedDataContractType, string>(new JsonPropertyDerivedDataContractType("_XYZ", onlySetSerializableMembers: true), "{\"DerivedPublicFieldDataMember\":\"DerivedPublicFieldNamedDataMember_XYZ\",\"DerivedInternalFieldDataMember\":\"DerivedInternalFieldNamedDataMember_XYZ\",\"DerivedPrivateFieldDataMember\":\"DerivedPrivateFieldNamedDataMember_XYZ\",\"DerivedPublicField\":\"DerivedPublicField_XYZ\",\"DerivedInternalField\":\"DerivedInternalField_XYZ\",\"DerivedPrivateField\":\"DerivedPrivateField_XYZ\",\"PublicFieldJsonProperty\":null,\"InternalFieldJsonProperty\":null,\"PublicField\":null,\"InternalField\":null,\"DerivedPublicPropertyDataMember\":\"DerivedPublicPropertyNamedDataMember_XYZ\",\"DerivedInternalPropertyDataMember\":\"DerivedInternalPropertyNamedDataMember_XYZ\",\"DerivedPrivatePropertyDataMember\":\"DerivedPrivatePropertyNamedDataMember_XYZ\",\"DerivedPublicProperty\":\"DerivedPublicProperty_XYZ\",\"DerivedInternalProperty\":\"DerivedInternalProperty_XYZ\",\"DerivedPrivateProperty\":\"DerivedPrivateProperty_XYZ\",\"PublicPropertyJsonProperty\":null,\"InternalPropertyJsonProperty\":null,\"PublicProperty\":null,\"InternalProperty\":null,\"PrivateFieldJsonProperty\":null,\"PrivateField\":null,\"PrivatePropertyJsonProperty\":null,\"PrivateProperty\":null}")
            };

            // Need to ensure that the type is registered as a table to force the id property check
            DefaultSerializer.SerializerSettings.ContractResolver.ResolveTableName(typeof(JsonPropertyDerivedDataContractType));

            foreach (var testCase in testCases)
            {
                var input = testCase.Item2;
                var expected = testCase.Item1;

                JsonPropertyDerivedDataContractType actual = new JsonPropertyDerivedDataContractType("_ABC", onlySetSerializableMembers: true);
                DefaultSerializer.Deserialize(input, actual);

                string test = DefaultSerializer.Serialize(expected).ToString(Formatting.None);
                Assert.AreEqual(actual, expected);
            }
        }
        public void JsonPropertyDerivedDataContractDeserialization()
        {
            List<Tuple<JsonPropertyDerivedDataContractType, string>> testCases = new List<Tuple<JsonPropertyDerivedDataContractType, string>>() {
                new Tuple<JsonPropertyDerivedDataContractType, string>(new JsonPropertyDerivedDataContractType(), "{\"DerivedPublicFieldDataMember\":null,\"DerivedInternalFieldDataMember\":null,\"DerivedPrivateFieldDataMember\":null,\"DerivedPublicField\":null,\"DerivedInternalField\":null,\"DerivedPrivateField\":null,\"PublicFieldJsonProperty\":null,\"InternalFieldJsonProperty\":null,\"PublicField\":null,\"InternalField\":null,\"PrivateFieldJsonProperty\":null,\"PrivateField\":null,\"DerivedPublicPropertyDataMember\":null,\"DerivedInternalPropertyDataMember\":null,\"DerivedPrivatePropertyDataMember\":null,\"DerivedPublicProperty\":null,\"DerivedInternalProperty\":null,\"DerivedPrivateProperty\":null,\"PublicPropertyJsonProperty\":null,\"InternalPropertyJsonProperty\":null,\"PublicProperty\":null,\"InternalProperty\":null,\"PrivatePropertyJsonProperty\":null,\"PrivateProperty\":null}"),
                new Tuple<JsonPropertyDerivedDataContractType, string>(new JsonPropertyDerivedDataContractType("_XYZ", onlySetSerializableMembers: true), "{\"DerivedPublicFieldDataMember\":\"DerivedPublicFieldNamedDataMember_XYZ\",\"DerivedInternalFieldDataMember\":\"DerivedInternalFieldNamedDataMember_XYZ\",\"DerivedPrivateFieldDataMember\":\"DerivedPrivateFieldNamedDataMember_XYZ\",\"DerivedPublicField\":\"DerivedPublicField_XYZ\",\"DerivedInternalField\":\"DerivedInternalField_XYZ\",\"DerivedPrivateField\":\"DerivedPrivateField_XYZ\",\"PublicFieldJsonProperty\":\"PublicFieldNamedJsonProperty_XYZ\",\"InternalFieldJsonProperty\":\"InternalFieldNamedJsonProperty_XYZ\",\"PublicField\":\"PublicField_XYZ\",\"InternalField\":\"InternalField_XYZ\",\"PrivateFieldJsonProperty\":\"PrivateFieldNamedJsonProperty_XYZ\",\"PrivateField\":\"PrivateField_XYZ\",\"DerivedPublicPropertyDataMember\":\"DerivedPublicPropertyNamedDataMember_XYZ\",\"DerivedInternalPropertyDataMember\":\"DerivedInternalPropertyNamedDataMember_XYZ\",\"DerivedPrivatePropertyDataMember\":\"DerivedPrivatePropertyNamedDataMember_XYZ\",\"DerivedPublicProperty\":\"DerivedPublicProperty_XYZ\",\"DerivedInternalProperty\":\"DerivedInternalProperty_XYZ\",\"DerivedPrivateProperty\":\"DerivedPrivateProperty_XYZ\",\"PublicPropertyJsonProperty\":\"PublicPropertyNamedJsonProperty_XYZ\",\"InternalPropertyJsonProperty\":\"InternalPropertyNamedJsonProperty_XYZ\",\"PublicProperty\":\"PublicProperty_XYZ\",\"InternalProperty\":\"InternalProperty_XYZ\",\"PrivatePropertyJsonProperty\":\"PrivatePropertyNamedJsonProperty_XYZ\",\"PrivateProperty\":\"PrivateProperty_XYZ\"}"),
            };

            // Need to ensure that the type is registered as a table to force the id property check
            DefaultSerializer.SerializerSettings.ContractResolver.ResolveTableName(typeof(JsonPropertyDerivedDataContractType));

            foreach (var testCase in testCases)
            {
                var input = testCase.Item2;
                var expected = testCase.Item1;

                JsonPropertyDerivedDataContractType actual = new JsonPropertyDerivedDataContractType();
                DefaultSerializer.Deserialize(input, actual);

                Assert.AreEqual(actual, expected);

                actual = new JsonPropertyDerivedDataContractType("_ABC", onlySetSerializableMembers: true);
                DefaultSerializer.Deserialize(input, actual);

                Assert.AreEqual(actual, expected);

                JArray json = JToken.Parse("[" + input + "]") as JArray;
                actual = DefaultSerializer.Deserialize<JsonPropertyDerivedDataContractType>(json).FirstOrDefault();

                Assert.AreEqual(actual, expected);

                actual = DefaultSerializer.Deserialize<JsonPropertyDerivedDataContractType>(input);

                Assert.AreEqual(actual, expected);
            }
        }