public void UserAssignedIdentitiesShouldSubstituteForBatchAccountIdentityUserAssignedIdentitiesValue()
        {
            string principalId = "TestPrincipal";
            string tenantId    = "TestTenant";
            BatchAccountIdentityUserAssignedIdentitiesValue testIdentity = new BatchAccountIdentityUserAssignedIdentitiesValue();
            BatchAccountIdentity identity = new BatchAccountIdentity(ResourceIdentityType.UserAssigned, principalId, tenantId, new Dictionary <string, BatchAccountIdentityUserAssignedIdentitiesValue> {
                { "", testIdentity }
            });

            Assert.True(testIdentity is UserAssignedIdentities);
            Assert.Equal(principalId, identity.PrincipalId);
            Assert.Equal(tenantId, identity.TenantId);
        }
        public void UserAssignedIdentitiesShouldSubstituteForBatchAccountIdentityUserAssignedIdentitiesValue()
        {
            string testPrincipalId = "testPrincipalId";
            string testClientId    = "testClientId";
            string testAccount     = "testAccount";

#pragma warning disable CS0618 // Type or member is obsolete
            BatchAccountIdentityUserAssignedIdentitiesValue testIdentity = new BatchAccountIdentityUserAssignedIdentitiesValue(testPrincipalId, testClientId);
            BatchAccountIdentity identity = new BatchAccountIdentity(ResourceIdentityType.UserAssigned, new Dictionary <string, BatchAccountIdentityUserAssignedIdentitiesValue> {
                { testAccount, testIdentity }
            });
#pragma warning restore CS0618 // Type or member is obsolete
            Assert.True(testIdentity is UserAssignedIdentities);
            Assert.Equal(testPrincipalId, identity.UserAssignedIdentities[testAccount].PrincipalId);
            Assert.Equal(testClientId, identity.UserAssignedIdentities[testAccount].ClientId);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Builds an AccountResource object using the specified parameters
        /// </summary>
        public static BatchAccount CreateAccountResource(
            string accountName,
            string resourceGroupName,
            string location  = "location",
            Hashtable tags   = null,
            string storageId = null,
            bool dedicatedCoreQuotaPerVMFamilyEnforced = false,
            IList <VirtualMachineFamilyCoreQuota> machineFamilyQuotas = null,
            BatchAccountIdentity identity = null)
        {
            string tenantUrlEnding = "batch-test.windows-int.net";
            string endpoint        = string.Format("{0}.{1}", accountName, tenantUrlEnding);
            string subscription    = Guid.Empty.ToString();
            string resourceGroup   = resourceGroupName;

            string id = string.Format("id/subscriptions/{0}/resourceGroups/{1}/providers/Microsoft.Batch/batchAccounts/abc", subscription, resourceGroup);

            machineFamilyQuotas = machineFamilyQuotas ?? new List <VirtualMachineFamilyCoreQuota> {
                new VirtualMachineFamilyCoreQuota("foo", 55)
            };

            BatchAccount resource = new BatchAccount(
                dedicatedCoreQuota: DefaultQuotaCount,
                lowPriorityCoreQuota: DefaultQuotaCount,
                poolQuota: DefaultQuotaCount,
                activeJobAndJobScheduleQuota: DefaultQuotaCount,
                accountEndpoint: endpoint,
                id: id,
                type: "type",
                location: location,
                provisioningState: ProvisioningState.Succeeded,
                autoStorage: new AutoStorageProperties()
            {
                StorageAccountId = storageId
            },
                tags: tags == null ? null : TagsConversionHelper.CreateTagDictionary(tags, true),
                dedicatedCoreQuotaPerVMFamilyEnforced: dedicatedCoreQuotaPerVMFamilyEnforced,
                dedicatedCoreQuotaPerVMFamily: machineFamilyQuotas,
                identity: identity ?? new BatchAccountIdentity(ResourceIdentityType.None));

            return(resource);
        }