@@ -109,7 +109,7 @@ public void ProfileMigratesAccountsAndDefaultSubscriptions()
109
109
Assert . Equal ( "https://api-dogfood.resources.windows-int.net" , client . Profile . Environments [ "Dogfood" ] . Endpoints [ AzureEnvironment . Endpoint . ResourceManager ] ) ;
110
110
Assert . Equal ( "https://management-preview.core.windows-int.net/" , client . Profile . Environments [ "Dogfood" ] . Endpoints [ AzureEnvironment . Endpoint . ServiceManagement ] ) ;
111
111
Assert . Equal ( ".database.windows.net" , client . Profile . Environments [ "Dogfood" ] . Endpoints [ AzureEnvironment . Endpoint . SqlDatabaseDnsSuffix ] ) ;
112
-
112
+
113
113
// Verify subscriptions
114
114
Assert . Equal ( 3 , client . Profile . Subscriptions . Count ) ;
115
115
Assert . False ( client . Profile . Subscriptions . ContainsKey ( new Guid ( "06E3F6FD-A3AA-439A-8FC4-1F5C41D2AD1E" ) ) ) ;
@@ -157,7 +157,7 @@ public void ProfileMigratesAccountsSkipsBadOnesAndBacksUpFile()
157
157
158
158
// Verify Environment migration
159
159
Assert . Equal ( 2 , client . Profile . Environments . Count ) ;
160
-
160
+
161
161
// Verify subscriptions
162
162
Assert . Equal ( 3 , client . Profile . Subscriptions . Count ) ;
163
163
Assert . True ( client . Profile . Subscriptions . ContainsKey ( new Guid ( "06E3F6FD-A3AA-439A-8FC4-1F5C41D2AD1F" ) ) ) ;
@@ -168,7 +168,7 @@ public void ProfileMigratesAccountsSkipsBadOnesAndBacksUpFile()
168
168
169
169
Assert . True ( client . Profile . Subscriptions . ContainsKey ( new Guid ( "d1e52cbc-b073-42e2-a0a0-c2f547118a6f" ) ) ) ;
170
170
Assert . Equal ( "Test Bad Cert" , client . Profile . Subscriptions [ new Guid ( "d1e52cbc-b073-42e2-a0a0-c2f547118a6f" ) ] . Name ) ;
171
-
171
+
172
172
// Verify accounts
173
173
Assert . Equal ( 2 , client . Profile . Accounts . Count ) ;
174
174
Assert . Equal ( "[email protected] " , client . Profile . Accounts [ "[email protected] " ] . Id ) ;
@@ -204,10 +204,10 @@ public void ProfileMigratesCorruptedFileAndCreatedBackup()
204
204
205
205
// Verify Environment migration
206
206
Assert . Equal ( 2 , client . Profile . Environments . Count ) ;
207
-
207
+
208
208
// Verify subscriptions
209
209
Assert . Equal ( 0 , client . Profile . Subscriptions . Count ) ;
210
-
210
+
211
211
// Verify accounts
212
212
Assert . Equal ( 0 , client . Profile . Accounts . Count ) ;
213
213
@@ -258,7 +258,7 @@ public void AddAzureAccountReturnsAccountWithAllSubscriptionsInRdfeMode()
258
258
ProfileClient . DataStore = dataStore ;
259
259
ProfileClient client = new ProfileClient ( ) ;
260
260
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 ) ;
262
262
263
263
Assert . Equal ( "test" , account . Id ) ;
264
264
Assert . Equal ( 3 , account . GetSubscriptions ( client . Profile ) . Count ) ;
@@ -603,7 +603,7 @@ public void SetAzureEnvironmentUpdatesEnvironment()
603
603
Assert . Equal ( 2 , client . Profile . Environments . Count ) ;
604
604
605
605
Assert . Throws < ArgumentNullException > ( ( ) => client . AddOrSetEnvironment ( null ) ) ;
606
-
606
+
607
607
var env2 = client . AddOrSetEnvironment ( azureEnvironment ) ;
608
608
Assert . Equal ( env2 . Name , azureEnvironment . Name ) ;
609
609
Assert . NotNull ( env2 . Endpoints [ AzureEnvironment . Endpoint . ServiceManagement ] ) ;
@@ -672,7 +672,7 @@ public void AddOrSetAzureSubscriptionChecksAndUpdates()
672
672
Assert . Equal ( subscription , azureSubscription1 ) ;
673
673
Assert . Throws < ArgumentNullException > ( ( ) => client . AddOrSetSubscription ( null ) ) ;
674
674
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" } ) ) ;
676
676
}
677
677
678
678
[ Fact ]
@@ -792,7 +792,7 @@ public void RefreshSubscriptionsWorksWithMooncake()
792
792
MockDataStore dataStore = new MockDataStore ( ) ;
793
793
ProfileClient . DataStore = dataStore ;
794
794
ProfileClient client = new ProfileClient ( ) ;
795
-
795
+
796
796
client . Profile . Accounts [ azureAccount . Id ] = azureAccount ;
797
797
798
798
var subscriptions = client . RefreshSubscriptions ( client . Profile . Environments [ EnvironmentName . AzureChinaCloud ] ) ;
@@ -878,7 +878,7 @@ public void SetAzureSubscriptionAsDefaultSetsDefaultAndCurrent()
878
878
Assert . Equal ( azureSubscription2 . Id , client . Profile . DefaultSubscription . Id ) ;
879
879
Assert . Equal ( azureSubscription2 . Id , AzureSession . CurrentContext . Subscription . Id ) ;
880
880
Assert . Throws < ArgumentException > ( ( ) => client . SetSubscriptionAsDefault ( "bad" , null ) ) ;
881
- Assert . Throws < ArgumentNullException > ( ( ) => client . SetSubscriptionAsDefault ( null , null ) ) ;
881
+ Assert . Throws < ArgumentException > ( ( ) => client . SetSubscriptionAsDefault ( null , null ) ) ;
882
882
}
883
883
884
884
[ Fact ]
@@ -917,7 +917,7 @@ public void SetAzureSubscriptionAsCurrentSetsCurrent()
917
917
918
918
Assert . Equal ( azureSubscription2 . Id , AzureSession . CurrentContext . Subscription . Id ) ;
919
919
Assert . Throws < ArgumentException > ( ( ) => client . SetSubscriptionAsCurrent ( "bad" , null ) ) ;
920
- Assert . Throws < ArgumentNullException > ( ( ) => client . SetSubscriptionAsCurrent ( null , null ) ) ;
920
+ Assert . Throws < ArgumentException > ( ( ) => client . SetSubscriptionAsCurrent ( null , null ) ) ;
921
921
}
922
922
923
923
[ Fact ]
@@ -1076,6 +1076,73 @@ public void ImportPublishSettingsUsesPassedInEnvironment()
1076
1076
Assert . Equal ( 7 , client . Profile . Subscriptions . Count ) ;
1077
1077
}
1078
1078
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
+
1079
1146
[ Fact ]
1080
1147
public void ImportPublishSettingsAddsSecondCertificate ( )
1081
1148
{
0 commit comments