From 1137072e24cfde07673e3153db95c3cd44aa9263 Mon Sep 17 00:00:00 2001 From: msJinLei Date: Thu, 13 Oct 2022 21:21:36 +0800 Subject: [PATCH] Try to fix test cases --- src/Accounts/Accounts.Test/AzureRMProfileTests.cs | 2 ++ .../AzureRMProfileTestsForMultitenant.cs | 13 +++++++++++++ 2 files changed, 15 insertions(+) diff --git a/src/Accounts/Accounts.Test/AzureRMProfileTests.cs b/src/Accounts/Accounts.Test/AzureRMProfileTests.cs index e22801cf8fa1..36a4b73db218 100644 --- a/src/Accounts/Accounts.Test/AzureRMProfileTests.cs +++ b/src/Accounts/Accounts.Test/AzureRMProfileTests.cs @@ -63,6 +63,7 @@ private static RMProfileClient SetupTestEnvironment(List tenants, List>(subscriptionLists); + MockSubscriptionClientFactory.Reset(); var clientFactory = new MockSubscriptionClientFactory(tenants, subscriptionList); if (SubscripitonGetList != null) { @@ -141,6 +142,7 @@ private static AzureRmProfile SetupLogin(List tenants, params List>(subscriptionLists); + MockSubscriptionClientFactory.Reset(); var clientFactory = new MockSubscriptionClientFactory(tenants, subscriptionList); var mock = new MockClientFactory(null, new List { diff --git a/src/Accounts/Accounts.Test/AzureRMProfileTestsForMultitenant.cs b/src/Accounts/Accounts.Test/AzureRMProfileTestsForMultitenant.cs index bca17524e80f..4240a74407be 100644 --- a/src/Accounts/Accounts.Test/AzureRMProfileTestsForMultitenant.cs +++ b/src/Accounts/Accounts.Test/AzureRMProfileTestsForMultitenant.cs @@ -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 subscriptionList = GetFirstTenantSubscriptionsJson(tenantA, subscriptionA, subscriptionB, subscriptionC, tenantB); @@ -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); @@ -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); @@ -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 subscriptionListA = GetFirstTenantSubscriptionsJson(tenantA, subscriptionA, subscriptionB, subscriptionC, tenantB); @@ -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 subscriptionListA = GetFirstTenantSubscriptionsJson(tenantA, subscriptionA, subscriptionB, subscriptionC, tenantB); @@ -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 subscriptionListA = GetFirstTenantSubscriptionsJson(tenantA, subscriptionA, subscriptionB, subscriptionC, tenantB); @@ -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 subscriptionListA = GetFirstTenantSubscriptionsJson(tenantA, subscriptionA, subscriptionB, subscriptionC, tenantB); @@ -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 subscriptionList = GetFirstTenantSubscriptionsJson(tenantA, subscriptionA, subscriptionB, subscriptionC, tenantB); @@ -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); @@ -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); @@ -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 subscriptionListA = GetFirstTenantSubscriptionsJson(tenantA, subscriptionA, subscriptionB, subscriptionC, tenantB); @@ -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 subscriptionListA = GetFirstTenantSubscriptionsJson(tenantA, subscriptionA, subscriptionB, subscriptionC, tenantB); @@ -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 subscriptionListB = GetSecondTenantSubscriptionsJson(tenantB, subscriptionA, subscriptionB, subscriptionC, subscriptionD, tenantA);