public void CamelCaseCustomSerialization()
        {
            MobileServiceSerializer serializer = new MobileServiceSerializer();
            serializer.SerializerSettings.CamelCasePropertyNames = true;

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

            PocoType pocoType = new PocoType();

            string actual = serializer.Serialize(pocoType).ToString(Formatting.None);
            Assert.AreEqual(actual, "{\"publicField\":null,\"publicProperty\":null}");
        }
        public void PocoPopulation()
        {
            List<Tuple<PocoType, string>> testCases = new List<Tuple<PocoType, string>>() {
                new Tuple<PocoType, string>(new PocoType(), "{\"PublicProperty\":null,\"PublicField\":null}"),
                new Tuple<PocoType, string>(new PocoType("_XYZ", onlySetSerializableMembers: true), "{\"PublicProperty\":\"PublicProperty_XYZ\",\"PublicField\":\"PublicField_XYZ\"}" ),
            };

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

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

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

                Assert.AreEqual(actual, expected);
            }
        }
        public void IndentedFormattingCustomSerialization()
        {
            MobileServiceSerializer serializer = new MobileServiceSerializer();
            serializer.SerializerSettings.Formatting = Formatting.Indented;

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

            PocoType pocoType = new PocoType();

            string actual = serializer.Serialize(pocoType).ToString();
            Assert.AreEqual(actual, "{" + Environment.NewLine + "  \"PublicField\": null," + Environment.NewLine + "  \"PublicProperty\": null" + Environment.NewLine + "}");
        }
        public void IgnoreNullValuesCustomSerialization()
        {
            MobileServiceSerializer serializer = new MobileServiceSerializer();
            serializer.SerializerSettings.NullValueHandling = NullValueHandling.Ignore;

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

            PocoType pocoType = new PocoType();

            string actual = serializer.Serialize(pocoType).ToString();
            Assert.AreEqual(actual, "{}");
        }
        public void CamelCaseCustomSerialization()
        {
            MobileServiceSerializer serializer = new MobileServiceSerializer();
            serializer.SerializerSettings.CamelCasePropertyNames = true;

            PocoType pocoType = new PocoType();

            string actual = serializer.Serialize(pocoType);
            Assert.AreEqual(actual, "{\"publicField\":null,\"publicProperty\":null}");
        }
        public void IndentedFormattingCustomSerialization()
        {
            MobileServiceSerializer serializer = new MobileServiceSerializer();
            serializer.SerializerSettings.Formatting = Formatting.Indented;

            PocoType pocoType = new PocoType();

            string actual = serializer.Serialize(pocoType);
            Assert.AreEqual(actual, "{\r\n  \"PublicField\": null,\r\n  \"PublicProperty\": null\r\n}");
        }
        public void IgnoreNullValuesCustomSerialization()
        {
            MobileServiceSerializer serializer = new MobileServiceSerializer();
            serializer.SerializerSettings.NullValueHandling = NullValueHandling.Ignore;

            PocoType pocoType = new PocoType();

            string actual = serializer.Serialize(pocoType);
            Assert.AreEqual(actual, "{}");
        }