コード例 #1
0
        public async Task GetAllInSubscription()
        {
            var collection = await GetGalleryCollectionAsync();

            var name1  = Recording.GenerateAssetName("testGallery_");
            var name2  = Recording.GenerateAssetName("testGallery_");
            var input1 = ResourceDataHelper.GetBasicGalleryData(DefaultLocation);
            var input2 = ResourceDataHelper.GetBasicGalleryData(DefaultLocation);

            _ = await collection.CreateOrUpdateAsync(WaitUntil.Completed, name1, input1);

            _ = await collection.CreateOrUpdateAsync(WaitUntil.Completed, name2, input2);

            GalleryResource gallery1 = null, gallery2 = null;

            await foreach (var gallery in DefaultSubscription.GetGalleriesAsync())
            {
                if (gallery.Data.Name == name1)
                {
                    gallery1 = gallery;
                }
                if (gallery.Data.Name == name2)
                {
                    gallery2 = gallery;
                }
            }

            Assert.NotNull(gallery1);
            Assert.NotNull(gallery2);
        }
コード例 #2
0
        public async Task Get()
        {
            var name    = Recording.GenerateAssetName("testGallery_");
            var gallery = await CreateGalleryAsync(name);

            GalleryResource gallery2 = await gallery.GetAsync();

            ResourceDataHelper.AssertGallery(gallery.Data, gallery2.Data);
        }
コード例 #3
0
        private async Task <GalleryResource> CreateGalleryAsync(string galleryName)
        {
            _resourceGroup = await CreateResourceGroupAsync();

            var galleryInput = ResourceDataHelper.GetBasicGalleryData(DefaultLocation);
            var lro          = await _resourceGroup.GetGalleries().CreateOrUpdateAsync(WaitUntil.Completed, galleryName, galleryInput);

            _gallery = lro.Value;
            return(_gallery);
        }
コード例 #4
0
        private async Task <GalleryImageCollection> GetGalleryImageCollectionAsync()
        {
            _resourceGroup = await CreateResourceGroupAsync();

            var galleryName = Recording.GenerateAssetName("testGallery_");
            var input       = ResourceDataHelper.GetBasicGalleryData(DefaultLocation);
            var lro         = await _resourceGroup.GetGalleries().CreateOrUpdateAsync(WaitUntil.Completed, galleryName, input);

            _gallery = lro.Value;
            return(_gallery.GetGalleryImages());
        }
コード例 #5
0
        public async Task CreateOrUpdate()
        {
            var collection = await GetGalleryCollectionAsync();

            var name  = Recording.GenerateAssetName("testGallery_");
            var input = ResourceDataHelper.GetBasicGalleryData(DefaultLocation);
            var lro   = await collection.CreateOrUpdateAsync(WaitUntil.Completed, name, input);

            GalleryResource gallery = lro.Value;

            Assert.AreEqual(name, gallery.Data.Name);
        }
コード例 #6
0
        public async Task SetTags()
        {
            var name    = Recording.GenerateAssetName("testGallery_");
            var gallery = await CreateGalleryAsync(name);

            var tags = new Dictionary <string, string>()
            {
                { "key", "value" }
            };
            GalleryResource updatedGallery = await gallery.SetTagsAsync(tags);

            Assert.AreEqual(tags, updatedGallery.Data.Tags);
        }
コード例 #7
0
        public async Task Get()
        {
            var collection = await GetGalleryCollectionAsync();

            var name  = Recording.GenerateAssetName("testGallery_");
            var input = ResourceDataHelper.GetBasicGalleryData(DefaultLocation);
            var lro   = await collection.CreateOrUpdateAsync(WaitUntil.Completed, name, input);

            GalleryResource gallery1 = lro.Value;
            GalleryResource gallery2 = await collection.GetAsync(name);

            ResourceDataHelper.AssertGallery(gallery1.Data, gallery2.Data);
        }
コード例 #8
0
        private async Task <GalleryImageResource> CreateGalleryImageAsync(string galleryImageName)
        {
            var galleryName = Recording.GenerateAssetName("testGallery_");

            _gallery = await CreateGalleryAsync(galleryName);

            var identifier = ResourceDataHelper.GetGalleryImageIdentifier(
                Recording.GenerateAssetName("publisher"),
                Recording.GenerateAssetName("offer"),
                Recording.GenerateAssetName("sku"));
            var imageInput = ResourceDataHelper.GetBasicGalleryImageData(DefaultLocation, OperatingSystemTypes.Linux, identifier);
            var lro        = await _gallery.GetGalleryImages().CreateOrUpdateAsync(WaitUntil.Completed, galleryImageName, imageInput);

            return(lro.Value);
        }
コード例 #9
0
        public async Task Exists()
        {
            var collection = await GetGalleryCollectionAsync();

            var name  = Recording.GenerateAssetName("testGallery_");
            var input = ResourceDataHelper.GetBasicGalleryData(DefaultLocation);
            var lro   = await collection.CreateOrUpdateAsync(WaitUntil.Completed, name, input);

            GalleryResource gallery = lro.Value;

            Assert.IsTrue(await collection.ExistsAsync(name));
            Assert.IsFalse(await collection.ExistsAsync(name + "1"));

            Assert.ThrowsAsync <ArgumentNullException>(async() => _ = await collection.ExistsAsync(null));
        }
コード例 #10
0
        public async Task Update()
        {
            var name    = Recording.GenerateAssetName("testGallery_");
            var gallery = await CreateGalleryAsync(name);

            var description = "This is a gallery for test";
            var update      = new GalleryPatch()
            {
                Description = description
            };
            var lro = await gallery.UpdateAsync(WaitUntil.Completed, update);

            GalleryResource updatedGallery = lro.Value;

            Assert.AreEqual(description, updatedGallery.Data.Description);
        }