Skip to content

Commit 6920200

Browse files
authored
Fix hpccache test playback issue. (#27270)
1 parent 859364f commit 6920200

File tree

1 file changed

+19
-6
lines changed

1 file changed

+19
-6
lines changed

src/HPCCache/HPCCache.Test/Fixtures/HpcCacheTestContext.cs

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,8 @@
1414

1515
namespace Microsoft.Azure.Commands.HPCCache.Test.Fixtures
1616
{
17-
using System;
18-
using System.Collections.Generic;
19-
using System.IO;
20-
using System.Linq;
21-
using System.Reflection;
22-
using Microsoft.Azure.Commands.HPCCache.Test.ScenarioTests;
17+
using Microsoft.Azure.Commands.Common.Authentication;
18+
using Microsoft.Azure.Commands.Common.Authentication.Models;
2319
using Microsoft.Azure.Commands.HPCCache.Test.Utilities;
2420
using Microsoft.Azure.Commands.TestFx.Recorder;
2521
using Microsoft.Azure.Management.Authorization;
@@ -33,6 +29,12 @@ namespace Microsoft.Azure.Commands.HPCCache.Test.Fixtures
3329
using Microsoft.Azure.Test.HttpRecorder;
3430
using Microsoft.Rest.Azure;
3531
using Microsoft.Rest.ClientRuntime.Azure.TestFramework;
32+
using System;
33+
using System.Collections.Generic;
34+
using System.IO;
35+
using System.Linq;
36+
using System.Reflection;
37+
using Constants = Utilities.Constants;
3638

3739
/// <summary>
3840
/// Defines the <see cref="HpcCacheTestContext" />.
@@ -64,6 +66,7 @@ public HpcCacheTestContext(
6466
[System.Runtime.CompilerServices.CallerMemberName]
6567
string methodName = ".ctor")
6668
{
69+
SetupAzureSession();
6770
BuildMockServer();
6871
this.mockContext = MockContext.Start(suiteObject, methodName);
6972
this.RegisterSubscriptionForResource("Microsoft.StorageCache");
@@ -79,11 +82,21 @@ public HpcCacheTestContext(
7982
[System.Runtime.CompilerServices.CallerMemberName]
8083
string methodName = ".ctor")
8184
{
85+
SetupAzureSession();
8286
BuildMockServer();
8387
this.mockContext = MockContext.Start(type.Name, methodName);
8488
this.RegisterSubscriptionForResource("Microsoft.StorageCache");
8589
}
8690

91+
private void SetupAzureSession()
92+
{
93+
AzureSessionInitializer.InitializeAzureSession();
94+
if (!(AzureSession.Instance?.DataStore is MemoryDataStore))
95+
{
96+
AzureSession.Instance.DataStore = new MemoryDataStore();
97+
}
98+
}
99+
87100
private void BuildMockServer()
88101
{
89102
var rpToIgnore = new Dictionary<string, string>

0 commit comments

Comments
 (0)