public void TestDeleteAzureMediaServiceAccountAsync() { HttpClient fakeHttpClient = new FakeHttpMessageHandler().CreateIMediaServicesHttpClient(); var target = new MediaServicesClient(new SubscriptionData { SubscriptionId = _subscriptionId }, null, fakeHttpClient, fakeHttpClient); bool result = target.DeleteAzureMediaServiceAccountAsync(_accountName).Result; Assert.IsTrue(result); }
public void TestDeleteAzureMediaServiceAccountAsync404() { var fakeHttpHandler = new FakeHttpMessageHandler(); string responseText = "<string xmlns=\"http://schemas.microsoft.com/2003/10/Serialization/\">{\"Code\":\"NotFound\",\"Message\":\"The specified account was not found.\"}</string>"; var response = new HttpResponseMessage(HttpStatusCode.NotFound) { Content = new FakeHttpContent(responseText) }; fakeHttpHandler.Send = request => response; HttpClient fakeHttpClient = fakeHttpHandler.CreateIMediaServicesHttpClient(); var target = new MediaServicesClient(new SubscriptionData { SubscriptionId = _subscriptionId }, null, fakeHttpClient, fakeHttpClient); try { bool result = target.DeleteAzureMediaServiceAccountAsync(_accountName).Result; } catch (AggregateException ax) { var x = (ServiceManagementClientException) ax.InnerExceptions.Single(); Assert.AreEqual("NotFound", x.ErrorDetails.Code); return; } Assert.Fail("ServiceManagementClientException expected"); }