public async Task GalleryApplication_CRUD_Tests()
        {
            string location = DefaultLocation;

            EnsureClientsInitialized(location);
            string rgName = Recording.GenerateAssetName(ResourceGroupPrefix);

            await ResourceGroupsOperations.CreateOrUpdateAsync(rgName, new ResourceGroup(location));

            Trace.TraceInformation("Created the resource group: " + rgName);
            string  galleryName = Recording.GenerateAssetName(GalleryNamePrefix);
            Gallery gallery     = GetTestInputGallery();

            gallery.Location = location;
            await WaitForCompletionAsync(await GalleriesOperations.StartCreateOrUpdateAsync(rgName, galleryName, gallery));

            Trace.TraceInformation(string.Format("Created the gallery: {0} in resource group: {1}", galleryName, rgName));

            string             galleryApplicationName  = Recording.GenerateAssetName(GalleryApplicationNamePrefix);
            GalleryApplication inputGalleryApplication = GetTestInputGalleryApplication();

            await WaitForCompletionAsync(await GalleryApplicationsOperations.StartCreateOrUpdateAsync(rgName, galleryName, galleryApplicationName, inputGalleryApplication));

            Trace.TraceInformation(string.Format("Created the gallery application: {0} in gallery: {1}", galleryApplicationName,
                                                 galleryName));

            GalleryApplication galleryApplicationFromGet = await GalleryApplicationsOperations.GetAsync(rgName, galleryName, galleryApplicationName);

            Assert.NotNull(galleryApplicationFromGet);
            ValidateGalleryApplication(inputGalleryApplication, galleryApplicationFromGet);

            inputGalleryApplication.Description = "Updated description.";
            await WaitForCompletionAsync(await GalleryApplicationsOperations.StartCreateOrUpdateAsync(rgName, galleryName, galleryApplicationName, inputGalleryApplication));

            Trace.TraceInformation(string.Format("Updated the gallery application: {0} in gallery: {1}", galleryApplicationName,
                                                 galleryName));
            galleryApplicationFromGet = await GalleryApplicationsOperations.GetAsync(rgName, galleryName, galleryApplicationName);

            Assert.NotNull(galleryApplicationFromGet);
            ValidateGalleryApplication(inputGalleryApplication, galleryApplicationFromGet);

            await WaitForCompletionAsync(await GalleryApplicationsOperations.StartDeleteAsync(rgName, galleryName, galleryApplicationName));

            Trace.TraceInformation(string.Format("Deleted the gallery application: {0} in gallery: {1}", galleryApplicationName,
                                                 galleryName));

            await WaitForCompletionAsync(await GalleriesOperations.StartDeleteAsync(rgName, galleryName));
        }
        public async Task GalleryApplicationVersion_CRUD_Tests()
        {
            string location = DefaultLocation;

            EnsureClientsInitialized(DefaultLocation);
            string rgName                 = Recording.GenerateAssetName(ResourceGroupPrefix);
            string applicationName        = Recording.GenerateAssetName("psTestSourceApplication");
            string galleryName            = Recording.GenerateAssetName(GalleryNamePrefix);
            string galleryApplicationName = Recording.GenerateAssetName(GalleryApplicationNamePrefix);
            string applicationMediaLink   = await CreateApplicationMediaLink(rgName, "test.txt");

            Assert.False(string.IsNullOrEmpty(applicationMediaLink));
            Trace.TraceInformation(string.Format("Created the source application media link: {0}", applicationMediaLink));

            Gallery gallery = GetTestInputGallery();

            gallery.Location = location;
            await WaitForCompletionAsync(await GalleriesOperations.StartCreateOrUpdateAsync(rgName, galleryName, gallery));

            Trace.TraceInformation(string.Format("Created the gallery: {0} in resource group: {1}", galleryName,
                                                 rgName));
            GalleryApplication inputGalleryApplication = GetTestInputGalleryApplication();

            await WaitForCompletionAsync(await GalleryApplicationsOperations.StartCreateOrUpdateAsync(rgName, galleryName, galleryApplicationName, inputGalleryApplication));

            Trace.TraceInformation(string.Format("Created the gallery application: {0} in gallery: {1}", galleryApplicationName,
                                                 galleryName));

            string galleryApplicationVersionName = "1.0.0";
            GalleryApplicationVersion inputApplicationVersion = GetTestInputGalleryApplicationVersion(applicationMediaLink);

            await WaitForCompletionAsync(await GalleryApplicationVersionsOperations.StartCreateOrUpdateAsync(rgName, galleryName, galleryApplicationName,
                                                                                                             galleryApplicationVersionName, inputApplicationVersion));

            Trace.TraceInformation(string.Format("Created the gallery application version: {0} in gallery application: {1}",
                                                 galleryApplicationVersionName, galleryApplicationName));

            GalleryApplicationVersion applicationVersionFromGet = await GalleryApplicationVersionsOperations.GetAsync(rgName,
                                                                                                                      galleryName, galleryApplicationName, galleryApplicationVersionName);

            Assert.NotNull(applicationVersionFromGet);
            ValidateGalleryApplicationVersion(inputApplicationVersion, applicationVersionFromGet);
            //applicationVersionFromGet = await GalleryApplicationVersionsClient.Get(rgName, galleryName, galleryApplicationName,
            //    galleryApplicationVersionName, ReplicationStatusTypes.ReplicationStatus);
            applicationVersionFromGet = await GalleryApplicationVersionsOperations.GetAsync(rgName, galleryName, galleryApplicationName,
                                                                                            galleryApplicationVersionName);

            Assert.AreEqual(StorageAccountType.StandardLRS, applicationVersionFromGet.PublishingProfile.StorageAccountType);
            Assert.AreEqual(StorageAccountType.StandardLRS,
                            applicationVersionFromGet.PublishingProfile.TargetRegions.First().StorageAccountType);
            Assert.NotNull(applicationVersionFromGet.ReplicationStatus);
            Assert.NotNull(applicationVersionFromGet.ReplicationStatus.Summary);

            inputApplicationVersion.PublishingProfile.EndOfLifeDate = Recording.UtcNow.AddDays(100);
            await WaitForCompletionAsync(await GalleryApplicationVersionsOperations.StartCreateOrUpdateAsync(rgName, galleryName, galleryApplicationName,
                                                                                                             galleryApplicationVersionName, inputApplicationVersion));

            Trace.TraceInformation(string.Format("Updated the gallery application version: {0} in gallery application: {1}",
                                                 galleryApplicationVersionName, galleryApplicationName));
            applicationVersionFromGet = await GalleryApplicationVersionsOperations.GetAsync(rgName, galleryName,
                                                                                            galleryApplicationName, galleryApplicationVersionName);

            Assert.NotNull(applicationVersionFromGet);
            ValidateGalleryApplicationVersion(inputApplicationVersion, applicationVersionFromGet);

            await WaitForCompletionAsync(await GalleryApplicationVersionsOperations.StartDeleteAsync(rgName, galleryName, galleryApplicationName, galleryApplicationVersionName));

            Trace.TraceInformation(string.Format("Deleted the gallery application version: {0} in gallery application: {1}",
                                                 galleryApplicationVersionName, galleryApplicationName));

            await WaitForCompletionAsync(await GalleryApplicationsOperations.StartDeleteAsync(rgName, galleryName, galleryApplicationName));

            Trace.TraceInformation("Deleted the gallery application.");
            await WaitForCompletionAsync(await GalleriesOperations.StartDeleteAsync(rgName, galleryName));

            Trace.TraceInformation("Deleted the gallery.");
        }
 /// <summary>
 /// Initializes client properties.
 /// </summary>
 private void Initialize()
 {
     Operations                    = new Operations(this);
     AvailabilitySets              = new AvailabilitySetsOperations(this);
     ProximityPlacementGroups      = new ProximityPlacementGroupsOperations(this);
     DedicatedHostGroups           = new DedicatedHostGroupsOperations(this);
     DedicatedHosts                = new DedicatedHostsOperations(this);
     SshPublicKeys                 = new SshPublicKeysOperations(this);
     VirtualMachineExtensionImages = new VirtualMachineExtensionImagesOperations(this);
     VirtualMachineExtensions      = new VirtualMachineExtensionsOperations(this);
     VirtualMachineImages          = new VirtualMachineImagesOperations(this);
     VirtualMachineImagesEdgeZone  = new VirtualMachineImagesEdgeZoneOperations(this);
     Usage                                 = new UsageOperations(this);
     VirtualMachines                       = new VirtualMachinesOperations(this);
     VirtualMachineScaleSets               = new VirtualMachineScaleSetsOperations(this);
     VirtualMachineSizes                   = new VirtualMachineSizesOperations(this);
     Images                                = new ImagesOperations(this);
     RestorePointCollections               = new RestorePointCollectionsOperations(this);
     RestorePoints                         = new RestorePointsOperations(this);
     VirtualMachineScaleSetExtensions      = new VirtualMachineScaleSetExtensionsOperations(this);
     VirtualMachineScaleSetRollingUpgrades = new VirtualMachineScaleSetRollingUpgradesOperations(this);
     VirtualMachineScaleSetVMExtensions    = new VirtualMachineScaleSetVMExtensionsOperations(this);
     VirtualMachineScaleSetVMs             = new VirtualMachineScaleSetVMsOperations(this);
     LogAnalytics                          = new LogAnalyticsOperations(this);
     VirtualMachineRunCommands             = new VirtualMachineRunCommandsOperations(this);
     VirtualMachineScaleSetVMRunCommands   = new VirtualMachineScaleSetVMRunCommandsOperations(this);
     ResourceSkus                          = new ResourceSkusOperations(this);
     Disks                                 = new DisksOperations(this);
     Snapshots                             = new SnapshotsOperations(this);
     DiskEncryptionSets                    = new DiskEncryptionSetsOperations(this);
     DiskAccesses                          = new DiskAccessesOperations(this);
     DiskRestorePoint                      = new DiskRestorePointOperations(this);
     Galleries                             = new GalleriesOperations(this);
     GalleryImages                         = new GalleryImagesOperations(this);
     GalleryImageVersions                  = new GalleryImageVersionsOperations(this);
     GalleryApplications                   = new GalleryApplicationsOperations(this);
     GalleryApplicationVersions            = new GalleryApplicationVersionsOperations(this);
     GallerySharingProfile                 = new GallerySharingProfileOperations(this);
     SharedGalleries                       = new SharedGalleriesOperations(this);
     SharedGalleryImages                   = new SharedGalleryImagesOperations(this);
     SharedGalleryImageVersions            = new SharedGalleryImageVersionsOperations(this);
     CloudServiceRoleInstances             = new CloudServiceRoleInstancesOperations(this);
     CloudServiceRoles                     = new CloudServiceRolesOperations(this);
     CloudServices                         = new CloudServicesOperations(this);
     CloudServicesUpdateDomain             = new CloudServicesUpdateDomainOperations(this);
     CloudServiceOperatingSystems          = new CloudServiceOperatingSystemsOperations(this);
     BaseUri                               = new System.Uri("https://management.azure.com");
     AcceptLanguage                        = "en-US";
     LongRunningOperationRetryTimeout      = 30;
     GenerateClientRequestId               = true;
     SerializationSettings                 = new JsonSerializerSettings
     {
         Formatting            = Newtonsoft.Json.Formatting.Indented,
         DateFormatHandling    = Newtonsoft.Json.DateFormatHandling.IsoDateFormat,
         DateTimeZoneHandling  = Newtonsoft.Json.DateTimeZoneHandling.Utc,
         NullValueHandling     = Newtonsoft.Json.NullValueHandling.Ignore,
         ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize,
         ContractResolver      = new ReadOnlyJsonContractResolver(),
         Converters            = new List <JsonConverter>
         {
             new Iso8601TimeSpanConverter()
         }
     };
     SerializationSettings.Converters.Add(new TransformationJsonConverter());
     DeserializationSettings = new JsonSerializerSettings
     {
         DateFormatHandling    = Newtonsoft.Json.DateFormatHandling.IsoDateFormat,
         DateTimeZoneHandling  = Newtonsoft.Json.DateTimeZoneHandling.Utc,
         NullValueHandling     = Newtonsoft.Json.NullValueHandling.Ignore,
         ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize,
         ContractResolver      = new ReadOnlyJsonContractResolver(),
         Converters            = new List <JsonConverter>
         {
             new Iso8601TimeSpanConverter()
         }
     };
     CustomInitialize();
     DeserializationSettings.Converters.Add(new TransformationJsonConverter());
     DeserializationSettings.Converters.Add(new CloudErrorJsonConverter());
 }