cases:
  - note: flattens root properties
    input:
      name: myStorage
      type: "Microsoft.Storage/storageAccounts"
      location: westus2
      properties:
        supportsHttpsTrafficOnly: true
        isHnsEnabled: false
    expected_normalized:
      name: myStorage
      type: "Microsoft.Storage/storageAccounts"
      location: westus2
      supportshttpstrafficonly: true
      ishnsenabled: false
    round_trip: true
    expected_round_trip:
      name: myStorage
      type: "Microsoft.Storage/storageAccounts"
      location: westus2
      properties:
        supportshttpstrafficonly: true
        ishnsenabled: false

  - note: preserves root level precedence
    input:
      name: root-name
      properties:
        name: props-name
    expected_normalized:
      name: root-name
    round_trip: true
    expected_round_trip:
      name: root-name

  - note: leaves plain arrays alone
    input:
      name: test
      properties:
        networkAcls:
          ipRules:
            - value: "10.0.0.1"
              action: Allow
            - value: "10.0.0.2"
              action: Deny
    expected_normalized:
      name: test
      networkacls:
        iprules:
          - value: "10.0.0.1"
            action: Allow
          - value: "10.0.0.2"
            action: Deny
    round_trip: true
    expected_round_trip:
      name: test
      properties:
        networkacls:
          iprules:
            - value: "10.0.0.1"
              action: Allow
            - value: "10.0.0.2"
              action: Deny

  - note: handles sku at root
    input:
      name: test
      sku:
        name: Standard_LRS
        tier: Standard
      properties:
        supportsHttpsTrafficOnly: true
    expected_normalized:
      name: test
      sku:
        name: Standard_LRS
        tier: Standard
      supportshttpstrafficonly: true
    round_trip: true
    expected_round_trip:
      name: test
      sku:
        name: Standard_LRS
        tier: Standard
      properties:
        supportshttpstrafficonly: true

  - note: non-object returns clone
    input: "just a string"
    expected_normalized: "just a string"
    round_trip: true

  - note: empty properties
    input:
      name: test
      properties: {}
    expected_normalized:
      name: test
    round_trip: true
    expected_round_trip:
      name: test

  - note: missing properties
    input:
      name: test
      location: eastus
    expected_normalized:
      name: test
      location: eastus
    round_trip: true

  - note: preserves all root fields
    input:
      name: r
      type: t
      location: l
      kind: k
      id: "/sub/rg/r"
      tags:
        env: prod
      identity:
        type: SystemAssigned
        principalId: pid-123
        userAssignedIdentities:
          /subscriptions/Sub/resourceGroups/Rg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/Uai1: {}
      sku:
        name: Basic
      plan:
        name: p1
      zones: ["1", "2"]
      managedBy: "/sub/other"
      etag: "W/\"abc\""
      apiVersion: "2023-01-01"
      fullName: parent/child
      systemData:
        createdBy: admin
      extendedLocation:
        name: edge1
        type: EdgeZone
      properties:
        someProp: true
    expected_normalized:
      name: r
      type: t
      location: l
      kind: k
      id: "/sub/rg/r"
      tags:
        env: prod
      identity:
        type: SystemAssigned
        principalid: pid-123
        userassignedidentities:
          /subscriptions/Sub/resourceGroups/Rg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/Uai1: {}
      sku:
        name: Basic
      plan:
        name: p1
      zones: ["1", "2"]
      managedby: "/sub/other"
      etag: "W/\"abc\""
      apiversion: "2023-01-01"
      fullname: parent/child
      systemdata:
        createdby: admin
      extendedlocation:
        name: edge1
        type: EdgeZone
      someprop: true
    round_trip: true
    expected_round_trip:
      name: r
      type: t
      location: l
      kind: k
      id: "/sub/rg/r"
      tags:
        env: prod
      identity:
        type: SystemAssigned
        principalId: pid-123
        userAssignedIdentities:
          /subscriptions/Sub/resourceGroups/Rg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/Uai1: {}
      sku:
        name: Basic
      plan:
        name: p1
      zones: ["1", "2"]
      managedBy: "/sub/other"
      etag: "W/\"abc\""
      apiVersion: "2023-01-01"
      fullName: parent/child
      systemData:
        createdBy: admin
      extendedLocation:
        name: edge1
        type: EdgeZone
      properties:
        someprop: true

  - note: primitive array pass through
    input:
      name: test
      properties:
        allowedIPs: ["10.0.0.1", "10.0.0.2", "10.0.0.3"]
    expected_normalized:
      name: test
      allowedips: ["10.0.0.1", "10.0.0.2", "10.0.0.3"]
    round_trip: true
    expected_round_trip:
      name: test
      properties:
        allowedips: ["10.0.0.1", "10.0.0.2", "10.0.0.3"]

  - note: deeply nested object no sub-resource
    input:
      name: test
      properties:
        networkAcls:
          defaultAction: Deny
          virtualNetworkRules:
            - id: "/vnet/subnet1"
              action: Allow
    expected_normalized:
      name: test
      networkacls:
        defaultaction: Deny
        virtualnetworkrules:
          - id: "/vnet/subnet1"
            action: Allow
    round_trip: true
    expected_round_trip:
      name: test
      properties:
        networkacls:
          defaultaction: Deny
          virtualnetworkrules:
            - id: "/vnet/subnet1"
              action: Allow

  - note: unknown root fields are dropped (not in ROOT_FIELDS)
    input:
      name: test
      type: "Microsoft.Foo/bars"
      fooExtension:
        barBaz: 1
      properties:
        enabled: true
    expected_normalized:
      name: test
      type: "Microsoft.Foo/bars"
      enabled: true
    round_trip: true
    expected_round_trip:
      name: test
      type: "Microsoft.Foo/bars"
      properties:
        enabled: true
