Example #1
0
        public async Task End2EndTest()
        {
            string rgName          = SdkContext.RandomResourceName("rgRSMA", 24);
            string blobAccountName = SdkContext.RandomResourceName("rgRSMA", 24);

            ResourceGroups oResourceGroups = new ResourceGroups(this.credentials, this.subscriptionId);

            oResourceGroups.Create(rgName, this.region);
            Assert.True(oResourceGroups.IsExist(rgName));

            StorageBlobs oStorageBlobs = new StorageBlobs(credentials, subscriptionId, rgName);

            oStorageBlobs.Create(blobAccountName, this.region);

            var resources = await oResourceGroups.GetResources(rgName);

            int count = 0;

            foreach (var resource in resources)
            {
                if (resource.Kind == StorageBlobs.KIND)
                {
                    Assert.True(oStorageBlobs.IsExist(resource.Name));
                }
                else
                {
                    Assert.True(false);
                }
                count++;
            }

            Assert.AreEqual(count, 1);

            oStorageBlobs.Del(blobAccountName);
            Trace.WriteLine("Delete Storage Account");
            Assert.False(oStorageBlobs.IsExist(blobAccountName));

            oResourceGroups.Del(rgName);
            Assert.False(oResourceGroups.IsExist(rgName));
        }
        public void SanityTest()
        {
            string rgName          = SdkContext.RandomResourceName("rgRSMA", 24);
            string blobAccountName = SdkContext.RandomResourceName("rgRSMA", 24);
            string containerName   = "dummycontainer";

            ResourceGroups oResourceGroups = new ResourceGroups(this.credentials, this.subscriptionId);

            oResourceGroups.Create(rgName, this.region);

            StorageBlobs oStorageBlobs = new StorageBlobs(credentials, subscriptionId, rgName);

            oStorageBlobs.Create(blobAccountName, this.region);

            Assert.AreEqual(Formatter.CountPageable(oStorageBlobs.GetContainers(blobAccountName)), 0);
            oStorageBlobs.CreateBlobContainer(blobAccountName, containerName);
            Assert.AreEqual(Formatter.CountPageable(oStorageBlobs.GetContainers(blobAccountName)), 1);
            oStorageBlobs.DelBlobContainer(blobAccountName, containerName);
            Assert.AreEqual(Formatter.CountPageable(oStorageBlobs.GetContainers(blobAccountName)), 0);

            // Blob Storage Account shall be deleted once resource group is deleted.
            oResourceGroups.Del(rgName);
        }