cases:
  - note: flattens sub-resource arrays
    input:
      name: myNsg
      type: "Microsoft.Network/networkSecurityGroups"
      properties:
        securityRules:
          - name: rule1
            properties:
              protocol: Tcp
              access: Allow
          - name: rule2
            properties:
              protocol: "*"
              access: Deny
    sub_resource_arrays: ["securityRules"]
    resource_type: "Microsoft.Network/networkSecurityGroups"
    expected_normalized:
      name: myNsg
      type: "Microsoft.Network/networkSecurityGroups"
      securityrules:
        - name: rule1
          protocol: Tcp
          access: Allow
        - name: rule2
          protocol: "*"
          access: Deny
    round_trip: true
    expected_round_trip:
      name: myNsg
      type: "Microsoft.Network/networkSecurityGroups"
      properties:
        securityrules:
          - name: rule1
            properties:
              protocol: Tcp
              access: Allow
          - name: rule2
            properties:
              protocol: "*"
              access: Deny

  - note: nested sub-resource arrays
    input:
      name: myVnet
      properties:
        subnets:
          - name: subnet1
            properties:
              addressPrefix: "10.0.0.0/24"
              ipConfigurations:
                - name: ipconfig1
                  properties:
                    privateIPAddress: "10.0.0.4"
    sub_resource_arrays: ["subnets", "subnets.ipConfigurations"]
    resource_type: "Microsoft.Network/virtualNetworks"
    expected_normalized:
      name: myVnet
      subnets:
        - name: subnet1
          addressprefix: "10.0.0.0/24"
          ipconfigurations:
            - name: ipconfig1
              privateipaddress: "10.0.0.4"
    round_trip: true
    expected_round_trip:
      name: myVnet
      properties:
        subnets:
          - name: subnet1
            properties:
              addressprefix: "10.0.0.0/24"
              ipconfigurations:
                - name: ipconfig1
                  properties:
                    privateipaddress: "10.0.0.4"

  - note: sub-resource element without properties
    input:
      name: test
      properties:
        items:
          - name: plain-object
            enabled: true
    sub_resource_arrays: ["items"]
    resource_type: test
    expected_normalized:
      name: test
      items:
        - name: plain-object
          enabled: true
    round_trip: true
    expected_round_trip:
      name: test
      properties:
        items:
          - name: plain-object
            properties:
              enabled: true

  - note: case-insensitive sub-resource match
    input:
      name: test
      properties:
        securityRules:
          - name: r1
            properties:
              protocol: Tcp
    sub_resource_arrays: ["SecurityRules"]
    resource_type: test
    expected_normalized:
      name: test
      securityrules:
        - name: r1
          protocol: Tcp
    round_trip: true
    expected_round_trip:
      name: test
      properties:
        securityrules:
          - name: r1
            properties:
              protocol: Tcp
