Exemplo n.º 1
0
        /// <summary>
        /// Load and append the text to the given MessageBody
        /// </summary>
        /// <param name="messageBody"></param>
        public void LoadBodyText(MessageBody messageBody)
        {
            var resource = new ResourceLinkResource(messageBody);

            var response = MakeRequest <MessageBody>(HttpMethod.GET, resource);

            messageBody.BodyText = response.BodyText;
        }
 private void AssertValidResourceLink(ResourceLinkResource model, ResourceLinkResource getResult)
 {
     Assert.AreEqual(model.Data.Name, getResult.Data.Name);
     Assert.AreEqual(model.Data.Id, getResult.Data.Id);
     Assert.AreEqual(model.Data.ResourceType, getResult.Data.ResourceType);
     if (model.Data.Properties != null || getResult.Data.Properties != null)
     {
         Assert.NotNull(model.Data.Properties);
         Assert.NotNull(getResult.Data.Properties);
         Assert.AreEqual(model.Data.Properties.Notes, getResult.Data.Properties.Notes);
         Assert.AreEqual(model.Data.Properties.SourceId, getResult.Data.Properties.SourceId);
         Assert.AreEqual(model.Data.Properties.TargetId, getResult.Data.Properties.TargetId);
     }
 }
        public async Task CreateOrUpdate()
        {
            TenantResource tenant = await Client.GetTenants().GetAllAsync().FirstOrDefaultAsync(_ => true);

            SubscriptionResource subscription = await tenant.GetSubscriptions().GetAllAsync().FirstOrDefaultAsync(_ => true);

            string rgName            = Recording.GenerateAssetName("testRg-");
            ResourceGroupResource rg = await CreateResourceGroup(subscription, rgName);

            string          vnName1 = Recording.GenerateAssetName("testVn-");
            string          vnName2 = Recording.GenerateAssetName("testVn-");
            GenericResource vn1     = await CreateGenericVirtualNetwork(subscription, rg, vnName1);

            GenericResource vn2 = await CreateGenericVirtualNetwork(subscription, rg, vnName2);

            string resourceLinkName           = Recording.GenerateAssetName("link-");
            ResourceLinkResource resourceLink = await CreateResourceLink(tenant, vn1, vn2, resourceLinkName);

            Assert.AreEqual(resourceLinkName, resourceLink.Data.Name);
            Assert.ThrowsAsync <ArgumentNullException>(async() => _ = await tenant.GetResourceLinks(null).CreateOrUpdateAsync(WaitUntil.Completed, null));
            Assert.ThrowsAsync <ArgumentNullException>(async() => _ = await tenant.GetResourceLinks(rg.Id).CreateOrUpdateAsync(WaitUntil.Completed, null));
        }
Exemplo n.º 4
0
        public async Task Delete()
        {
            TenantResource tenant = await Client.GetTenants().GetAllAsync().FirstOrDefaultAsync(_ => true);

            SubscriptionResource subscription = await tenant.GetSubscriptions().GetAllAsync().FirstOrDefaultAsync(_ => true);

            string rgName            = Recording.GenerateAssetName("testRg-");
            ResourceGroupResource rg = await CreateResourceGroup(subscription, rgName);

            string          vnName1 = Recording.GenerateAssetName("testVn-");
            string          vnName2 = Recording.GenerateAssetName("testVn-");
            GenericResource vn1     = await CreateGenericVirtualNetwork(subscription, rg, vnName1);

            GenericResource vn2 = await CreateGenericVirtualNetwork(subscription, rg, vnName2);

            string resourceLinkName           = Recording.GenerateAssetName("link-");
            ResourceLinkResource resourceLink = await CreateResourceLink(tenant, vn1, vn2, resourceLinkName);

            await resourceLink.DeleteAsync(WaitUntil.Completed);

            var ex = Assert.ThrowsAsync <RequestFailedException>(async() => await resourceLink.GetAsync());

            Assert.AreEqual(404, ex.Status);
        }
Exemplo n.º 5
0
 public virtual ResourceLinkResource GetResourceLinkResource(ResourceIdentifier id)
 {
     ResourceLinkResource.ValidateResourceId(id);
     return(new ResourceLinkResource(this, id));
 }