12
12
// limitations under the License.
13
13
// ----------------------------------------------------------------------------------
14
14
15
- using System ;
16
- using System . Collections . Generic ;
17
- using System . Linq ;
18
- using Xunit ;
19
- using Microsoft . WindowsAzure . Commands . Common ;
20
15
using Microsoft . Azure . Common . Authentication . Models ;
21
16
using Microsoft . WindowsAzure . Commands . Common . Properties ;
22
17
using Microsoft . WindowsAzure . Commands . Common . Test . Mocks ;
23
18
using Microsoft . WindowsAzure . Commands . Test . Utilities . Common ;
24
19
using Microsoft . WindowsAzure . Commands . Test . Utilities . Websites ;
20
+ using Microsoft . WindowsAzure . Commands . Utilities . Common ;
25
21
using Microsoft . WindowsAzure . Commands . Utilities . Websites ;
26
22
using Microsoft . WindowsAzure . Commands . Utilities . Websites . Services . WebEntities ;
27
23
using Microsoft . WindowsAzure . Commands . Websites ;
28
24
using Moq ;
29
- using Microsoft . Azure . Common . Authentication ;
25
+ using System ;
26
+ using System . Collections . Generic ;
27
+ using System . Linq ;
28
+ using Xunit ;
30
29
31
30
namespace Microsoft . WindowsAzure . Commands . Test . Websites
32
31
{
@@ -50,18 +49,15 @@ public void ProcessGetWebsiteTest()
50
49
. Returns ( new List < Site > { new Site { Name = "website1" , WebSpace = "webspace1" } ,
51
50
new Site { Name = "website2" , WebSpace = "webspace2" } } ) ;
52
51
52
+ SetupProfile ( null ) ;
53
53
// Test
54
54
var getAzureWebsiteCommand = new GetAzureWebsiteCommand
55
55
{
56
56
CommandRuntime = new MockCommandRuntime ( ) ,
57
57
WebsitesClient = clientMock . Object
58
58
} ;
59
- currentProfile = new AzureProfile ( ) ;
60
- var subscription = new AzureSubscription { Id = new Guid ( base . subscriptionId ) } ;
61
- subscription . Properties [ AzureSubscription . Property . Default ] = "True" ;
62
- currentProfile . Subscriptions [ new Guid ( base . subscriptionId ) ] = subscription ;
63
59
64
- getAzureWebsiteCommand . ExecuteCmdlet ( ) ;
60
+ getAzureWebsiteCommand . ExecuteWithProcessing ( ) ;
65
61
Assert . Equal ( 1 , ( ( MockCommandRuntime ) getAzureWebsiteCommand . CommandRuntime ) . OutputPipeline . Count ) ;
66
62
var sites = ( IEnumerable < Site > ) ( ( MockCommandRuntime ) getAzureWebsiteCommand . CommandRuntime ) . OutputPipeline . FirstOrDefault ( ) ;
67
63
Assert . NotNull ( sites ) ;
@@ -92,6 +88,7 @@ public void GetWebsiteProcessShowTest()
92
88
PublishingUsername = "user1" }
93
89
) ;
94
90
91
+ SetupProfile ( null ) ;
95
92
96
93
// Test
97
94
var getAzureWebsiteCommand = new GetAzureWebsiteCommand
@@ -100,12 +97,8 @@ public void GetWebsiteProcessShowTest()
100
97
Name = "website1" ,
101
98
WebsitesClient = clientMock . Object
102
99
} ;
103
- currentProfile = new AzureProfile ( ) ;
104
- var subscription = new AzureSubscription { Id = new Guid ( subscriptionId ) } ;
105
- subscription . Properties [ AzureSubscription . Property . Default ] = "True" ;
106
- currentProfile . Subscriptions [ new Guid ( subscriptionId ) ] = subscription ;
107
100
108
- getAzureWebsiteCommand . ExecuteCmdlet ( ) ;
101
+ getAzureWebsiteCommand . ExecuteWithProcessing ( ) ;
109
102
Assert . Equal ( 1 , ( ( MockCommandRuntime ) getAzureWebsiteCommand . CommandRuntime ) . OutputPipeline . Count ) ;
110
103
111
104
SiteWithConfig website = ( ( MockCommandRuntime ) getAzureWebsiteCommand . CommandRuntime ) . OutputPipeline [ 0 ] as SiteWithConfig ;
@@ -114,19 +107,17 @@ public void GetWebsiteProcessShowTest()
114
107
Assert . Equal ( "website1" , website . Name ) ;
115
108
Assert . Equal ( "webspace1" , website . WebSpace ) ;
116
109
110
+ SetupProfile ( null ) ;
111
+
117
112
// Run with mixed casing
118
113
getAzureWebsiteCommand = new GetAzureWebsiteCommand
119
114
{
120
115
CommandRuntime = new MockCommandRuntime ( ) ,
121
116
Name = "WEBSiTe1" ,
122
117
WebsitesClient = clientMock . Object
123
118
} ;
124
- currentProfile = new AzureProfile ( ) ;
125
- subscription = new AzureSubscription { Id = new Guid ( subscriptionId ) } ;
126
- subscription . Properties [ AzureSubscription . Property . Default ] = "True" ;
127
- currentProfile . Subscriptions [ new Guid ( subscriptionId ) ] = subscription ;
128
119
129
- getAzureWebsiteCommand . ExecuteCmdlet ( ) ;
120
+ getAzureWebsiteCommand . ExecuteWithProcessing ( ) ;
130
121
Assert . Equal ( 1 , ( ( MockCommandRuntime ) getAzureWebsiteCommand . CommandRuntime ) . OutputPipeline . Count ) ;
131
122
132
123
website = ( ( MockCommandRuntime ) getAzureWebsiteCommand . CommandRuntime ) . OutputPipeline [ 0 ] as SiteWithConfig ;
@@ -145,7 +136,7 @@ public void ProcessGetWebsiteWithNullSubscription()
145
136
CommandRuntime = new MockCommandRuntime ( )
146
137
} ;
147
138
148
- Testing . AssertThrows < Exception > ( getAzureWebsiteCommand . ExecuteCmdlet , Resources . InvalidDefaultSubscription ) ;
139
+ Testing . AssertThrows < Exception > ( getAzureWebsiteCommand . ExecuteWithProcessing , Resources . InvalidDefaultSubscription ) ;
149
140
}
150
141
151
142
[ Fact ]
@@ -165,20 +156,18 @@ public void TestGetAzureWebsiteWithDiagnosticsSettings()
165
156
websitesClientMock . Setup ( c => c . GetWebsiteConfiguration ( It . IsAny < string > ( ) , slot ) )
166
157
. Returns ( new SiteConfig { PublishingUsername = "user1" } ) ;
167
158
159
+ SetupProfile ( null ) ;
160
+
168
161
var getAzureWebsiteCommand = new GetAzureWebsiteCommand
169
162
{
170
163
CommandRuntime = new MockCommandRuntime ( ) ,
171
164
Name = "website1" ,
172
165
WebsitesClient = websitesClientMock . Object ,
173
166
Slot = slot
174
167
} ;
175
- currentProfile = new AzureProfile ( ) ;
176
- var subscription = new AzureSubscription { Id = new Guid ( subscriptionId ) } ;
177
- subscription . Properties [ AzureSubscription . Property . Default ] = "True" ;
178
- currentProfile . Subscriptions [ new Guid ( subscriptionId ) ] = subscription ;
179
168
180
169
// Test
181
- getAzureWebsiteCommand . ExecuteCmdlet ( ) ;
170
+ getAzureWebsiteCommand . ExecuteWithProcessing ( ) ;
182
171
183
172
// Assert
184
173
Assert . Equal ( 1 , ( ( MockCommandRuntime ) getAzureWebsiteCommand . CommandRuntime ) . OutputPipeline . Count ) ;
@@ -209,6 +198,7 @@ public void GetsWebsiteSlot()
209
198
PublishingUsername = "user1"
210
199
} ) ;
211
200
201
+ SetupProfile ( null ) ;
212
202
// Test
213
203
var getAzureWebsiteCommand = new GetAzureWebsiteCommand
214
204
{
@@ -217,12 +207,8 @@ public void GetsWebsiteSlot()
217
207
WebsitesClient = clientMock . Object ,
218
208
Slot = slot
219
209
} ;
220
- currentProfile = new AzureProfile ( ) ;
221
- var subscription = new AzureSubscription { Id = new Guid ( subscriptionId ) } ;
222
- subscription . Properties [ AzureSubscription . Property . Default ] = "True" ;
223
- currentProfile . Subscriptions [ new Guid ( subscriptionId ) ] = subscription ;
224
210
225
- getAzureWebsiteCommand . ExecuteCmdlet ( ) ;
211
+ getAzureWebsiteCommand . ExecuteWithProcessing ( ) ;
226
212
Assert . Equal ( 1 , ( ( MockCommandRuntime ) getAzureWebsiteCommand . CommandRuntime ) . OutputPipeline . Count ) ;
227
213
228
214
var website = ( ( MockCommandRuntime ) getAzureWebsiteCommand . CommandRuntime ) . OutputPipeline [ 0 ] as SiteWithConfig ;
@@ -255,19 +241,17 @@ public void GetsSlots()
255
241
PublishingUsername = "user1"
256
242
} ) ;
257
243
244
+ SetupProfile ( null ) ;
245
+
258
246
// Test
259
247
var getAzureWebsiteCommand = new GetAzureWebsiteCommand
260
248
{
261
249
CommandRuntime = new MockCommandRuntime ( ) ,
262
250
WebsitesClient = clientMock . Object ,
263
251
Slot = slot
264
252
} ;
265
- currentProfile = new AzureProfile ( ) ;
266
- var subscription = new AzureSubscription { Id = new Guid ( subscriptionId ) } ;
267
- subscription . Properties [ AzureSubscription . Property . Default ] = "True" ;
268
- currentProfile . Subscriptions [ new Guid ( subscriptionId ) ] = subscription ;
269
253
270
- getAzureWebsiteCommand . ExecuteCmdlet ( ) ;
254
+ getAzureWebsiteCommand . ExecuteWithProcessing ( ) ;
271
255
IEnumerable < Site > sites = ( ( MockCommandRuntime ) getAzureWebsiteCommand . CommandRuntime ) . OutputPipeline [ 0 ] as IEnumerable < Site > ;
272
256
273
257
var website1 = sites . ElementAt ( 0 ) ;
0 commit comments