Skip to content

Commit 9276deb

Browse files
committed
Added BatchAccountIdentity constructor and test for equality against old type.
1 parent 6e9d963 commit 9276deb

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
7+
namespace Microsoft.Azure.Management.Batch.Models
8+
{
9+
public partial class BatchAccountIdentity
10+
{
11+
public BatchAccountIdentity(ResourceIdentityType type, string principalId = default(string), string tenantId = default(string), IDictionary<string, BatchAccountIdentityUserAssignedIdentitiesValue> userAssignedIdentities = default(IDictionary<string, BatchAccountIdentityUserAssignedIdentitiesValue>))
12+
: this(type, principalId, tenantId, userAssignedIdentities as IDictionary<string, UserAssignedIdentities>)
13+
{
14+
}
15+
}
16+
}

sdk/batch/Microsoft.Azure.Management.Batch/tests/InMemoryTests/AccountTests.InMemory.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
using Microsoft.Azure.Management.Batch.Models;
77
using Microsoft.Rest;
88
using Microsoft.Rest.Azure;
9+
using Microsoft.Rest.ClientRuntime.Azure.TestFramework;
910
using System;
1011
using System.Collections.Generic;
1112
using System.Linq;
@@ -902,5 +903,18 @@ public void ListOutboundNetworkDependenciesEndpointsValidateResponse()
902903
Assert.Equal("AutoStorage endpoint for this Batch account. Applicable to all Azure Batch pools under this account.", endpoint.Endpoints[0].Description);
903904
Assert.Equal(443, endpoint.Endpoints[0].EndpointDetails[0].Port);
904905
}
906+
907+
[Fact]
908+
public void UserAssignedIdentitiesShouldSubstituteForBatchAccountIdentityUserAssignedIdentitiesValue()
909+
{
910+
string principalId = "TestPrincipal";
911+
string tenantId = "TestTenant";
912+
BatchAccountIdentityUserAssignedIdentitiesValue testIdentity = new BatchAccountIdentityUserAssignedIdentitiesValue();
913+
BatchAccountIdentity identity = new BatchAccountIdentity(ResourceIdentityType.UserAssigned, principalId, tenantId, new Dictionary<string, BatchAccountIdentityUserAssignedIdentitiesValue> { { "", testIdentity } });
914+
915+
Assert.True(testIdentity is UserAssignedIdentities);
916+
Assert.Equal(principalId, identity.PrincipalId);
917+
Assert.Equal(tenantId, identity.TenantId);
918+
}
905919
}
906920
}

0 commit comments

Comments
 (0)