File tree Expand file tree Collapse file tree 1 file changed +36
-0
lines changed
src/ResourceManager/Profile/Commands.Profile.Test Expand file tree Collapse file tree 1 file changed +36
-0
lines changed Original file line number Diff line number Diff line change @@ -71,6 +71,42 @@ public void GetAzureContext()
71
71
Assert . Equal ( "test" , context . Subscription . SubscriptionName ) ;
72
72
}
73
73
74
+ [ Fact ]
75
+ [ Trait ( Category . AcceptanceType , Category . CheckIn ) ]
76
+ public void GetAzureContextNoLogin ( )
77
+ {
78
+ var cmdlt = new GetAzureRMContextCommand ( ) ;
79
+
80
+ // Setup
81
+ cmdlt . CommandRuntime = commandRuntimeMock ;
82
+ var profile = AzureRmProfileProvider . Instance . Profile ;
83
+ AzureRmProfileProvider . Instance . Profile = new AzureRMProfile ( ) ;
84
+
85
+ try
86
+ {
87
+ // Act
88
+ cmdlt . InvokeBeginProcessing ( ) ;
89
+ cmdlt . ExecuteCmdlet ( ) ;
90
+ cmdlt . InvokeEndProcessing ( ) ;
91
+ }
92
+ catch
93
+ {
94
+
95
+ }
96
+ finally
97
+ {
98
+ AzureRmProfileProvider . Instance . Profile = profile ;
99
+ }
100
+
101
+ // Verify
102
+ Assert . True ( commandRuntimeMock . OutputPipeline . Count == 1 ) ;
103
+ var context = ( PSAzureContext ) commandRuntimeMock . OutputPipeline [ 0 ] ;
104
+ Assert . Null ( context ) ;
105
+ Assert . True ( commandRuntimeMock . ErrorStream . Count == 1 ) ;
106
+ var error = commandRuntimeMock . ErrorStream [ 0 ] ;
107
+ Assert . Equal ( "Run Login-AzureRmAccount to login." , error . Exception . Message ) ;
108
+ }
109
+
74
110
[ Fact ]
75
111
[ Trait ( Category . AcceptanceType , Category . CheckIn ) ]
76
112
public void SelectAzureContextWithNoSubscriptionAndTenant ( )
You can’t perform that action at this time.
0 commit comments