Skip to content

Commit fb16075

Browse files
authored
Update recording mocking in HPCCache.Test.csproj (#12294)
1 parent 80e1ea3 commit fb16075

File tree

3 files changed

+26
-13
lines changed

3 files changed

+26
-13
lines changed

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ namespace Microsoft.Azure.Commands.HPCCache.Test.Fixtures
1717
using System;
1818
using System.Collections.Generic;
1919
using System.Linq;
20+
using Microsoft.Azure.Commands.HPCCache.Test.ScenarioTests;
2021
using Microsoft.Azure.Commands.HPCCache.Test.Utilities;
2122
using Microsoft.Azure.Management.Authorization;
2223
using Microsoft.Azure.Management.Authorization.Models;
@@ -26,6 +27,7 @@ namespace Microsoft.Azure.Commands.HPCCache.Test.Fixtures
2627
using Microsoft.Azure.Management.Network.Models;
2728
using Microsoft.Azure.Management.StorageCache;
2829
using Microsoft.Azure.Management.StorageCache.Models;
30+
using Microsoft.Azure.Test.HttpRecorder;
2931
using Microsoft.Rest.Azure;
3032
using Microsoft.Rest.ClientRuntime.Azure.TestFramework;
3133

@@ -59,6 +61,7 @@ public HpcCacheTestContext(
5961
[System.Runtime.CompilerServices.CallerMemberName]
6062
string methodName = ".ctor")
6163
{
64+
HttpMockServer.Matcher = HpcCacheController.GetRecordMatcher();
6265
this.mockContext = MockContext.Start(suiteObject, methodName);
6366
this.RegisterSubscriptionForResource("Microsoft.StorageCache");
6467
}
@@ -73,6 +76,7 @@ public HpcCacheTestContext(
7376
[System.Runtime.CompilerServices.CallerMemberName]
7477
string methodName = ".ctor")
7578
{
79+
HttpMockServer.Matcher = HpcCacheController.GetRecordMatcher();
7680
this.mockContext = MockContext.Start(type.Name, methodName);
7781
this.RegisterSubscriptionForResource("Microsoft.StorageCache");
7882
}

src/HPCCache/HPCCache.Test/HPCCache.Test.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
<ItemGroup>
1818
<PackageReference Include="Microsoft.Azure.Management.Authorization" Version="2.11.0-preview" />
1919
<PackageReference Include="Microsoft.Azure.Management.Storage" Version="14.5.0" />
20-
<PackageReference Include="Microsoft.Azure.Management.Network" Version="19.18.0-preview" />
20+
<PackageReference Include="Microsoft.Azure.Management.Network" Version="20.0.2-preview" />
2121
<PackageReference Include="WindowsAzure.Storage" Version="9.3.0" />
2222
</ItemGroup>
2323

src/HPCCache/HPCCache.Test/ScenarioTests/HPCCacheController.cs

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,26 @@ public void RunPsTest(XunitTracingInterceptor logger, params string[] scripts)
8585
logger.Information(string.Format("Test method finished: {0}.{1}", callingClassType, mockName));
8686
}
8787

88+
/// <summary>
89+
/// Gets storage management client.
90+
/// </summary>
91+
static public IRecordMatcher GetRecordMatcher()
92+
{
93+
var d = new Dictionary<string, string>
94+
{
95+
{ "Microsoft.Resources", null },
96+
{ "Microsoft.Features", null },
97+
{ "Microsoft.Authorization", null },
98+
{ "Microsoft.Network", null },
99+
};
100+
var providersToIgnore = new Dictionary<string, string>
101+
{
102+
{ "Microsoft.Azure.Management.Resources.ResourceManagementClient", "2016-02-01" },
103+
{ "Microsoft.Azure.Management.ResourceManager.ResourceManagementClient", "2017-05-10" },
104+
};
105+
return new PermissiveRecordMatcherWithApiExclusion(true, d, providersToIgnore);
106+
}
107+
88108
/// <summary>
89109
/// RunPsTestWorkflow.
90110
/// </summary>
@@ -103,18 +123,7 @@ protected void RunPsTestWorkflow(
103123
Action initialize = null)
104124
{
105125
this.helper.TracingInterceptor = logger;
106-
var d = new Dictionary<string, string>
107-
{
108-
{ "Microsoft.Resources", null },
109-
{ "Microsoft.Features", null },
110-
{ "Microsoft.Authorization", null },
111-
};
112-
var providersToIgnore = new Dictionary<string, string>
113-
{
114-
{ "Microsoft.Azure.Management.Resources.ResourceManagementClient", "2016-02-01" },
115-
{ "Microsoft.Azure.Management.ResourceManager.ResourceManagementClient", "2017-05-10" },
116-
};
117-
HttpMockServer.Matcher = new PermissiveRecordMatcherWithApiExclusion(true, d, providersToIgnore);
126+
HttpMockServer.Matcher = GetRecordMatcher();
118127
HttpMockServer.RecordsDirectory = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "SessionRecords");
119128
using (var context = new HpcCacheTestContext(callingClassType, mockName))
120129
{

0 commit comments

Comments
 (0)