public async Task SelectAsyncGeneric()
        {
            TestHttpHandler hijack = new TestHttpHandler();
            hijack.SetResponseContent("[{\"id\":12,\"String\":\"Hey\"}]");
            IMobileServiceClient service = new MobileServiceClient("http://www.test.com", "secret...", hijack);

            IMobileServiceTable<StringType> table = service.GetTable<StringType>();
            StringType me = new StringType();
            me.Id = 10;
            me.String = "apple";

            List<string> people = await table.Select(p => p.String).ToListAsync();
            
            Assert.Contains(hijack.Request.RequestUri.ToString(), "StringType");

            Assert.AreEqual(1, people.Count);
            Assert.AreEqual("Hey", people[0]);
        }
        public void StringDeserialization()
        {
            List<Tuple<StringType, string>> testCases = new List<Tuple<StringType, string>>() {
                new Tuple<StringType, string>(new StringType() { String = null }, "{}"),
                new Tuple<StringType, string>(new StringType() { String = null }, "{\"String\":null}"),
                new Tuple<StringType, string>(new StringType() { String = "" }, "{\"String\":\"\"}"),
                new Tuple<StringType, string>(new StringType() { String = " " }, "{\"String\":\" \"}"),
                new Tuple<StringType, string>(new StringType() { String = "\n" }, "{\"String\":\"\\n\"}"),
                new Tuple<StringType, string>(new StringType() { String = "\t" }, "{\"String\":\"\\t\"}"), 
                new Tuple<StringType, string>(new StringType() { String = "\n" }, "{\"String\":\"\n\"}"),
                new Tuple<StringType, string>(new StringType() { String = "\t" }, "{\"String\":\"\t\"}"),
                new Tuple<StringType, string>(new StringType() { String = "hello" }, "{\"String\":\"hello\"}"), 
                new Tuple<StringType, string>(new StringType() { String = "\"hello\"" }, "{\"String\":\"\\\"hello\\\"\"}"), 
                new Tuple<StringType, string>(new StringType() { String = new string('*', 1025) }, "{\"String\":\"*****************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************\"}"), 
                new Tuple<StringType, string>(new StringType() { String = "ÃÇßÑᾆΏ" }, "{\"String\":\"ÃÇßÑᾆΏ\"}"), 
                new Tuple<StringType, string>(new StringType() { String = "'hello'" }, "{\"String\":\"'hello'\"}"), 
                new Tuple<StringType, string>(new StringType() { String = "True" }, "{\"String\":true}"),
                new Tuple<StringType, string>(new StringType() { String = "5" }, "{\"String\":5}"),
            };

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

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

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

                Assert.AreEqual(actual.String, expected.String);

                if (testCase.Item2 != "{}")
                {
                    actual = new StringType();
                    actual.String = "xyz";
                    DefaultSerializer.Deserialize(input, actual);
                }

                Assert.AreEqual(actual.String, expected.String);

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

                Assert.AreEqual(actual.String, expected.String);

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

                Assert.AreEqual(actual.String, expected.String);
            }
        }
        public async Task UpdateAsyncGenericWithUserParameters()
        {
            var userDefinedParameters = new Dictionary<string, string>() { { "state", "FL" } };

            TestHttpHandler hijack = new TestHttpHandler();
            IMobileServiceClient service = new MobileServiceClient("http://www.test.com", "secret...", hijack);
            IMobileServiceTable<StringType> table = service.GetTable<StringType>();

            StringType obj = new StringType();
            obj.Id = 12;
            obj.String = "new";

            hijack.SetResponseContent("{\"Id\":12,\"String\":\"new1\"}");

            await table.UpdateAsync(obj, userDefinedParameters);

            Assert.AreEqual("new1", obj.String);
            Assert.Contains(hijack.Request.RequestUri.ToString(), "StringType");
            Assert.Contains(hijack.Request.RequestUri.Query, "state=FL");
        }
        public async Task DeleteAsyncWithUserParameters()
        {
            var userDefinedParameters = new Dictionary<string, string>() { { "state", "WY" } };

            TestHttpHandler hijack = new TestHttpHandler();
            IMobileServiceClient service = new MobileServiceClient("http://www.test.com", "secret...", hijack);
            IMobileServiceTable<StringType> table = service.GetTable<StringType>();

            StringType obj = new StringType();
            obj.Id = 12;
            obj.String = "new";

            await table.DeleteAsync(obj, userDefinedParameters);

            Assert.AreEqual(0, obj.Id);
            Assert.Contains(hijack.Request.RequestUri.ToString(), "StringType");
            Assert.IsNull(hijack.Request.Content);
            Assert.Contains(hijack.Request.RequestUri.Query, "state=WY");
        }
        public async Task RefreshAsyncWithUserParameters()
        {
            var userDefinedParameters = new Dictionary<string, string>() { { "state", "CA" } };

            TestHttpHandler hijack = new TestHttpHandler();
            IMobileServiceClient service = new MobileServiceClient("http://www.test.com", "secret...", hijack);
            IMobileServiceTable<StringType> table = service.GetTable<StringType>();

            StringType expected = new StringType();
            expected.Id = 12;

            hijack.SetResponseContent("{\"id\":12,\"String\":\"Goodbye\"}");
            await table.RefreshAsync(expected, userDefinedParameters);

            Assert.Contains(hijack.Request.RequestUri.ToString(), "$filter=(id eq 12)");
            Assert.Contains(hijack.Request.RequestUri.Query, "state=CA");
            Assert.AreEqual(12, expected.Id);
            Assert.AreEqual("Goodbye", expected.String);
        }
        public async Task DeleteAsyncGeneric()
        {
            TestHttpHandler hijack = new TestHttpHandler();
            IMobileServiceClient service = new MobileServiceClient("http://www.test.com", "secret...", hijack);
            IMobileServiceTable<StringType> table = service.GetTable<StringType>();

            StringType obj = new StringType();
            obj.Id = 12;
            obj.String = "new";

            await table.DeleteAsync(obj);

            Assert.AreEqual(0, obj.Id);
            Assert.Contains(hijack.Request.RequestUri.ToString(), "StringType");
            Assert.IsNull(hijack.Request.Content);
        }
        public async Task UpdateAsyncGeneric()
        {
            TestHttpHandler hijack = new TestHttpHandler();
            IMobileServiceClient service = new MobileServiceClient("http://www.test.com", "secret...", hijack);
            IMobileServiceTable<StringType> table = service.GetTable<StringType>();

            StringType obj = new StringType();
            obj.Id = 12;
            obj.String = "new";

            hijack.SetResponseContent("{\"Id\":12,\"String\":\"new1\"}");

            await table.UpdateAsync(obj);

            Assert.AreEqual("new1", obj.String);
            Assert.Contains(hijack.Request.RequestUri.ToString(), "StringType");
        }
        public async Task RefreshAsyncGeneric()
        {
            TestHttpHandler hijack = new TestHttpHandler();
            IMobileServiceClient service = new MobileServiceClient("http://www.test.com", "secret...", hijack);
            IMobileServiceTable<StringType> table = service.GetTable<StringType>();

            StringType expected = new StringType();
            expected.Id = 12;

            hijack.SetResponseContent("{\"id\":12,\"String\":\"Goodbye\"}");
            await table.RefreshAsync(expected);

            Assert.Contains(hijack.Request.RequestUri.ToString(), "$filter=id eq 12");
            Assert.AreEqual(12, expected.Id);
            Assert.AreEqual("Goodbye", expected.String);
        }
        public async Task InsertAsyncGenericWithUserParameters()
        {
            var userDefinedParameters = new Dictionary<string, string>() { { "state", "CA" } };

            TestHttpHandler hijack = new TestHttpHandler();
            IMobileServiceClient service = new MobileServiceClient(MobileAppUriValidator.DummyMobileApp, hijack);
            IMobileServiceTable<StringType> table = service.GetTable<StringType>();

            StringType obj = new StringType();
            obj.String = "new";

            hijack.SetResponseContent("{\"id\":12,\"value\":\"new\"}");
            await table.InsertAsync(obj, userDefinedParameters);

            Assert.AreEqual(12, obj.Id);
            Assert.Contains(hijack.Request.RequestUri.ToString(), "StringType");
            Assert.Contains(hijack.Request.RequestUri.Query, "state=CA");
        }