Esempio n. 1
0
        protected async Task <AfdOriginResource> CreateAfdOrigin(AfdOriginGroupResource originGroup, string originName)
        {
            AfdOriginData input = ResourceDataHelper.CreateAfdOriginData();
            var           lro   = await originGroup.GetAfdOrigins().CreateOrUpdateAsync(WaitUntil.Completed, originName, input);

            return(lro.Value);
        }
        public async Task CreateOrUpdate()
        {
            SubscriptionResource subscription = await Client.GetDefaultSubscriptionAsync();

            ResourceGroupResource rg = await CreateResourceGroup(subscription, "testRg-");

            string          afdProfileName     = Recording.GenerateAssetName("AFDProfile-");
            ProfileResource afdProfileResource = await CreateAfdProfile(rg, afdProfileName, CdnSkuName.StandardAzureFrontDoor);

            string afdOriginGroupName = Recording.GenerateAssetName("AFDOriginGroup-");
            AfdOriginGroupResource afdOriginGroupInstance = await CreateAfdOriginGroup(afdProfileResource, afdOriginGroupName);

            string            afdOriginName     = Recording.GenerateAssetName("AFDOrigin-");
            AfdOriginResource afdOriginInstance = await CreateAfdOrigin(afdOriginGroupInstance, afdOriginName);

            Assert.AreEqual(afdOriginName, afdOriginInstance.Data.Name);
            Assert.ThrowsAsync <ArgumentNullException>(async() => _ = await afdOriginGroupInstance.GetAfdOrigins().CreateOrUpdateAsync(WaitUntil.Completed, null, afdOriginInstance.Data));
            Assert.ThrowsAsync <ArgumentNullException>(async() => _ = await afdOriginGroupInstance.GetAfdOrigins().CreateOrUpdateAsync(WaitUntil.Completed, afdOriginName, null));
        }
        public async Task Get()
        {
            SubscriptionResource subscription = await Client.GetDefaultSubscriptionAsync();

            ResourceGroupResource rg = await CreateResourceGroup(subscription, "testRg-");

            string          afdProfileName     = Recording.GenerateAssetName("AFDProfile-");
            ProfileResource afdProfileResource = await CreateAfdProfile(rg, afdProfileName, CdnSkuName.StandardAzureFrontDoor);

            string afdOriginGroupName = Recording.GenerateAssetName("AFDOriginGroup-");
            AfdOriginGroupResource afdOriginGroupInstance = await CreateAfdOriginGroup(afdProfileResource, afdOriginGroupName);

            string            afdOriginName     = Recording.GenerateAssetName("AFDOrigin-");
            AfdOriginResource afdOriginInstance = await CreateAfdOrigin(afdOriginGroupInstance, afdOriginName);

            AfdOriginResource getAfdOriginInstance = await afdOriginGroupInstance.GetAfdOrigins().GetAsync(afdOriginName);

            ResourceDataHelper.AssertValidAfdOrigin(afdOriginInstance, getAfdOriginInstance);
            Assert.ThrowsAsync <ArgumentNullException>(async() => _ = await afdOriginGroupInstance.GetAfdOrigins().GetAsync(null));
        }
        public async Task List()
        {
            SubscriptionResource subscription = await Client.GetDefaultSubscriptionAsync();

            ResourceGroupResource rg = await CreateResourceGroup(subscription, "testRg-");

            string          afdProfileName     = Recording.GenerateAssetName("AFDProfile-");
            ProfileResource afdProfileResource = await CreateAfdProfile(rg, afdProfileName, CdnSkuName.StandardAzureFrontDoor);

            string afdOriginGroupName = Recording.GenerateAssetName("AFDOriginGroup-");
            AfdOriginGroupResource afdOriginGroupInstance = await CreateAfdOriginGroup(afdProfileResource, afdOriginGroupName);

            string afdOriginName = Recording.GenerateAssetName("AFDOrigin-");

            _ = await CreateAfdOrigin(afdOriginGroupInstance, afdOriginName);

            int count = 0;

            await foreach (var tempAfdOrigin in afdOriginGroupInstance.GetAfdOrigins().GetAllAsync())
            {
                count++;
            }
            Assert.AreEqual(count, 1);
        }