/// <summary>
 /// Updates the specified Active directory's configuration.
 /// </summary>
 /// <param name='operations'>
 /// Reference to the
 /// Microsoft.Azure.Management.RemoteApp.ICollectionOperations.
 /// </param>
 /// <param name='collectionName'>
 /// Required. Name of the collection
 /// </param>
 /// <param name='activeDirectoryConfigDetails'>
 /// Required. AD config
 /// </param>
 /// <returns>
 /// The response containing the operation tracking id.
 /// </returns>
 public static Task<OperationResultWithTrackingId> SetAdAsync(this ICollectionOperations operations, string collectionName, ActiveDirectoryConfigParameter activeDirectoryConfigDetails)
 {
     return operations.SetAdAsync(collectionName, activeDirectoryConfigDetails, CancellationToken.None);
 }
        public void CanCreateAD()
        {
            using (UndoContext context = UndoContext.Current)
            {
                context.Start();
                HttpRecorderMode mode = HttpMockServer.GetCurrentMode();
                RemoteAppManagementClient remoteAppManagementClient = GetRemoteAppManagementClient();
                HttpStatusCode[] statusSuccess = { HttpStatusCode.OK, HttpStatusCode.Accepted };

                    ActiveDirectoryConfigParameter payload = new ActiveDirectoryConfigParameter()
                    {
                        DomainName = "MyDomain",
                        UserName = "******",
                        Password = "******"
                    };

                    OperationResultWithTrackingId result = null;

                    Assert.DoesNotThrow(() =>
                    {
                        result = remoteAppManagementClient.Collections.SetAd("testd112", payload);
                    });

                    Assert.NotNull(result);
                    Assert.True(result.StatusCode == HttpStatusCode.OK || result.StatusCode == HttpStatusCode.Accepted);

                    if (result.StatusCode == HttpStatusCode.Accepted)
                    {
                        Assert.NotNull(result.TrackingId);
                    }
            }
        }
 /// <summary>
 /// Updates the specified Active directory's configuration.
 /// </summary>
 /// <param name='operations'>
 /// Reference to the
 /// Microsoft.Azure.Management.RemoteApp.ICollectionOperations.
 /// </param>
 /// <param name='collectionName'>
 /// Required. Name of the collection
 /// </param>
 /// <param name='activeDirectoryConfigDetails'>
 /// Required. AD config
 /// </param>
 /// <returns>
 /// The response containing the operation tracking id.
 /// </returns>
 public static OperationResultWithTrackingId SetAd(this ICollectionOperations operations, string collectionName, ActiveDirectoryConfigParameter activeDirectoryConfigDetails)
 {
     return Task.Factory.StartNew((object s) => 
     {
         return ((ICollectionOperations)s).SetAdAsync(collectionName, activeDirectoryConfigDetails);
     }
     , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult();
 }