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.");
        }