@@ -193,11 +193,11 @@ public void SetAzureSubscriptionAddsSubscriptionWithCertificate()
193
193
[ Fact ]
194
194
public void SetAzureSubscriptionDerivesEnvironmentFromEnvironmentParameterOnAdd ( )
195
195
{
196
- SetAzureSubscriptionCommand cmdlt = new SetAzureSubscriptionCommand ( ) ;
197
196
// Setup
198
197
ProfileClient client = new ProfileClient ( ) ;
199
198
client . AddOrSetEnvironment ( azureEnvironment ) ;
200
199
client . Profile . Save ( ) ;
200
+ SetAzureSubscriptionCommand cmdlt = new SetAzureSubscriptionCommand ( ) ;
201
201
202
202
cmdlt . CommandRuntime = commandRuntimeMock ;
203
203
cmdlt . SubscriptionId = Guid . NewGuid ( ) . ToString ( ) ;
@@ -242,13 +242,13 @@ public void SetAzureSubscriptionThrowsExceptionWithoutCertificateOnAdd()
242
242
[ Fact ]
243
243
public void SetAzureSubscriptionDerivesEnvironmentFromEnvironmentParameterOnSet ( )
244
244
{
245
- SetAzureSubscriptionCommand cmdlt = new SetAzureSubscriptionCommand ( ) ;
246
245
// Setup
247
246
ProfileClient client = new ProfileClient ( ) ;
248
247
client . AddOrSetAccount ( azureAccount ) ;
249
248
client . AddOrSetEnvironment ( azureEnvironment ) ;
250
249
client . AddOrSetSubscription ( azureSubscription1 ) ;
251
250
client . Profile . Save ( ) ;
251
+ SetAzureSubscriptionCommand cmdlt = new SetAzureSubscriptionCommand ( ) ;
252
252
253
253
cmdlt . CommandRuntime = commandRuntimeMock ;
254
254
cmdlt . SubscriptionId = azureSubscription1 . Id . ToString ( ) ;
@@ -270,13 +270,13 @@ public void SetAzureSubscriptionDerivesEnvironmentFromEnvironmentParameterOnSet(
270
270
[ Fact ]
271
271
public void SetAzureSubscriptionDerivesEnvironmentFromServiceEndpointParameterOnSet ( )
272
272
{
273
- SetAzureSubscriptionCommand cmdlt = new SetAzureSubscriptionCommand ( ) ;
274
273
// Setup
275
274
ProfileClient client = new ProfileClient ( ) ;
276
275
client . AddOrSetAccount ( azureAccount ) ;
277
276
client . AddOrSetEnvironment ( azureEnvironment ) ;
278
277
client . AddOrSetSubscription ( azureSubscription1 ) ;
279
278
client . Profile . Save ( ) ;
279
+ SetAzureSubscriptionCommand cmdlt = new SetAzureSubscriptionCommand ( ) ;
280
280
281
281
cmdlt . CommandRuntime = commandRuntimeMock ;
282
282
cmdlt . SubscriptionId = azureSubscription1 . Id . ToString ( ) ;
@@ -299,13 +299,13 @@ public void SetAzureSubscriptionDerivesEnvironmentFromServiceEndpointParameterOn
299
299
[ Fact ]
300
300
public void SetAzureSubscriptionDerivesEnvironmentFromResourcesEndpointParameterOnSet ( )
301
301
{
302
- SetAzureSubscriptionCommand cmdlt = new SetAzureSubscriptionCommand ( ) ;
303
302
// Setup
304
303
ProfileClient client = new ProfileClient ( ) ;
305
304
client . AddOrSetAccount ( azureAccount ) ;
306
305
client . AddOrSetEnvironment ( azureEnvironment ) ;
307
306
client . AddOrSetSubscription ( azureSubscription1 ) ;
308
307
client . Profile . Save ( ) ;
308
+ SetAzureSubscriptionCommand cmdlt = new SetAzureSubscriptionCommand ( ) ;
309
309
310
310
cmdlt . CommandRuntime = commandRuntimeMock ;
311
311
cmdlt . SubscriptionId = azureSubscription1 . Id . ToString ( ) ;
@@ -327,14 +327,15 @@ public void SetAzureSubscriptionDerivesEnvironmentFromResourcesEndpointParameter
327
327
[ Fact ]
328
328
public void SetAzureSubscriptionDerivesEnvironmentFromBothEndpointParameters ( )
329
329
{
330
- SetAzureSubscriptionCommand cmdlt = new SetAzureSubscriptionCommand ( ) ;
331
330
// Setup
332
331
ProfileClient client = new ProfileClient ( ) ;
333
332
client . AddOrSetAccount ( azureAccount ) ;
334
333
client . AddOrSetEnvironment ( azureEnvironment ) ;
335
334
client . AddOrSetSubscription ( azureSubscription1 ) ;
336
335
client . Profile . Save ( ) ;
337
336
337
+ SetAzureSubscriptionCommand cmdlt = new SetAzureSubscriptionCommand ( ) ;
338
+
338
339
cmdlt . CommandRuntime = commandRuntimeMock ;
339
340
cmdlt . SubscriptionId = azureSubscription1 . Id . ToString ( ) ;
340
341
cmdlt . CurrentStorageAccountName = "NewCloudStorage" ;
@@ -356,15 +357,15 @@ public void SetAzureSubscriptionDerivesEnvironmentFromBothEndpointParameters()
356
357
[ Fact ]
357
358
public void SetAzureSubscriptionUpdatesSubscriptionWithCertificate ( )
358
359
{
359
- SetAzureSubscriptionCommand cmdlt = new SetAzureSubscriptionCommand ( ) ;
360
-
361
360
// Setup
362
361
ProfileClient client = new ProfileClient ( ) ;
363
362
client . AddOrSetAccount ( azureAccount ) ;
364
363
client . AddOrSetEnvironment ( azureEnvironment ) ;
365
364
client . AddOrSetSubscription ( azureSubscription1 ) ;
366
365
client . Profile . Save ( ) ;
367
366
367
+ SetAzureSubscriptionCommand cmdlt = new SetAzureSubscriptionCommand ( ) ;
368
+
368
369
cmdlt . CommandRuntime = commandRuntimeMock ;
369
370
cmdlt . SubscriptionId = azureSubscription1 . Id . ToString ( ) ;
370
371
cmdlt . CurrentStorageAccountName = "NewCloudStorage" ;
@@ -475,8 +476,8 @@ public void ImportPublishSettingsFileOverwritesEnvironment()
475
476
[ Fact ]
476
477
public void SelectDefaultAzureSubscriptionByNameUpdatesProfile ( )
477
478
{
478
- SelectAzureSubscriptionCommand cmdlt = new SelectAzureSubscriptionCommand ( ) ;
479
479
var client = SetupDefaultProfile ( ) ;
480
+ SelectAzureSubscriptionCommand cmdlt = new SelectAzureSubscriptionCommand ( ) ;
480
481
481
482
// Setup
482
483
cmdlt . CommandRuntime = commandRuntimeMock ;
@@ -499,14 +500,14 @@ public void SelectDefaultAzureSubscriptionByNameUpdatesProfile()
499
500
[ Fact ]
500
501
public void SelectAzureSubscriptionByNameUpdatesProfile ( )
501
502
{
502
- SelectAzureSubscriptionCommand cmdlt = new SelectAzureSubscriptionCommand ( ) ;
503
503
SetupDefaultProfile ( ) ;
504
+ SelectAzureSubscriptionCommand cmdlt = new SelectAzureSubscriptionCommand ( ) ;
504
505
505
506
// Setup
506
507
cmdlt . CommandRuntime = commandRuntimeMock ;
507
508
cmdlt . SetParameterSet ( "SelectSubscriptionByNameParameterSet" ) ;
508
509
cmdlt . SubscriptionName = azureSubscription2 . Name ;
509
- Assert . Null ( AzureSession . Profile . CurrentContext . Subscription ) ;
510
+ Assert . NotEqual ( azureSubscription2 . Id , AzureSession . Profile . CurrentContext . Subscription . Id ) ;
510
511
511
512
// Act
512
513
cmdlt . InvokeBeginProcessing ( ) ;
@@ -521,14 +522,13 @@ public void SelectAzureSubscriptionByNameUpdatesProfile()
521
522
[ Fact ]
522
523
public void SelectAzureSubscriptionWithoutPassthroughDoesNotPrint ( )
523
524
{
524
- SelectAzureSubscriptionCommand cmdlt = new SelectAzureSubscriptionCommand ( ) ;
525
525
SetupDefaultProfile ( ) ;
526
+ SelectAzureSubscriptionCommand cmdlt = new SelectAzureSubscriptionCommand ( ) ;
526
527
527
528
// Setup
528
529
cmdlt . CommandRuntime = commandRuntimeMock ;
529
530
cmdlt . SetParameterSet ( "SelectSubscriptionByNameParameterSet" ) ;
530
531
cmdlt . SubscriptionName = azureSubscription2 . Name ;
531
- Assert . Null ( AzureSession . Profile . CurrentContext . Subscription ) ;
532
532
533
533
// Act
534
534
cmdlt . InvokeBeginProcessing ( ) ;
@@ -542,15 +542,14 @@ public void SelectAzureSubscriptionWithoutPassthroughDoesNotPrint()
542
542
[ Fact ]
543
543
public void SelectAzureSubscriptionWithPassthroughPrintsSubscription ( )
544
544
{
545
- SelectAzureSubscriptionCommand cmdlt = new SelectAzureSubscriptionCommand ( ) ;
546
545
SetupDefaultProfile ( ) ;
546
+ SelectAzureSubscriptionCommand cmdlt = new SelectAzureSubscriptionCommand ( ) ;
547
547
548
548
// Setup
549
549
cmdlt . CommandRuntime = commandRuntimeMock ;
550
550
cmdlt . SetParameterSet ( "SelectSubscriptionByNameParameterSet" ) ;
551
551
cmdlt . SubscriptionName = azureSubscription2 . Name ;
552
552
cmdlt . PassThru = new SwitchParameter ( true ) ;
553
- Assert . Null ( AzureSession . Profile . CurrentContext . Subscription ) ;
554
553
555
554
// Act
556
555
cmdlt . InvokeBeginProcessing ( ) ;
@@ -565,8 +564,8 @@ public void SelectAzureSubscriptionWithPassthroughPrintsSubscription()
565
564
[ Fact ]
566
565
public void SelectDefaultAzureSubscriptionByIdAndNoDefaultUpdatesProfile ( )
567
566
{
568
- SelectAzureSubscriptionCommand cmdlt = new SelectAzureSubscriptionCommand ( ) ;
569
567
var client = SetupDefaultProfile ( ) ;
568
+ SelectAzureSubscriptionCommand cmdlt = new SelectAzureSubscriptionCommand ( ) ;
570
569
571
570
// Setup
572
571
cmdlt . CommandRuntime = commandRuntimeMock ;
@@ -602,55 +601,17 @@ public void SelectDefaultAzureSubscriptionByIdAndNoDefaultUpdatesProfile()
602
601
Assert . Null ( client . Profile . DefaultSubscription ) ;
603
602
}
604
603
605
- [ Fact ]
606
- public void SelectAzureSubscriptionByIdAndNoCurrentUpdatesProfile ( )
607
- {
608
- SelectAzureSubscriptionCommand cmdlt = new SelectAzureSubscriptionCommand ( ) ;
609
- SetupDefaultProfile ( ) ;
610
-
611
- // Setup
612
- cmdlt . CommandRuntime = commandRuntimeMock ;
613
- cmdlt . SetParameterSet ( "SelectSubscriptionByIdParameterSet" ) ;
614
- cmdlt . SubscriptionId = azureSubscription2 . Id . ToString ( ) ;
615
- Assert . Null ( AzureSession . Profile . CurrentContext . Subscription ) ;
616
-
617
- // Act
618
- cmdlt . InvokeBeginProcessing ( ) ;
619
- cmdlt . ExecuteCmdlet ( ) ;
620
- cmdlt . InvokeEndProcessing ( ) ;
621
-
622
- // Verify
623
- Assert . NotNull ( AzureSession . Profile . CurrentContext . Subscription ) ;
624
- Assert . Equal ( azureSubscription2 . Id , AzureSession . Profile . CurrentContext . Subscription . Id ) ;
625
-
626
- cmdlt = new SelectAzureSubscriptionCommand ( ) ;
627
-
628
- // Setup
629
- cmdlt . CommandRuntime = commandRuntimeMock ;
630
- cmdlt . SetParameterSet ( "NoCurrentSubscriptionParameterSet" ) ;
631
- cmdlt . NoCurrent = new SwitchParameter ( true ) ;
632
-
633
- // Act
634
- cmdlt . InvokeBeginProcessing ( ) ;
635
- cmdlt . ExecuteCmdlet ( ) ;
636
- cmdlt . InvokeEndProcessing ( ) ;
637
-
638
- // Verify
639
- Assert . Null ( AzureSession . Profile . CurrentContext . Subscription ) ;
640
- }
641
-
642
604
[ Fact ]
643
605
public void SelectAzureSubscriptionByInvalidIdThrowsException ( )
644
606
{
645
- SelectAzureSubscriptionCommand cmdlt = new SelectAzureSubscriptionCommand ( ) ;
646
607
SetupDefaultProfile ( ) ;
608
+ SelectAzureSubscriptionCommand cmdlt = new SelectAzureSubscriptionCommand ( ) ;
647
609
648
610
// Setup
649
611
cmdlt . CommandRuntime = commandRuntimeMock ;
650
612
cmdlt . SetParameterSet ( "SelectSubscriptionByIdParameterSet" ) ;
651
613
string invalidGuid = Guid . NewGuid ( ) . ToString ( ) ;
652
614
cmdlt . SubscriptionId = invalidGuid ;
653
- Assert . Null ( AzureSession . Profile . CurrentContext . Subscription ) ;
654
615
655
616
// Act
656
617
cmdlt . InvokeBeginProcessing ( ) ;
@@ -661,7 +622,7 @@ public void SelectAzureSubscriptionByInvalidIdThrowsException()
661
622
}
662
623
catch ( ArgumentException ex )
663
624
{
664
- Assert . Contains ( string . Format ( Microsoft . WindowsAzure . Commands . Common . Properties . Resources . InvalidSubscriptionId , invalidGuid ) , ex . Message ) ;
625
+ Assert . Contains ( string . Format ( "The subscription id {0} doesn't exist. \r \n Parameter name: id" , invalidGuid ) , ex . Message ) ;
665
626
}
666
627
}
667
628
0 commit comments