public void IdentifierIsParsedFromVeryLongId()
 {
     ResourceIdentifier id = new ResourceIdentifier("/subscriptions/abc123/resourceGroups/group1/providers/Microsoft.Test/servers/r12345sql/subserver/r5555/db/r45678db");
     Assert.Equal("abc123", id.Subscription);
     Assert.Equal("group1", id.ResourceGroupName);
     Assert.Equal("Microsoft.Test/servers/subserver/db", id.ResourceType);
     Assert.Equal("servers/r12345sql/subserver/r5555", id.ParentResource);
     Assert.Equal("r45678db", id.ResourceName);
 }
 public void IdentifierIsParsedFromShortId()
 {
     ResourceIdentifier id = new ResourceIdentifier("/subscriptions/abc123/resourceGroups/group1/providers/Microsoft.Test/db/r45678db");
     Assert.Equal("abc123", id.Subscription);
     Assert.Equal("group1", id.ResourceGroupName);
     Assert.Equal("Microsoft.Test/db", id.ResourceType);
     Assert.Null(id.ParentResource);
     Assert.Equal("r45678db", id.ResourceName);
 }
        public void IdentifierIsConstructedWithoutParent()
        {
            ResourceIdentifier id = new ResourceIdentifier();
            id.Subscription = "abc123";
            id.ResourceGroupName = "group1";
            id.ResourceType = "Microsoft.Test/db";
            id.ResourceName = "r45678db";

            Assert.Equal("/subscriptions/abc123/resourceGroups/group1/providers/Microsoft.Test/db/r45678db", id.ToString());
        }
        public void IdentifierIsConstructedFromProvidedValues()
        {
            ResourceIdentifier id = new ResourceIdentifier();
            id.Subscription = "abc123";
            id.ResourceGroupName = "group1";
            id.ResourceType = "Microsoft.Test/servers/db";
            id.ParentResource = "servers/r12345sql";
            id.ResourceName = "r45678db";

            Assert.Equal("/subscriptions/abc123/resourceGroups/group1/providers/Microsoft.Test/servers/r12345sql/db/r45678db", id.ToString());
        }
 public static PSResource ToPSResource(this Resource resource, ResourcesClient client)
 {
     ResourceIdentifier identifier = new ResourceIdentifier(resource.Id);
     return new PSResource()
     {
         Name = identifier.ResourceName,
         Location = resource.Location,
         ResourceType = identifier.ResourceType,
         ResourceGroupName = identifier.ResourceGroupName,
         ParentResource = identifier.ParentResource,
         Properties = JsonUtilities.DeserializeJson(resource.Properties),
         PropertiesText = resource.Properties
     };
 }
        public void IdentifierParsedIsSkippedWithEmptyId()
        {
            ResourceIdentifier id = new ResourceIdentifier(null);
            Assert.Null(id.Subscription);
            Assert.Null(id.ResourceGroupName);
            Assert.Null(id.ResourceType);
            Assert.Null(id.ParentResource);
            Assert.Null(id.ResourceName);

            id = new ResourceIdentifier("");
            Assert.Null(id.Subscription);
            Assert.Null(id.ResourceGroupName);
            Assert.Null(id.ResourceType);
            Assert.Null(id.ParentResource);
            Assert.Null(id.ResourceName);
        }
        public void IdentifierIsConstructedWithMissingParameters()
        {
            ResourceIdentifier id = new ResourceIdentifier();

            Assert.Equal("/subscriptions//resourceGroups//providers///", id.ToString());
        }