private void ValidateSharedGalleryImageVersion(SharedGalleryImageVersion sharedGalleryImageVersion) { string expectedId = "/SharedGalleries/" + GalleryUniqueName + "/Images/" + GalleryImageName + "/Versions/" + GalleryImageVersionName; Assert.Equal(expectedId, sharedGalleryImageVersion.UniqueId); Assert.NotNull(sharedGalleryImageVersion.StorageProfile); Assert.NotNull(sharedGalleryImageVersion.ExcludeFromLatest); Assert.NotNull(sharedGalleryImageVersion.StorageProfile.OsDiskImage); }
public void SharedGalleryImageVersion_GetAndList_Tests() { using (MockContext context = MockContext.Start(this.GetType())) { EnsureClientsInitialized(context); SharedGalleryImageVersion sharedGalleryImageVersionOut = m_CrpClient.SharedGalleryImageVersions.Get(galleryAccessLocation, GalleryUniqueName, GalleryImageName, GalleryImageVersionName); Trace.TraceInformation("Got the shared gallery image name {0} which is shared to current subscription.", GalleryImageVersionName); Assert.NotNull(sharedGalleryImageVersionOut); ValidateSharedGalleryImageVersion(sharedGalleryImageVersionOut); IPage <SharedGalleryImageVersion> sharedGalleryImageVersionsList = m_CrpClient.SharedGalleryImageVersions.List(galleryAccessLocation, GalleryUniqueName, GalleryImageName, "tenant"); Trace.TraceInformation("Got the shared gallery image versions which are shared to tenant of current subscription."); int count = sharedGalleryImageVersionsList.Count(); Assert.Equal(1, count); foreach (SharedGalleryImageVersion galleryImageVersion in sharedGalleryImageVersionsList) { if (galleryImageVersion.Name == GalleryImageVersionName) { ValidateSharedGalleryImageVersion(galleryImageVersion); break; } } sharedGalleryImageVersionsList = m_CrpClient.SharedGalleryImageVersions.List(galleryAccessLocation, GalleryUniqueName, GalleryImageName); count = sharedGalleryImageVersionsList.Count(); Assert.Equal(1, count); Trace.TraceInformation("Got the shared gallery {0} which is shared to current subscription.", GalleryUniqueName); ValidateSharedGalleryImageVersion(sharedGalleryImageVersionsList.First()); sharedGalleryImageVersionsList = m_CrpClient.SharedGalleryImageVersions.List(galleryAccessLocation, GalleryUniqueName, GalleryImageName, sharedTo: SharedToValues.Tenant); count = sharedGalleryImageVersionsList.Count(); Assert.Equal(1, count); Trace.TraceInformation("Got the shared gallery {0} which is shared to current tenant.", GalleryUniqueName); ValidateSharedGalleryImageVersion(sharedGalleryImageVersionsList.First()); } }
public void SharedGalleryGet() { if (this.IsParameterBound(c => c.Name)) { SharedGalleryImageVersion result = SharedGalleryImageVersionsClient.Get(this.Location, this.GalleryUniqueName, this.GalleryImageDefinitionName, this.Name); var psObject = new PSSharedGalleryImageVersion(); ComputeAutomationAutoMapperProfile.Mapper.Map <SharedGalleryImageVersion, PSSharedGalleryImageVersion>(result, psObject); WriteObject(psObject); } else { Rest.Azure.IPage <SharedGalleryImageVersion> result = new Page <SharedGalleryImageVersion>(); if (this.IsParameterBound(c => c.Scope) && this.Scope != "subscription") { result = SharedGalleryImageVersionsClient.List(this.Location, this.GalleryUniqueName, this.GalleryImageDefinitionName, this.Scope); } else { result = SharedGalleryImageVersionsClient.List(this.Location, this.GalleryUniqueName, this.GalleryImageDefinitionName); } var resultList = result.ToList(); var nextPageLink = result.NextPageLink; while (!string.IsNullOrEmpty(nextPageLink)) { var pageResult = SharedGalleryImageVersionsClient.ListNext(nextPageLink); foreach (var pageItem in pageResult) { resultList.Add(pageItem); } nextPageLink = pageResult.NextPageLink; } var psObject = new List <PSSharedGalleryImageVersionList>(); foreach (var r in resultList) { psObject.Add(ComputeAutomationAutoMapperProfile.Mapper.Map <SharedGalleryImageVersion, PSSharedGalleryImageVersionList>(r)); } WriteObject(psObject); } }
private void ValidateSharedGalleryImageVersion(SharedGalleryImageVersion sharedGalleryImageVersion) { string expectedId = "/SharedGalleries/" + GalleryUniqueName + "/Images/" + GalleryImageName + "/Versions/" + GalleryImageVersionName; Assert.Equal(expectedId, sharedGalleryImageVersion.UniqueId); }