@@ -662,6 +662,79 @@ public void GetAzureRmSubscriptionByNameMultiplePages()
662
662
Assert . Equal ( tenants [ 1 ] , resultSubscription . TenantId ) ;
663
663
}
664
664
665
+ [ Fact ]
666
+ [ Trait ( Category . AcceptanceType , Category . CheckIn ) ]
667
+ public void GetAzureRmSubscriptionManagedService ( )
668
+ {
669
+ var tenants = new List < string > { Guid . NewGuid ( ) . ToString ( ) , DefaultTenant . ToString ( ) } ;
670
+ var firstTenantSubscriptions = new List < string > { Guid . NewGuid ( ) . ToString ( ) ,
671
+ Guid . NewGuid ( ) . ToString ( ) ,
672
+ Guid . NewGuid ( ) . ToString ( ) ,
673
+ Guid . NewGuid ( ) . ToString ( ) } ;
674
+ var secondTenantSubscriptions = new List < string > { Guid . NewGuid ( ) . ToString ( ) ,
675
+ Guid . NewGuid ( ) . ToString ( ) ,
676
+ Guid . NewGuid ( ) . ToString ( ) ,
677
+ Guid . NewGuid ( ) . ToString ( ) } ;
678
+
679
+ var firstList = new List < string > { firstTenantSubscriptions [ 0 ] , firstTenantSubscriptions [ 1 ] } ;
680
+ var secondList = new List < string > { firstTenantSubscriptions [ 2 ] , firstTenantSubscriptions [ 3 ] } ;
681
+
682
+ var thirdList = new List < string > { secondTenantSubscriptions [ 0 ] , secondTenantSubscriptions [ 1 ] } ;
683
+ var fourthList = new List < string > { secondTenantSubscriptions [ 2 ] , secondTenantSubscriptions [ 3 ] } ;
684
+
685
+ var client = SetupTestEnvironment ( tenants , firstList , secondList , thirdList , fourthList ) ;
686
+
687
+ // TEST WITH USER TYPE
688
+ var dataStore = new MemoryDataStore ( ) ;
689
+ AzureSession . Instance . DataStore = dataStore ;
690
+ var commandRuntimeMock = new MockCommandRuntime ( ) ;
691
+ AzureSession . Instance . AuthenticationFactory = new MockTokenAuthenticationFactory ( ) ;
692
+ var profile = new AzureRmProfile ( ) ;
693
+ profile . EnvironmentTable . Add ( "foo" , new AzureEnvironment ( AzureEnvironment . PublicEnvironments . Values . FirstOrDefault ( ) ) ) ;
694
+ profile . DefaultContext = Context ;
695
+ profile . DefaultContext . Account = new AzureAccount ( ) ;
696
+ profile . DefaultContext . Tenant . Id = DefaultTenant . ToString ( ) ;
697
+
698
+ profile . DefaultContext . Account . Type = "User" ;
699
+ var cmdlt = new GetAzureRMSubscriptionCommand ( ) ;
700
+ // Setup
701
+ cmdlt . DefaultProfile = profile ;
702
+ cmdlt . CommandRuntime = commandRuntimeMock ;
703
+ Assert . Null ( cmdlt . TenantId ) ;
704
+ // Act
705
+ cmdlt . InvokeBeginProcessing ( ) ;
706
+ cmdlt . ExecuteCmdlet ( ) ;
707
+ cmdlt . InvokeEndProcessing ( ) ;
708
+ Assert . Null ( cmdlt . TenantId ) ;
709
+ Assert . True ( commandRuntimeMock . OutputPipeline . Count == 8 ) ;
710
+
711
+ // TEST WITH MANAGEDSERVICE
712
+ client = SetupTestEnvironment ( tenants , firstList , secondList , thirdList , fourthList ) ;
713
+
714
+ dataStore = new MemoryDataStore ( ) ;
715
+ AzureSession . Instance . DataStore = dataStore ;
716
+ commandRuntimeMock = new MockCommandRuntime ( ) ;
717
+ AzureSession . Instance . AuthenticationFactory = new MockTokenAuthenticationFactory ( ) ;
718
+ profile = new AzureRmProfile ( ) ;
719
+ profile . EnvironmentTable . Add ( "foo" , new AzureEnvironment ( AzureEnvironment . PublicEnvironments . Values . FirstOrDefault ( ) ) ) ;
720
+ profile . DefaultContext = Context ;
721
+ profile . DefaultContext . Account = new AzureAccount ( ) ;
722
+ profile . DefaultContext . Tenant . Id = DefaultTenant . ToString ( ) ;
723
+
724
+ profile . DefaultContext . Account . Type = "ManagedService" ;
725
+ cmdlt = new GetAzureRMSubscriptionCommand ( ) ;
726
+ // Setup
727
+ cmdlt . DefaultProfile = profile ;
728
+ cmdlt . CommandRuntime = commandRuntimeMock ;
729
+ Assert . Null ( cmdlt . TenantId ) ;
730
+ // Act
731
+ cmdlt . InvokeBeginProcessing ( ) ;
732
+ cmdlt . ExecuteCmdlet ( ) ;
733
+ cmdlt . InvokeEndProcessing ( ) ;
734
+ Assert . NotNull ( cmdlt . TenantId ) ;
735
+ Assert . True ( commandRuntimeMock . OutputPipeline . Count == 4 ) ;
736
+ }
737
+
665
738
#if NETSTANDARD
666
739
[ Fact ( Skip = "ConcurrentDictionary is not marked as Serializable" ) ]
667
740
[ Trait ( Category . RunType , Category . DesktopOnly ) ]
0 commit comments