Skip to content

Commit 441d872

Browse files
author
Hovsep Mkrtchyan
committed
Fixed GalleryClient
1 parent e15a2dc commit 441d872

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

src/Common/Commands.Common.Test/Common/ProfileCmdltsTests.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -499,7 +499,7 @@ public void SelectDefaultAzureSubscriptionByNameUpdatesProfile()
499499
[Fact]
500500
public void SelectAzureSubscriptionByNameUpdatesProfile()
501501
{
502-
var profileClient = SetupDefaultProfile();
502+
SetupDefaultProfile();
503503
SelectAzureSubscriptionCommand cmdlt = new SelectAzureSubscriptionCommand();
504504

505505
// Setup
@@ -511,10 +511,10 @@ public void SelectAzureSubscriptionByNameUpdatesProfile()
511511
cmdlt.InvokeBeginProcessing();
512512
cmdlt.ExecuteCmdlet();
513513
cmdlt.InvokeEndProcessing();
514-
514+
515515
// Verify
516-
Assert.NotNull(profileClient.Profile.Context.Subscription);
517-
Assert.Equal(azureSubscription2.Id, profileClient.Profile.Context.Subscription.Id);
516+
Assert.NotNull(cmdlt.Profile.Context.Subscription);
517+
Assert.Equal(azureSubscription2.Id, cmdlt.Profile.Context.Subscription.Id);
518518
}
519519

520520
[Fact]

src/ResourceManager/Resources/Commands.Resources/Models.ResourceGroups/ResourcesBaseCmdlet.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,10 @@
1313
// ----------------------------------------------------------------------------------
1414

1515
using Microsoft.Azure.Commands.Resources.Models.Authorization;
16+
using Microsoft.Azure.Common.Authentication;
17+
using Microsoft.Azure.Common.Authentication.Models;
1618
using Microsoft.WindowsAzure.Commands.Utilities.Common;
19+
using System.IO;
1720

1821
namespace Microsoft.Azure.Commands.Resources.Models
1922
{
@@ -50,6 +53,11 @@ public GalleryTemplatesClient GalleryTemplatesClient
5053
{
5154
if (galleryTemplatesClient == null)
5255
{
56+
if(Profile == null)
57+
{
58+
Profile = new AzureProfile(Path.Combine(AzureSession.ProfileDirectory, AzureSession.ProfileFile));
59+
}
60+
5361
galleryTemplatesClient = new GalleryTemplatesClient(Profile.Context);
5462
}
5563
return galleryTemplatesClient;

0 commit comments

Comments
 (0)