public async Task DeleteAsyncWithIntIdTypeAndInvalidIntIdParameter()
        {
            long[] testIdData = IdTestData.InvalidIntIds;

            foreach (long testId in testIdData)
            {
                TestHttpHandler hijack = new TestHttpHandler();
                hijack.SetResponseContent("{\"id\":\"" + testId + "\",\"String\":\"Hey\"}");
                IMobileServiceClient service = new MobileServiceClient("http://www.test.com", "secret...", hijack);

                IMobileServiceTable<LongIdType> table = service.GetTable<LongIdType>();
                Exception exception = null;
                try
                {
                    LongIdType item = new LongIdType() { Id = testId, String = "what?" };
                    await table.DeleteAsync(item);
                }
                catch (Exception e)
                {
                    exception = e;
                }

                Assert.IsNotNull(exception);
                Assert.IsTrue(exception.Message.Contains(" is not a positive integer value") ||
                              exception.Message.Contains("for member id is outside the valid range for numeric columns"));
            }
        }
        public async Task DeleteAsyncWithIntIdTypeAndIntIdItem()
        {
            long[] testIdData = IdTestData.ValidIntIds
                                          .Where(id => id != long.MaxValue) // Max value fails for serialization reasons; not because of id constraints
                                          .ToArray();

            foreach (long testId in testIdData)
            {
                TestHttpHandler hijack = new TestHttpHandler();
                hijack.SetResponseContent("{\"id\":" + testId + ",\"String\":\"Hey\"}");
                IMobileServiceClient service = new MobileServiceClient("http://www.test.com", "secret...", hijack);

                IMobileServiceTable<LongIdType> table = service.GetTable<LongIdType>();
                LongIdType item = new LongIdType() { Id = testId, String = "what?" };
                await table.DeleteAsync(item);

                Assert.AreEqual(0L, item.Id);
                Assert.AreEqual("what?", item.String);
            }
        }
        public async Task DeleteAsyncWithIntIdTypeAndZeroIdItem()
        {
            TestHttpHandler hijack = new TestHttpHandler();
            hijack.SetResponseContent("{\"id\":10,\"String\":\"Hey\"}");
            IMobileServiceClient service = new MobileServiceClient("http://www.test.com", "secret...", hijack);

            IMobileServiceTable<LongIdType> table = service.GetTable<LongIdType>();
            Exception exception = null;
            try
            {
                LongIdType item = new LongIdType() { Id = 0, String = "what?" };
                await table.DeleteAsync(item);
            }
            catch (Exception e)
            {
                exception = e;
            }

            Assert.IsNotNull(exception);
            Assert.IsTrue(exception.Message.Contains("Expected id member not found."));
        }
        public async Task UpdateAsyncWithIntIdTypeAndNoIdResponseContent()
        {
            TestHttpHandler hijack = new TestHttpHandler();
            hijack.SetResponseContent("{\"String\":\"Hey\"}");
            IMobileServiceClient service = new MobileServiceClient("http://www.test.com", "secret...", hijack);

            IMobileServiceTable<LongIdType> table = service.GetTable<LongIdType>();

            LongIdType item = new LongIdType() { Id = 12, String = "what?" };
            await table.UpdateAsync(item);

            Assert.AreEqual(12L, item.Id);
            Assert.AreEqual("Hey", item.String);
        }
        public async Task UpdateAsyncWithIntIdTypeAndStringIdResponseContent()
        {
            TestHttpHandler hijack = new TestHttpHandler();
            hijack.SetResponseContent("{\"id\":\"an id\",\"String\":\"Hey\"}");
            IMobileServiceClient service = new MobileServiceClient("http://www.test.com", "secret...", hijack);

            IMobileServiceTable<LongIdType> table = service.GetTable<LongIdType>();

            Exception exception = null;
            try
            {
                LongIdType item = new LongIdType() { Id = 12, String = "what?" };
                await table.UpdateAsync(item);
            }
            catch (Exception e)
            {
                exception = e;
            }

            Assert.IsNotNull(exception);
            Assert.IsTrue(exception.Message.Contains("Error converting value"));
        }
        public async Task UpdateAsyncWithIntIdTypeAndIntIdResponseContent()
        {
            long[] testIdData = IdTestData.ValidIntIds.Concat(
                                IdTestData.InvalidIntIds).ToArray();

            foreach (long testId in testIdData)
            {
                TestHttpHandler hijack = new TestHttpHandler();
                hijack.SetResponseContent("{\"id\":" + testId + ",\"String\":\"Hey\"}");
                IMobileServiceClient service = new MobileServiceClient("http://www.test.com", "secret...", hijack);

                IMobileServiceTable<LongIdType> table = service.GetTable<LongIdType>();

                LongIdType item = new LongIdType() { Id = 12, String = "what?" };
                await table.UpdateAsync(item);

                Assert.AreEqual(testId, item.Id);
                Assert.AreEqual("Hey", item.String);
            }
        }
        public async Task UpdateAsyncWithIntIdTypeParseableIdResponseContent()
        {
            object[] testIdData = IdTestData.NonStringNonIntValidJsonIds;

            foreach (object testId in testIdData)
            {
                TestHttpHandler hijack = new TestHttpHandler();
                hijack.SetResponseContent("{\"id\":" + testId.ToString().ToLower() + ",\"String\":\"Hey\"}");
                IMobileServiceClient service = new MobileServiceClient("http://www.test.com", "secret...", hijack);

                IMobileServiceTable<LongIdType> table = service.GetTable<LongIdType>();

                LongIdType item = new LongIdType() { Id = 12, String = "what?" };
                await table.UpdateAsync(item);

                long expectedId = Convert.ToInt64(testId);
                if (expectedId == 0L)
                {
                    expectedId = 12;
                }

                Assert.AreEqual(expectedId, item.Id);
                Assert.AreEqual("Hey", item.String);
            }
        }
        public async Task RefreshAsyncWithIntIdTypeAndIntIdItem()
        {
            long[] testIdData = IdTestData.ValidIntIds;

            foreach (long testId in testIdData)
            {
                TestHttpHandler hijack = new TestHttpHandler();
                hijack.SetResponseContent("[{\"id\":" + testId + ",\"String\":\"Hey\"}]");
                IMobileServiceClient service = new MobileServiceClient("http://www.test.com", "secret...", hijack);

                IMobileServiceTable<LongIdType> table = service.GetTable<LongIdType>();

                LongIdType item = new LongIdType() { Id = testId, String = "what?" };
                await table.RefreshAsync(item);

                Uri expectedUri = new Uri(string.Format("http://www.test.com/tables/LongIdType?$filter=(id eq {0}L)", testId));

                Assert.AreEqual(testId, item.Id);
                Assert.AreEqual("Hey", item.String);
                Assert.AreEqual(hijack.Request.RequestUri.AbsoluteUri, expectedUri.AbsoluteUri);
            }
        }
        public async Task RefreshAsyncWithIntIdTypeAndZeroIdItem()
        {
            TestHttpHandler hijack = new TestHttpHandler();
            IMobileServiceClient service = new MobileServiceClient("http://www.test.com", "secret...", hijack);

            IMobileServiceTable<LongIdType> table = service.GetTable<LongIdType>();
            LongIdType item = new LongIdType() { Id = 0, String = "what?" };
            await table.RefreshAsync(item);

            Assert.AreEqual(0L, item.Id);
            Assert.AreEqual("what?", item.String);
        }
        public async Task UpdateAsyncWithIntIdTypeAndNullIdResponseContent()
        {
            TestHttpHandler hijack = new TestHttpHandler();
            hijack.SetResponseContent("{\"id\":null,\"String\":\"Hey\"}");
            IMobileServiceClient service = new MobileServiceClient(MobileAppUriValidator.DummyMobileApp, hijack);

            IMobileServiceTable<LongIdType> table = service.GetTable<LongIdType>();

            LongIdType item = new LongIdType() { Id = 12, String = "what?" };
            await table.UpdateAsync(item);

            Assert.AreEqual(12L, item.Id);
            Assert.AreEqual("Hey", item.String);
        }
        public async Task RefreshAsyncWithIntIdTypeAndStringIdResponseContent()
        {
            string[] testIdData = IdTestData.ValidStringIds.Concat(
                                  IdTestData.EmptyStringIds).ToArray();

            foreach (string testId in testIdData)
            {
                TestHttpHandler hijack = new TestHttpHandler();
                hijack.SetResponseContent("{\"id\":\"" + testId + "\",\"String\":\"Hey\"}");
                IMobileServiceClient service = new MobileServiceClient("http://www.test.com", "secret...", hijack);

                IMobileServiceTable<LongIdType> table = service.GetTable<LongIdType>();

                Exception exception = null;
                try
                {
                    LongIdType item = new LongIdType() { Id = 3, String = "what?" };
                    await table.RefreshAsync(item);
                }
                catch (Exception e)
                {
                    exception = e;
                }

                Assert.IsNotNull(exception);
                Assert.IsTrue(exception.Message.Contains("Error converting value"));
            }
        }
        public async Task InsertAsyncWithIntIdTypeAndIntIdItem()
        {
            long[] testIdData = IdTestData.ValidIntIds;

            foreach (long testId in testIdData)
            {
                TestHttpHandler hijack = new TestHttpHandler();
                hijack.SetResponseContent("{\"id\":" + testId + ",\"String\":\"Hey\"}");
                IMobileServiceClient service = new MobileServiceClient(MobileAppUriValidator.DummyMobileApp, hijack);

                IMobileServiceTable<LongIdType> table = service.GetTable<LongIdType>();

                Exception exception = null;
                try
                {
                    LongIdType item = new LongIdType() { Id = testId, String = "what?" };
                    await table.InsertAsync(item);
                }
                catch (Exception e)
                {
                    exception = e;
                }

                Assert.IsNotNull(exception);
                Assert.IsTrue(exception.Message.Contains("Cannot insert if the id member is already set.") ||
                              exception.Message.Contains("for member id is outside the valid range for numeric columns"));
            }
        }
        public async Task InsertAsyncWithIntIdTypeAndStringIdResponseContent()
        {
            TestHttpHandler hijack = new TestHttpHandler();
            hijack.SetResponseContent("{\"id\":\"an id\",\"String\":\"Hey\"}");
            IMobileServiceClient service = new MobileServiceClient(MobileAppUriValidator.DummyMobileApp, hijack);

            IMobileServiceTable<LongIdType> table = service.GetTable<LongIdType>();

            Exception exception = null;
            try
            {
                LongIdType item = new LongIdType() { String = "what?" };
                await table.InsertAsync(item);
            }
            catch (Exception e)
            {
                exception = e;
            }

            Assert.IsNotNull(exception);
            Assert.IsTrue(exception.Message.Contains("Error converting value"));
        }
        public async Task InsertAsyncWithIntIdTypeParseableIdResponseContent()
        {
            object[] testIdData = IdTestData.NonStringNonIntValidJsonIds;

            foreach (object testId in testIdData)
            {
                TestHttpHandler hijack = new TestHttpHandler();
                hijack.SetResponseContent("{\"id\":" + testId.ToString().ToLower() + ",\"String\":\"Hey\"}");
                IMobileServiceClient service = new MobileServiceClient(MobileAppUriValidator.DummyMobileApp, hijack);

                IMobileServiceTable<LongIdType> table = service.GetTable<LongIdType>();

                LongIdType item = new LongIdType() { String = "what?" };
                await table.InsertAsync(item);

                long expectedId = Convert.ToInt64(testId);
                Assert.AreEqual(expectedId, item.Id);
                Assert.AreEqual("Hey", item.String);
            }
        }
        public async Task RefreshAsyncWithIntIdTypeAndInvalidIntIdParameter()
        {
            long[] testIdData = IdTestData.InvalidIntIds;

            foreach (long testId in testIdData)
            {
                TestHttpHandler hijack = new TestHttpHandler();
                hijack.SetResponseContent("{\"id\":\"" + testId + "\",\"String\":\"Hey\"}");
                IMobileServiceClient service = new MobileServiceClient(MobileAppUriValidator.DummyMobileApp, hijack);

                IMobileServiceTable<LongIdType> table = service.GetTable<LongIdType>();
                Exception exception = null;
                try
                {
                    LongIdType item = new LongIdType() { Id = testId, String = "what?" };
                    await table.RefreshAsync(item);
                }
                catch (Exception e)
                {
                    exception = e;
                }

                Assert.IsNotNull(exception);
                Assert.IsTrue(exception.Message.Contains(" is not a positive integer value"));
            }
        }
        public async Task RefreshAsyncWithIntIdTypeAndZeroIdItem()
        {
            TestHttpHandler hijack = new TestHttpHandler();
            IMobileServiceClient service = new MobileServiceClient(MobileAppUriValidator.DummyMobileApp, hijack);

            IMobileServiceTable<LongIdType> table = service.GetTable<LongIdType>();
            LongIdType item = new LongIdType() { Id = 0, String = "what?" };
            await table.RefreshAsync(item);

            Assert.AreEqual(0L, item.Id);
            Assert.AreEqual("what?", item.String);
        }