Skip to content

Commit 94c9283

Browse files
committed
Fixed Resources tests to use Az.Monitor.psd1.
1 parent 6ead587 commit 94c9283

File tree

1 file changed

+24
-21
lines changed

1 file changed

+24
-21
lines changed

src/ResourceManager/Resources/Commands.Resources.Test/ScenarioTests/ResourcesController.cs

Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434
using Microsoft.Rest;
3535
using Microsoft.Rest.ClientRuntime.Azure.TestFramework;
3636
using Microsoft.WindowsAzure.Commands.ScenarioTest;
37-
using ManagedGroups = Microsoft.Azure.Management.ManagementGroups;
3837
using TestEnvironmentFactory = Microsoft.Rest.ClientRuntime.Azure.TestFramework.TestEnvironmentFactory;
3938

4039
namespace Microsoft.Azure.Commands.Resources.Test.ScenarioTests
@@ -56,7 +55,7 @@ public sealed class ResourcesController
5655

5756
public AuthorizationManagementClient AuthorizationManagementClient { get; private set; }
5857

59-
public ManagedGroups.ManagementGroupsAPIClient ManagementGroupsApiClient { get; private set; }
58+
public ManagementGroupsAPIClient ManagementGroupsApiClient { get; private set; }
6059

6160
public string UserDomain { get; private set; }
6261

@@ -90,18 +89,22 @@ public void RunPsTestWorkflow(
9089
string mockName)
9190
{
9291
_helper.TracingInterceptor = interceptor;
93-
Dictionary<string, string> d = new Dictionary<string, string>();
94-
d.Add("Microsoft.Resources", null);
95-
d.Add("Microsoft.Features", null);
96-
d.Add("Microsoft.Authorization", null);
97-
d.Add("Providers.Test", null);
98-
var providersToIgnore = new Dictionary<string, string>();
99-
providersToIgnore.Add("Microsoft.Azure.Management.ResourceManager.ResourceManagementClient", "2016-07-01");
100-
providersToIgnore.Add("Microsoft.Azure.Management.Resources.ResourceManagementClient", "2016-02-01");
92+
var d = new Dictionary<string, string>
93+
{
94+
{"Microsoft.Resources", null},
95+
{"Microsoft.Features", null},
96+
{"Microsoft.Authorization", null},
97+
{"Providers.Test", null}
98+
};
99+
var providersToIgnore = new Dictionary<string, string>
100+
{
101+
{"Microsoft.Azure.Management.ResourceManager.ResourceManagementClient", "2016-07-01"},
102+
{"Microsoft.Azure.Management.Resources.ResourceManagementClient", "2016-02-01"}
103+
};
101104
HttpMockServer.Matcher = new ResourcesRecordMatcher(true, d, providersToIgnore);
102105
HttpMockServer.RecordsDirectory = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "SessionRecords");
103106

104-
using (MockContext context = MockContext.Start(callingClassType, mockName))
107+
using (var context = MockContext.Start(callingClassType, mockName))
105108
{
106109
_helper.SetupEnvironment(AzureModule.AzureResourceManager);
107110

@@ -115,7 +118,7 @@ public void RunPsTestWorkflow(
115118
"ScenarioTests\\" + callingClassName + ".ps1",
116119
_helper.RMProfileModule,
117120
_helper.RMResourceModule,
118-
_helper.RMInsightsModule);
121+
_helper.GetRMModulePath("AzureRM.Monitor.psd1"));
119122

120123
try
121124
{
@@ -195,29 +198,29 @@ private GraphRbacManagementClient GetGraphClient(MockContext context)
195198
return client;
196199
}
197200

198-
private AuthorizationManagementClient GetAuthorizationManagementClient(MockContext context)
201+
private static AuthorizationManagementClient GetAuthorizationManagementClient(MockContext context)
199202
{
200203
return context.GetServiceClient<AuthorizationManagementClient>(TestEnvironmentFactory.GetTestEnvironment());
201204
}
202205

203-
private FeatureClient GetFeatureClient(MockContext context)
206+
private static FeatureClient GetFeatureClient(MockContext context)
204207
{
205208
return context.GetServiceClient<FeatureClient>(TestEnvironmentFactory.GetTestEnvironment());
206209
}
207210

208-
private ResourceManagementClient GetResourceManagementClient(MockContext context)
211+
private static ResourceManagementClient GetResourceManagementClient(MockContext context)
209212
{
210213
return context.GetServiceClient<ResourceManagementClient>(TestEnvironmentFactory.GetTestEnvironment());
211214
}
212215

213-
private Internal.Subscriptions.SubscriptionClient GetSubscriptionClient(MockContext context)
216+
private static Internal.Subscriptions.SubscriptionClient GetSubscriptionClient(MockContext context)
214217
{
215218
return context.GetServiceClient<Internal.Subscriptions.SubscriptionClient>(TestEnvironmentFactory.GetTestEnvironment());
216219
}
217220

218-
private ManagedGroups.ManagementGroupsAPIClient GetManagementGroupsApiClient(MockContext context)
221+
private static ManagementGroupsAPIClient GetManagementGroupsApiClient(MockContext context)
219222
{
220-
return context.GetServiceClient<ManagedGroups.ManagementGroupsAPIClient>(TestEnvironmentFactory.GetTestEnvironment());
223+
return context.GetServiceClient<ManagementGroupsAPIClient>(TestEnvironmentFactory.GetTestEnvironment());
221224
}
222225

223226
/// <summary>
@@ -228,15 +231,15 @@ private class TestHttpClientHelperFactory : HttpClientHelperFactory
228231
/// <summary>
229232
/// The subscription cloud credentials.
230233
/// </summary>
231-
private readonly SubscriptionCloudCredentials credential;
234+
private readonly SubscriptionCloudCredentials _credential;
232235

233236
/// <summary>
234237
/// Initializes a new instance of the <see cref="TestHttpClientHelperFactory"/> class.
235238
/// </summary>
236239
/// <param name="credentials"></param>
237240
public TestHttpClientHelperFactory(SubscriptionCloudCredentials credentials)
238241
{
239-
credential = credentials;
242+
_credential = credentials;
240243
}
241244

242245
/// <summary>
@@ -246,7 +249,7 @@ public TestHttpClientHelperFactory(SubscriptionCloudCredentials credentials)
246249
/// <param name="headerValues">The headers.</param>
247250
public override HttpClientHelper CreateHttpClientHelper(SubscriptionCloudCredentials credentials, IEnumerable<ProductInfoHeaderValue> headerValues, Dictionary<string, string> cmdletHeaderValues)
248251
{
249-
return new HttpClientHelperImpl(credentials: credential, headerValues: headerValues, cmdletHeaderValues: cmdletHeaderValues);
252+
return new HttpClientHelperImpl(credentials: _credential, headerValues: headerValues, cmdletHeaderValues: cmdletHeaderValues);
250253
}
251254

252255
/// <summary>

0 commit comments

Comments
 (0)