From 2ac58a83937fa175dffc95b04e91c902d0702834 Mon Sep 17 00:00:00 2001 From: Rohit Mahamuni <44378577+romahamu@users.noreply.github.com> Date: Mon, 16 Mar 2020 10:57:45 -0400 Subject: [PATCH] Add storage account name constant (#35) * Add StorageAccountName constant. * Fix Context calling --- .../Fixtures/HpcCacheTestFixture.cs | 2 +- .../Fixtures/StorageAccountFixture.cs | 11 ++++++++++- .../HPCCache.Test/Utilities/Constants.cs | 5 +++++ .../HpcCacheTestEnvironmentUtilities.cs | 18 ++++++++++++++++++ 4 files changed, 34 insertions(+), 2 deletions(-) diff --git a/src/StorageCache/HPCCache.Test/Fixtures/HpcCacheTestFixture.cs b/src/StorageCache/HPCCache.Test/Fixtures/HpcCacheTestFixture.cs index 9ed4caa43f2e..b72a2a52b50d 100644 --- a/src/StorageCache/HPCCache.Test/Fixtures/HpcCacheTestFixture.cs +++ b/src/StorageCache/HPCCache.Test/Fixtures/HpcCacheTestFixture.cs @@ -66,7 +66,7 @@ public HpcCacheTestFixture() using (this.Context = new HpcCacheTestContext(callingClassType, mockName)) { - //this.Context = new HpcCacheTestContext(this); + this.Context = new HpcCacheTestContext(callingClassType, mockName); try { StorageCacheManagementClient storagecacheMgmtClient = this.Context.GetClient(); diff --git a/src/StorageCache/HPCCache.Test/Fixtures/StorageAccountFixture.cs b/src/StorageCache/HPCCache.Test/Fixtures/StorageAccountFixture.cs index 93f6bbb91a13..2cadb89d1abb 100644 --- a/src/StorageCache/HPCCache.Test/Fixtures/StorageAccountFixture.cs +++ b/src/StorageCache/HPCCache.Test/Fixtures/StorageAccountFixture.cs @@ -51,7 +51,7 @@ public StorageAccountFixture(HpcCacheTestFixture fixture) var mockName = sf.GetMethod().Name; using (this.Context = new HpcCacheTestContext(callingClassType, mockName)) { - // this.Context = new HpcCacheTestContext(this); + this.Context = new HpcCacheTestContext(callingClassType, mockName); this.StorageTarget = this.AddClfsStorageTarget(this.Context); Match clfsTargetMatch = ClfsTargetRegex.Match(this.StorageTarget.Clfs.Target); var storageAccountName = clfsTargetMatch.Groups["StorageAccountName"].Value; @@ -212,6 +212,15 @@ public StorageTarget AddClfsStorageTarget( storageTargetName = HpcCacheTestEnvironmentUtilities.StorageTargetName; } + if (string.IsNullOrEmpty(HpcCacheTestEnvironmentUtilities.StorageAccountName)) + { + storageAccountName = string.IsNullOrEmpty(suffix) ? storageAccountName : storageAccountName + suffix; + } + else + { + storageAccountName = HpcCacheTestEnvironmentUtilities.StorageAccountName; + } + var client = context.GetClient(); client.ApiVersion = Constants.DefaultAPIVersion; this.fixture.CacheHelper.StoragecacheManagementClient = client; diff --git a/src/StorageCache/HPCCache.Test/Utilities/Constants.cs b/src/StorageCache/HPCCache.Test/Utilities/Constants.cs index 1cd33af22d7e..2f5c87cb0775 100644 --- a/src/StorageCache/HPCCache.Test/Utilities/Constants.cs +++ b/src/StorageCache/HPCCache.Test/Utilities/Constants.cs @@ -65,5 +65,10 @@ public static class Constants /// Storage target name. /// // public static readonly string StorageTargetName = "msazure"; + + /// + /// Storage account name. + /// + public static readonly string StorageAccountName = "romahamu"; } } diff --git a/src/StorageCache/HPCCache.Test/Utilities/HpcCacheTestEnvironmentUtilities.cs b/src/StorageCache/HPCCache.Test/Utilities/HpcCacheTestEnvironmentUtilities.cs index 50433cccedce..8036eda83151 100644 --- a/src/StorageCache/HPCCache.Test/Utilities/HpcCacheTestEnvironmentUtilities.cs +++ b/src/StorageCache/HPCCache.Test/Utilities/HpcCacheTestEnvironmentUtilities.cs @@ -134,6 +134,24 @@ public static string StorageTargetName } } + /// + /// Gets storage account name + /// + public static string StorageAccountName + { + get + { + try + { + return GetValueFromEnvironment("StorageAccountName"); + } + catch (KeyNotFoundException) + { + return null; + } + } + } + /// /// Get subscription id. ///