コード例 #1
0
        public async Task RefreshUserAsync_Throws_On_Forbidden()
        {
            string appUrl     = MobileAppUriValidator.DummyMobileApp;
            string refreshUrl = appUrl + ".auth/refresh";
            string userId     = "sid:xxxxxxxxxxxxxxxxx";

            TestHttpHandler hijack = new TestHttpHandler();

            hijack.Response = TestHttpHandler.CreateResponse("error message from Mobile Apps refresh endpoint", HttpStatusCode.Forbidden);

            MobileServiceHttpClient.DefaultHandlerFactory = () => hijack;
            MobileServiceClient client = new MobileServiceClient(appUrl, hijack);

            client.CurrentUser = new MobileServiceUser(userId)
            {
                MobileServiceAuthenticationToken = "auth-token"
            };

            await Assert.ThrowsAsync <MobileServiceInvalidOperationException>(() => client.RefreshUserAsync());
        }