Skip to content

Commit

Permalink
Try to fix test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
msJinLei committed Oct 13, 2022
1 parent 2902e1e commit 1137072
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/Accounts/Accounts.Test/AzureRMProfileTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ private static RMProfileClient SetupTestEnvironment(List<string> tenants, List<s
AzureSession.Instance.AuthenticationFactory = new MockTokenAuthenticationFactory(DefaultAccount,
Guid.NewGuid().ToString(), DefaultTenant.ToString());
var subscriptionList = new Queue<List<string>>(subscriptionLists);
MockSubscriptionClientFactory.Reset();
var clientFactory = new MockSubscriptionClientFactory(tenants, subscriptionList);
if (SubscripitonGetList != null)
{
Expand Down Expand Up @@ -141,6 +142,7 @@ private static AzureRmProfile SetupLogin(List<string> tenants, params List<strin
{
AzureSession.Instance.AuthenticationFactory = new AuthenticationFactory();
var subscriptionList = new Queue<List<string>>(subscriptionLists);
MockSubscriptionClientFactory.Reset();
var clientFactory = new MockSubscriptionClientFactory(tenants, subscriptionList);
var mock = new MockClientFactory(null, new List<object>
{
Expand Down
13 changes: 13 additions & 0 deletions src/Accounts/Accounts.Test/AzureRMProfileTestsForMultitenant.cs
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,7 @@ public void LoginByTenant()
string subscriptionA = Guid.NewGuid().ToString()
, subscriptionB = Guid.NewGuid().ToString()
, subscriptionC = Guid.NewGuid().ToString();
MockSubscriptionClientFactory.Reset();
var clientFactory = new MockSubscriptionClientFactory();

Dictionary<string, string> subscriptionList = GetFirstTenantSubscriptionsJson(tenantA, subscriptionA, subscriptionB, subscriptionC, tenantB);
Expand Down Expand Up @@ -325,6 +326,7 @@ public void LoginBySubscriptionInMultitenantsHomeFirst()
, subscriptionB = Guid.NewGuid().ToString()
, subscriptionC = Guid.NewGuid().ToString()
, subscriptionD = Guid.NewGuid().ToString();
MockSubscriptionClientFactory.Reset();
var clientFactory = new MockSubscriptionClientFactory();

var subscriptionListA = GetFirstTenantSubscriptionsJson(tenantA, subscriptionA, subscriptionB, subscriptionC, tenantB);
Expand Down Expand Up @@ -368,6 +370,7 @@ public void LoginBySubscriptionInMultitenantsHomeSecond()
, subscriptionB = Guid.NewGuid().ToString()
, subscriptionC = Guid.NewGuid().ToString()
, subscriptionD = Guid.NewGuid().ToString();
MockSubscriptionClientFactory.Reset();
var clientFactory = new MockSubscriptionClientFactory();

var tenantList = GetTenantsJson(tenantA, tenantB);
Expand Down Expand Up @@ -414,6 +417,7 @@ public void LoginBySubscriptionInManagedByTenants()
, subscriptionB = Guid.NewGuid().ToString()
, subscriptionC = Guid.NewGuid().ToString()
, subscriptionD = Guid.NewGuid().ToString();
MockSubscriptionClientFactory.Reset();
var clientFactory = new MockSubscriptionClientFactory();

Dictionary<string, string> subscriptionListA = GetFirstTenantSubscriptionsJson(tenantA, subscriptionA, subscriptionB, subscriptionC, tenantB);
Expand Down Expand Up @@ -458,6 +462,7 @@ public void LoginBySubscriptionTenant()
, subscriptionB = Guid.NewGuid().ToString()
, subscriptionC = Guid.NewGuid().ToString()
, subscriptionD = Guid.NewGuid().ToString();
MockSubscriptionClientFactory.Reset();
var clientFactory = new MockSubscriptionClientFactory();

Dictionary<string, string> subscriptionListA = GetFirstTenantSubscriptionsJson(tenantA, subscriptionA, subscriptionB, subscriptionC, tenantB);
Expand Down Expand Up @@ -501,6 +506,7 @@ public void LoginByTenantSubscriptionNotExist()
, subscriptionB = Guid.NewGuid().ToString()
, subscriptionC = Guid.NewGuid().ToString()
, subscriptionD = Guid.NewGuid().ToString();
MockSubscriptionClientFactory.Reset();
var clientFactory = new MockSubscriptionClientFactory();

Dictionary<string, string> subscriptionListA = GetFirstTenantSubscriptionsJson(tenantA, subscriptionA, subscriptionB, subscriptionC, tenantB);
Expand Down Expand Up @@ -542,6 +548,7 @@ public void LoginSubscriptionNameNotExist()
, subscriptionB = Guid.NewGuid().ToString()
, subscriptionC = Guid.NewGuid().ToString()
, subscriptionD = Guid.NewGuid().ToString();
MockSubscriptionClientFactory.Reset();
var clientFactory = new MockSubscriptionClientFactory();

Dictionary<string, string> subscriptionListA = GetFirstTenantSubscriptionsJson(tenantA, subscriptionA, subscriptionB, subscriptionC, tenantB);
Expand Down Expand Up @@ -580,6 +587,7 @@ public void SetContextByValidTenant()
string subscriptionA = Guid.NewGuid().ToString()
, subscriptionB = Guid.NewGuid().ToString()
, subscriptionC = Guid.NewGuid().ToString();
MockSubscriptionClientFactory.Reset();
var clientFactory = new MockSubscriptionClientFactory();

Dictionary<string, string> subscriptionList = GetFirstTenantSubscriptionsJson(tenantA, subscriptionA, subscriptionB, subscriptionC, tenantB);
Expand Down Expand Up @@ -615,6 +623,7 @@ public void SetContextBySubscriptionIdInHomeTenant()
, subscriptionB = Guid.NewGuid().ToString()
, subscriptionC = Guid.NewGuid().ToString()
, subscriptionD = Guid.NewGuid().ToString();
MockSubscriptionClientFactory.Reset();
var clientFactory = new MockSubscriptionClientFactory();

var subscriptionListA = GetFirstTenantSubscriptionsJson(tenantA, subscriptionA, subscriptionB, subscriptionC, tenantB);
Expand Down Expand Up @@ -682,6 +691,7 @@ public void SetContextBySubscriptionNameInHomeTenant()
, subscriptionB = Guid.NewGuid().ToString()
, subscriptionC = Guid.NewGuid().ToString()
, subscriptionD = Guid.NewGuid().ToString();
MockSubscriptionClientFactory.Reset();
var clientFactory = new MockSubscriptionClientFactory();

var tenantList = GetTenantsJson(tenantA, tenantB);
Expand Down Expand Up @@ -720,6 +730,7 @@ public void SetContextBySubscriptionInManagedByTenants()
, subscriptionB = Guid.NewGuid().ToString()
, subscriptionC = Guid.NewGuid().ToString()
, subscriptionD = Guid.NewGuid().ToString();
MockSubscriptionClientFactory.Reset();
var clientFactory = new MockSubscriptionClientFactory();

Dictionary<string, string> subscriptionListA = GetFirstTenantSubscriptionsJson(tenantA, subscriptionA, subscriptionB, subscriptionC, tenantB);
Expand Down Expand Up @@ -754,6 +765,7 @@ public void SetContextBySubscriptionTenant()
, subscriptionB = Guid.NewGuid().ToString()
, subscriptionC = Guid.NewGuid().ToString()
, subscriptionD = Guid.NewGuid().ToString();
MockSubscriptionClientFactory.Reset();
var clientFactory = new MockSubscriptionClientFactory();

Dictionary<string, string> subscriptionListA = GetFirstTenantSubscriptionsJson(tenantA, subscriptionA, subscriptionB, subscriptionC, tenantB);
Expand Down Expand Up @@ -789,6 +801,7 @@ public void SetContextBySubscriptionTenantNotExist()
, subscriptionB = Guid.NewGuid().ToString()
, subscriptionC = Guid.NewGuid().ToString()
, subscriptionD = Guid.NewGuid().ToString();
MockSubscriptionClientFactory.Reset();
var clientFactory = new MockSubscriptionClientFactory();

Dictionary<string, string> subscriptionListB = GetSecondTenantSubscriptionsJson(tenantB, subscriptionA, subscriptionB, subscriptionC, subscriptionD, tenantA);
Expand Down

0 comments on commit 1137072

Please sign in to comment.