public void TestGetMediaServiceAccountsAsync() { FakeHttpMessageHandler fakeHttpHandler; MediaServicesManagementClient clientWithHandler = CreateMediaManagementClientWithFakeHttpMessageHandler(out fakeHttpHandler); const string responseText = @"<ServiceResources xmlns='http://schemas.microsoft.com/windowsazure' xmlns:i='http://www.w3.org/2001/XMLSchema-instance'> <ServiceResource> <Name>mymediademo</Name> <Type>MediaService</Type> <State>Active</State> <AccountId>E0658294-5C96-4B0F-AD55-F7446CE4F788</AccountId> </ServiceResource> <ServiceResource> <Name>nimbusorigintrial</Name> <Type>MediaService</Type> <State>Active</State> <AccountId>C92B17C8-5422-4CD1-8D3C-61E576E861DD</AccountId> </ServiceResource> </ServiceResources>"; HttpResponseMessage response = new HttpResponseMessage(HttpStatusCode.OK) { Content = new FakeHttpContent(responseText) }; fakeHttpHandler.Send = request => response; MediaServicesClient target = new MediaServicesClient(null, clientWithHandler, StorageClient.WithHandler(new FakeHttpMessageHandler())); MediaServicesAccountListResponse.MediaServiceAccount[] result = target.GetMediaServiceAccountsAsync().Result.Accounts.ToArray(); Assert.Equal("E0658294-5C96-4B0F-AD55-F7446CE4F788", result[0].AccountId); Assert.Equal("C92B17C8-5422-4CD1-8D3C-61E576E861DD", result[1].AccountId); }
public void TestGetMediaServiceAccountsAsync() { var fakeHttpHandler = new FakeHttpMessageHandler(); string responseText = "[{\"Name\":\"testps\",\"Type\":\"MediaService\",\"State\":\"Active\",\"AccountId\":\"E0658294-5C96-4B0F-AD55-F7446CE4F788\"},{\"Name\":\"test2\",\"Type\":\"MediaService\",\"State\":\"Active\",\"AccountId\":\"C92B17C8-5422-4CD1-8D3C-61E576E861DD\"}]"; var response = new HttpResponseMessage(HttpStatusCode.OK) { Content = new FakeHttpContent(responseText) }; fakeHttpHandler.Send = request => response; HttpClient fakeHttpClient = fakeHttpHandler.CreateIMediaServicesHttpClient(); var target = new MediaServicesClient(new SubscriptionData { SubscriptionId = _subscriptionId }, null, fakeHttpClient, fakeHttpClient); MediaServiceAccount[] result = target.GetMediaServiceAccountsAsync().Result.ToArray(); Assert.AreEqual(Guid.Parse("E0658294-5C96-4B0F-AD55-F7446CE4F788"), result[0].AccountId); Assert.AreEqual(Guid.Parse("C92B17C8-5422-4CD1-8D3C-61E576E861DD"), result[1].AccountId); }
public void TestGetMediaServiceAccountsAsync() { FakeHttpMessageHandler fakeHttpHandler; MediaServicesManagementClient clientWithHandler = CreateMediaManagementClientWithFakeHttpMessageHandler(out fakeHttpHandler); const string responseText = @"<ServiceResources xmlns='http://schemas.microsoft.com/windowsazure' xmlns:i='http://www.w3.org/2001/XMLSchema-instance'> <ServiceResource> <Name>mymediademo</Name> <Type>MediaService</Type> <State>Active</State> <AccountId>E0658294-5C96-4B0F-AD55-F7446CE4F788</AccountId> </ServiceResource> <ServiceResource> <Name>nimbusorigintrial</Name> <Type>MediaService</Type> <State>Active</State> <AccountId>C92B17C8-5422-4CD1-8D3C-61E576E861DD</AccountId> </ServiceResource> </ServiceResources>"; HttpResponseMessage response = new HttpResponseMessage(HttpStatusCode.OK) { Content = new FakeHttpContent(responseText) }; fakeHttpHandler.Send = request => response; MediaServicesClient target = new MediaServicesClient(null, clientWithHandler, StorageClient.WithHandler(new FakeHttpMessageHandler())); MediaServicesAccountListResponse.MediaServiceAccount[] result = target.GetMediaServiceAccountsAsync().Result.Accounts.ToArray(); Assert.AreEqual("E0658294-5C96-4B0F-AD55-F7446CE4F788", result[0].AccountId); Assert.AreEqual("C92B17C8-5422-4CD1-8D3C-61E576E861DD", result[1].AccountId); }