@@ -109,7 +109,7 @@ public void ProfileMigratesAccountsAndDefaultSubscriptions()
109109 Assert . Equal ( "https://api-dogfood.resources.windows-int.net" , client . Profile . Environments [ "Dogfood" ] . Endpoints [ AzureEnvironment . Endpoint . ResourceManager ] ) ;
110110 Assert . Equal ( "https://management-preview.core.windows-int.net/" , client . Profile . Environments [ "Dogfood" ] . Endpoints [ AzureEnvironment . Endpoint . ServiceManagement ] ) ;
111111 Assert . Equal ( ".database.windows.net" , client . Profile . Environments [ "Dogfood" ] . Endpoints [ AzureEnvironment . Endpoint . SqlDatabaseDnsSuffix ] ) ;
112-
112+
113113 // Verify subscriptions
114114 Assert . Equal ( 3 , client . Profile . Subscriptions . Count ) ;
115115 Assert . False ( client . Profile . Subscriptions . ContainsKey ( new Guid ( "06E3F6FD-A3AA-439A-8FC4-1F5C41D2AD1E" ) ) ) ;
@@ -157,7 +157,7 @@ public void ProfileMigratesAccountsSkipsBadOnesAndBacksUpFile()
157157
158158 // Verify Environment migration
159159 Assert . Equal ( 2 , client . Profile . Environments . Count ) ;
160-
160+
161161 // Verify subscriptions
162162 Assert . Equal ( 3 , client . Profile . Subscriptions . Count ) ;
163163 Assert . True ( client . Profile . Subscriptions . ContainsKey ( new Guid ( "06E3F6FD-A3AA-439A-8FC4-1F5C41D2AD1F" ) ) ) ;
@@ -168,7 +168,7 @@ public void ProfileMigratesAccountsSkipsBadOnesAndBacksUpFile()
168168
169169 Assert . True ( client . Profile . Subscriptions . ContainsKey ( new Guid ( "d1e52cbc-b073-42e2-a0a0-c2f547118a6f" ) ) ) ;
170170 Assert . Equal ( "Test Bad Cert" , client . Profile . Subscriptions [ new Guid ( "d1e52cbc-b073-42e2-a0a0-c2f547118a6f" ) ] . Name ) ;
171-
171+
172172 // Verify accounts
173173 Assert . Equal ( 2 , client . Profile . Accounts . Count ) ;
174174 Assert . Equal ( "[email protected] " , client . Profile . Accounts [ "[email protected] " ] . Id ) ; @@ -204,10 +204,10 @@ public void ProfileMigratesCorruptedFileAndCreatedBackup()
204204
205205 // Verify Environment migration
206206 Assert . Equal ( 2 , client . Profile . Environments . Count ) ;
207-
207+
208208 // Verify subscriptions
209209 Assert . Equal ( 0 , client . Profile . Subscriptions . Count ) ;
210-
210+
211211 // Verify accounts
212212 Assert . Equal ( 0 , client . Profile . Accounts . Count ) ;
213213
@@ -258,7 +258,7 @@ public void AddAzureAccountReturnsAccountWithAllSubscriptionsInRdfeMode()
258258 ProfileClient . DataStore = dataStore ;
259259 ProfileClient client = new ProfileClient ( ) ;
260260
261- var account = client . AddAccountAndLoadSubscriptions ( new AzureAccount { Id = "test" , Type = AzureAccount . AccountType . User } , AzureEnvironment . PublicEnvironments [ EnvironmentName . AzureCloud ] , null ) ;
261+ var account = client . AddAccountAndLoadSubscriptions ( new AzureAccount { Id = "test" , Type = AzureAccount . AccountType . User } , AzureEnvironment . PublicEnvironments [ EnvironmentName . AzureCloud ] , null ) ;
262262
263263 Assert . Equal ( "test" , account . Id ) ;
264264 Assert . Equal ( 3 , account . GetSubscriptions ( client . Profile ) . Count ) ;
@@ -603,7 +603,7 @@ public void SetAzureEnvironmentUpdatesEnvironment()
603603 Assert . Equal ( 2 , client . Profile . Environments . Count ) ;
604604
605605 Assert . Throws < ArgumentNullException > ( ( ) => client . AddOrSetEnvironment ( null ) ) ;
606-
606+
607607 var env2 = client . AddOrSetEnvironment ( azureEnvironment ) ;
608608 Assert . Equal ( env2 . Name , azureEnvironment . Name ) ;
609609 Assert . NotNull ( env2 . Endpoints [ AzureEnvironment . Endpoint . ServiceManagement ] ) ;
@@ -672,7 +672,7 @@ public void AddOrSetAzureSubscriptionChecksAndUpdates()
672672 Assert . Equal ( subscription , azureSubscription1 ) ;
673673 Assert . Throws < ArgumentNullException > ( ( ) => client . AddOrSetSubscription ( null ) ) ;
674674 Assert . Throws < ArgumentNullException > ( ( ) => client . AddOrSetSubscription (
675- new AzureSubscription { Id = new Guid ( ) , Environment = null , Name = "foo" } ) ) ;
675+ new AzureSubscription { Id = new Guid ( ) , Environment = null , Name = "foo" } ) ) ;
676676 }
677677
678678 [ Fact ]
@@ -792,7 +792,7 @@ public void RefreshSubscriptionsWorksWithMooncake()
792792 MockDataStore dataStore = new MockDataStore ( ) ;
793793 ProfileClient . DataStore = dataStore ;
794794 ProfileClient client = new ProfileClient ( ) ;
795-
795+
796796 client . Profile . Accounts [ azureAccount . Id ] = azureAccount ;
797797
798798 var subscriptions = client . RefreshSubscriptions ( client . Profile . Environments [ EnvironmentName . AzureChinaCloud ] ) ;
@@ -878,7 +878,7 @@ public void SetAzureSubscriptionAsDefaultSetsDefaultAndCurrent()
878878 Assert . Equal ( azureSubscription2 . Id , client . Profile . DefaultSubscription . Id ) ;
879879 Assert . Equal ( azureSubscription2 . Id , AzureSession . CurrentContext . Subscription . Id ) ;
880880 Assert . Throws < ArgumentException > ( ( ) => client . SetSubscriptionAsDefault ( "bad" , null ) ) ;
881- Assert . Throws < ArgumentNullException > ( ( ) => client . SetSubscriptionAsDefault ( null , null ) ) ;
881+ Assert . Throws < ArgumentException > ( ( ) => client . SetSubscriptionAsDefault ( null , null ) ) ;
882882 }
883883
884884 [ Fact ]
@@ -917,7 +917,7 @@ public void SetAzureSubscriptionAsCurrentSetsCurrent()
917917
918918 Assert . Equal ( azureSubscription2 . Id , AzureSession . CurrentContext . Subscription . Id ) ;
919919 Assert . Throws < ArgumentException > ( ( ) => client . SetSubscriptionAsCurrent ( "bad" , null ) ) ;
920- Assert . Throws < ArgumentNullException > ( ( ) => client . SetSubscriptionAsCurrent ( null , null ) ) ;
920+ Assert . Throws < ArgumentException > ( ( ) => client . SetSubscriptionAsCurrent ( null , null ) ) ;
921921 }
922922
923923 [ Fact ]
@@ -1076,6 +1076,73 @@ public void ImportPublishSettingsUsesPassedInEnvironment()
10761076 Assert . Equal ( 7 , client . Profile . Subscriptions . Count ) ;
10771077 }
10781078
1079+ [ Fact ]
1080+ public void SelectAzureSubscriptionByIdWorks ( )
1081+ {
1082+ MockDataStore dataStore = new MockDataStore ( ) ;
1083+ ProfileClient . DataStore = dataStore ;
1084+ ProfileClient client = new ProfileClient ( ) ;
1085+
1086+ var tempSubscriptions = new List < AzureSubscription >
1087+ {
1088+ new AzureSubscription
1089+ {
1090+ Id = new Guid ( "11111111-1383-4740-8A69-748C5B63ADBA" ) ,
1091+ Name = "Same Name Subscription" ,
1092+ Environment = azureEnvironment . Name ,
1093+ Account = azureAccount . Id ,
1094+ Properties = new Dictionary < AzureSubscription . Property , string >
1095+ {
1096+ { AzureSubscription . Property . Default , "True" }
1097+ }
1098+ } ,
1099+
1100+ new AzureSubscription
1101+ {
1102+ Id = new Guid ( "22222222-1383-4740-8A69-748C5B63ADBA" ) ,
1103+ Name = "Same Name Subscription" ,
1104+ Environment = azureEnvironment . Name ,
1105+ Account = azureAccount . Id ,
1106+ Properties = new Dictionary < AzureSubscription . Property , string > ( )
1107+ } ,
1108+
1109+ new AzureSubscription
1110+ {
1111+ Id = new Guid ( "33333333-1383-4740-8A69-748C5B63ADBA" ) ,
1112+ Name = "Same Name Subscription" ,
1113+ Environment = azureEnvironment . Name ,
1114+ Account = azureAccount . Id ,
1115+ Properties = new Dictionary < AzureSubscription . Property , string > ( )
1116+ }
1117+ } ;
1118+
1119+ client . Profile . Accounts [ azureAccount . Id ] = azureAccount ;
1120+ client . AddOrSetEnvironment ( azureEnvironment ) ;
1121+
1122+ foreach ( var s in tempSubscriptions )
1123+ {
1124+ client . AddOrSetSubscription ( s ) ;
1125+ }
1126+
1127+ client . SetSubscriptionAsCurrent ( tempSubscriptions [ 0 ] . Name , tempSubscriptions [ 0 ] . Account ) ;
1128+ client . Profile . Save ( ) ;
1129+
1130+ Assert . Equal ( tempSubscriptions [ 0 ] . Id , AzureSession . CurrentContext . Subscription . Id ) ;
1131+
1132+ var cmdlt = new SelectAzureSubscriptionCommand ( ) ;
1133+
1134+ cmdlt . CommandRuntime = new MockCommandRuntime ( ) ;
1135+ cmdlt . SubscriptionId = tempSubscriptions [ 2 ] . Id . ToString ( ) ;
1136+ cmdlt . SetParameterSet ( "SelectSubscriptionByIdParameterSet" ) ;
1137+
1138+ // Act
1139+ cmdlt . InvokeBeginProcessing ( ) ;
1140+ cmdlt . ExecuteCmdlet ( ) ;
1141+ cmdlt . InvokeEndProcessing ( ) ;
1142+
1143+ Assert . Equal ( tempSubscriptions [ 2 ] . Id , AzureSession . CurrentContext . Subscription . Id ) ;
1144+ }
1145+
10791146 [ Fact ]
10801147 public void ImportPublishSettingsAddsSecondCertificate ( )
10811148 {
0 commit comments