12
12
// limitations under the License.
13
13
// ----------------------------------------------------------------------------------
14
14
15
-
15
+ using Microsoft . VisualStudio . TestTools . UnitTesting ;
16
+ using Microsoft . WindowsAzure . Commands . ServiceManagement . Model ;
17
+ using Microsoft . WindowsAzure . Commands . ServiceManagement . PlatformImageRepository . Model ;
18
+ using Microsoft . WindowsAzure . Commands . ServiceManagement . Test . FunctionalTests . ConfigDataInfo ;
16
19
using System ;
17
20
using System . Collections . ObjectModel ;
18
21
using System . IO ;
19
22
using System . Reflection ;
20
23
using System . Threading ;
21
- using Microsoft . VisualStudio . TestTools . UnitTesting ;
22
- using Microsoft . WindowsAzure . Commands . ServiceManagement . Model ;
23
- using Microsoft . WindowsAzure . Commands . ServiceManagement . PlatformImageRepository . Model ;
24
- using Microsoft . WindowsAzure . Commands . ServiceManagement . Test . FunctionalTests . ConfigDataInfo ;
25
24
26
25
namespace Microsoft . WindowsAzure . Commands . ServiceManagement . Test . FunctionalTests
27
26
{
@@ -39,8 +38,8 @@ public class PIRTest : ServiceManagementTest
39
38
private const string location2 = "North Central US" ;
40
39
private const string location3 = "East US" ;
41
40
42
- private const string publisher = "publisher1" ;
43
- private const string normaluser = "normaluser2" ;
41
+ private static string publisher = "publisher1" ;
42
+ private static string normaluser = "normaluser2" ;
44
43
private const string normaluserSubId = "602258C5-52EC-46B3-A49A-7587A764AC84" ;
45
44
46
45
private const string storageNormalUser = "normalstorage" ;
@@ -52,6 +51,16 @@ public static void ClassInit(TestContext context)
52
51
{
53
52
Assert . Inconclusive ( "No Subscription is selected!" ) ;
54
53
}
54
+
55
+ if ( vmPowershellCmdlets . GetAzureSubscription ( publisher ) == null )
56
+ {
57
+ publisher = defaultAzureSubscription . SubscriptionName ;
58
+ }
59
+
60
+ if ( vmPowershellCmdlets . GetAzureSubscription ( normaluser ) == null )
61
+ {
62
+ normaluser = defaultAzureSubscription . SubscriptionName ;
63
+ }
55
64
}
56
65
57
66
[ TestInitialize ]
@@ -66,7 +75,7 @@ public void Initialize()
66
75
{
67
76
if ( string . IsNullOrEmpty ( localFile ) )
68
77
{
69
- CredentialHelper . CopyTestData ( testDataContainer , osVhdName , vhdContainerName , vhdName ) ;
78
+ vmPowershellCmdlets . AddAzureVhd ( new FileInfo ( osVhdName ) , vhdBlobLocation ) ;
70
79
}
71
80
else
72
81
{
@@ -101,6 +110,35 @@ public void Initialize()
101
110
testStartTime = DateTime . Now ;
102
111
}
103
112
113
+ [ TestCleanup ]
114
+ public virtual void CleanUp ( )
115
+ {
116
+ SwitchToPublisher ( ) ;
117
+ Console . WriteLine ( "Test {0}" , pass ? "passed" : "failed" ) ;
118
+
119
+ if ( ( cleanupIfPassed && pass ) || ( cleanupIfFailed && ! pass ) )
120
+ {
121
+ Console . WriteLine ( "Starting to clean up created VM and service." ) ;
122
+
123
+ try
124
+ {
125
+ vmPowershellCmdlets . RemoveAzureVMImage ( image , false ) ;
126
+ }
127
+ catch ( Exception e )
128
+ {
129
+ Console . WriteLine ( "Exception occurs during cleanup: {0}" , e . ToString ( ) ) ;
130
+ }
131
+
132
+ try
133
+ {
134
+ }
135
+ catch ( Exception e )
136
+ {
137
+ Console . WriteLine ( e . ToString ( ) ) ;
138
+ }
139
+ }
140
+ }
141
+
104
142
/// <summary>
105
143
/// This test covers Get-AzurePlatformVMImage, Set-AzurePlatformVMImage and Remove-AzurePlatformVMImage cmdlets
106
144
/// </summary>
@@ -301,35 +339,6 @@ public void AzurePlatformVMImageScenarioTest()
301
339
}
302
340
}
303
341
304
- [ TestCleanup ]
305
- public virtual void CleanUp ( )
306
- {
307
- SwitchToPublisher ( ) ;
308
- Console . WriteLine ( "Test {0}" , pass ? "passed" : "failed" ) ;
309
-
310
- if ( ( cleanupIfPassed && pass ) || ( cleanupIfFailed && ! pass ) )
311
- {
312
- Console . WriteLine ( "Starting to clean up created VM and service." ) ;
313
-
314
- try
315
- {
316
- vmPowershellCmdlets . RemoveAzureVMImage ( image , false ) ;
317
- }
318
- catch ( Exception e )
319
- {
320
- Console . WriteLine ( "Exception occurs during cleanup: {0}" , e . ToString ( ) ) ;
321
- }
322
-
323
- try
324
- {
325
- }
326
- catch ( Exception e )
327
- {
328
- Console . WriteLine ( e . ToString ( ) ) ;
329
- }
330
- }
331
- }
332
-
333
342
private void SwitchToPublisher ( )
334
343
{
335
344
vmPowershellCmdlets . SetDefaultAzureSubscription ( publisher ) ;
0 commit comments