public async Task RegisterAsync_ChannelUri() { MobileServiceClient mobileClient = new MobileServiceClient(DefaultServiceUri); var expectedUri = string.Format("{0}{1}/{2}", DefaultServiceUri, InstallationsPath, mobileClient.GetPush().InstallationId); string installationRegistration = JsonConvert.SerializeObject(this.pushTestUtility.GetInstallation(mobileClient.GetPush().InstallationId, false)); var hijack = TestHttpDelegatingHandler.CreateTestHttpHandler(expectedUri, HttpMethod.Put, null, HttpStatusCode.OK, expectedRequestContent: installationRegistration); mobileClient = new MobileServiceClient(DefaultServiceUri, hijack); await mobileClient.GetPush().RegisterAsync(this.originalNSData); }
public async Task DeleteInstallationAsync() { MobileServiceClient mobileClient = new MobileServiceClient(DefaultServiceUri); var expectedUri = string.Format("{0}{1}/{2}", DefaultServiceUri, InstallationsPath, mobileClient.InstallationId); var hijack = TestHttpDelegatingHandler.CreateTestHttpHandler(expectedUri, HttpMethod.Delete, null, HttpStatusCode.NoContent); mobileClient = new MobileServiceClient(DefaultServiceUri, hijack); var pushHttpClient = new PushHttpClient(mobileClient); await pushHttpClient.DeleteInstallationAsync(); }
public async Task RegisterAsync_ErrorHttp() { MobileServiceClient mobileClient = new MobileServiceClient(DefaultServiceUri); var expectedUri = string.Format("{0}{1}/{2}", DefaultServiceUri, InstallationsPath, mobileClient.GetPush().InstallationId); var hijack = TestHttpDelegatingHandler.CreateTestHttpHandler(expectedUri, HttpMethod.Put, null, HttpStatusCode.BadRequest); mobileClient = new MobileServiceClient(DefaultServiceUri, hijack); var exception = await AssertEx.Throws <MobileServiceInvalidOperationException>(() => mobileClient.GetPush().RegisterAsync(this.registrationId)); Assert.AreEqual(exception.Response.StatusCode, HttpStatusCode.BadRequest); }