18
18
using System . Diagnostics ;
19
19
using System . IO ;
20
20
using Microsoft . Azure . Management . Storage ;
21
+ using Microsoft . Azure . ServiceManagemenet . Common . Models ;
21
22
using Microsoft . Rest . ClientRuntime . Azure . TestFramework ;
22
23
using TestEnvironmentFactory = Microsoft . Rest . ClientRuntime . Azure . TestFramework . TestEnvironmentFactory ;
23
- #if ! NETSTANDARD
24
- using Microsoft . Azure . Test ;
25
- using TestBase = Microsoft . Azure . Test . TestBase ;
26
- #endif
27
24
28
25
namespace Microsoft . Azure . Commands . ApiManagement . Test . ScenarioTests
29
26
{
30
27
using Azure . Test . HttpRecorder ;
31
28
using WindowsAzure . Commands . ScenarioTest ;
32
29
using WindowsAzure . Commands . Test . Utilities . Common ;
33
- using ApiManagementClient = Management . ApiManagement . ApiManagementClient ;
34
30
using ResourceManagementClient = Management . Internal . Resources . ResourceManagementClient ;
35
31
using Xunit ;
36
32
@@ -40,21 +36,19 @@ public class ApiManagementTests : RMTestBase
40
36
41
37
public ApiManagementTests ( Xunit . Abstractions . ITestOutputHelper output )
42
38
{
43
- _helper = new EnvironmentSetupHelper ( ) ;
44
- _helper . TracingInterceptor = new ServiceManagemenet . Common . Models . XunitTracingInterceptor ( output ) ;
45
- ServiceManagemenet . Common . Models . XunitTracingInterceptor . AddToContext ( _helper . TracingInterceptor ) ;
39
+ _helper = new EnvironmentSetupHelper
40
+ {
41
+ TracingInterceptor = new XunitTracingInterceptor ( output )
42
+ } ;
43
+ XunitTracingInterceptor . AddToContext ( _helper . TracingInterceptor ) ;
46
44
}
47
45
48
46
protected void SetupManagementClients ( MockContext context )
49
47
{
50
- var apiManagementManagementClient = GetApiManagementManagementClient ( context ) ;
51
48
var resourceManagementClient = GetResourceManagementClient ( context ) ;
52
49
var armStorageManagementClient = GetArmStorageManagementClient ( context ) ;
53
50
54
- _helper . SetupManagementClients (
55
- apiManagementManagementClient ,
56
- resourceManagementClient ,
57
- armStorageManagementClient ) ;
51
+ _helper . SetupSomeOfManagementClients ( resourceManagementClient , armStorageManagementClient ) ;
58
52
}
59
53
60
54
protected StorageManagementClient GetArmStorageManagementClient ( MockContext context )
@@ -67,22 +61,7 @@ private ResourceManagementClient GetResourceManagementClient(MockContext context
67
61
return context . GetServiceClient < ResourceManagementClient > ( TestEnvironmentFactory . GetTestEnvironment ( ) ) ;
68
62
}
69
63
70
- private ApiManagementClient GetApiManagementManagementClient ( MockContext context )
71
- {
72
- #if NETSTANDARD
73
- //return context.GetServiceClient<ApiManagementClient>(TestEnvironmentFactory.GetTestEnvironment());
74
- return null ;
75
- #else
76
- return TestBase . GetServiceClient < ApiManagementClient > ( new CSMTestEnvironmentFactory ( ) ) ;
77
- #endif
78
- }
79
-
80
- #if NETSTANDARD
81
- [ Fact ( Skip = "Cannot construct ApiManagementClient using MockContext" ) ]
82
- [ Trait ( Category . RunType , Category . DesktopOnly ) ]
83
- #else
84
64
[ Fact ]
85
- #endif
86
65
[ Trait ( Category . AcceptanceType , Category . CheckIn ) ]
87
66
public void TestCrudApiManagement ( )
88
67
{
@@ -101,96 +80,56 @@ public void TestBackupRestoreApiManagement()
101
80
RunPowerShellTest ( "Test-BackupRestoreApiManagement" ) ;
102
81
}
103
82
104
- #if NETSTANDARD
105
- [ Fact ( Skip = "Cannot construct ApiManagementClient using MockContext" ) ]
106
- [ Trait ( Category . RunType , Category . DesktopOnly ) ]
107
- #else
108
83
[ Fact ]
109
- #endif
110
84
[ Trait ( Category . AcceptanceType , Category . CheckIn ) ]
111
85
public void TestSetApiManagementDeploymentExternalVN ( )
112
86
{
113
87
RunPowerShellTest ( "Test-SetApiManagementDeploymentExternalVirtualNetwork" ) ;
114
88
}
115
89
116
- #if NETSTANDARD
117
- [ Fact ( Skip = "Cannot construct ApiManagementClient using MockContext" ) ]
118
- [ Trait ( Category . RunType , Category . DesktopOnly ) ]
119
- #else
120
90
[ Fact ]
121
- #endif
122
91
[ Trait ( Category . AcceptanceType , Category . CheckIn ) ]
123
92
public void TestSetApiManagementDeploymentInternalVN ( )
124
93
{
125
94
RunPowerShellTest ( "Test-SetApiManagementDeploymentInternalVirtualNetwork" ) ;
126
95
}
127
96
128
- #if NETSTANDARD
129
- [ Fact ( Skip = "Cannot construct ApiManagementClient using MockContext" ) ]
130
- [ Trait ( Category . RunType , Category . DesktopOnly ) ]
131
- #else
132
97
[ Fact ]
133
- #endif
134
98
[ Trait ( Category . AcceptanceType , Category . CheckIn ) ]
135
99
public void TestUpdateApiManagementDeployment ( )
136
100
{
137
101
RunPowerShellTest ( "Test-UpdateApiManagementDeployment" ) ;
138
102
}
139
103
140
- #if NETSTANDARD
141
- [ Fact ( Skip = "Cannot construct ApiManagementClient using MockContext" ) ]
142
- [ Trait ( Category . RunType , Category . DesktopOnly ) ]
143
- #else
144
104
[ Fact ]
145
- #endif
146
105
[ Trait ( Category . AcceptanceType , Category . CheckIn ) ]
147
106
public void TestUpdateDeploymentComplex ( )
148
107
{
149
108
RunPowerShellTest ( "Test-UpdateApiManagementDeploymentWithHelpersAndPipeline" ) ;
150
109
}
151
110
152
- #if NETSTANDARD
153
- [ Fact ( Skip = "Cannot construct ApiManagementClient using MockContext" ) ]
154
- [ Trait ( Category . RunType , Category . DesktopOnly ) ]
155
- #else
156
111
[ Fact ]
157
- #endif
158
112
[ Trait ( Category . AcceptanceType , Category . CheckIn ) ]
159
113
public void TestImportApiManagementHostnameCertificate ( )
160
114
{
161
115
RunPowerShellTest ( "Test-ImportApiManagementHostnameCertificate" ) ;
162
116
}
163
117
164
- #if NETSTANDARD
165
- [ Fact ( Skip = "Cannot construct ApiManagementClient using MockContext" ) ]
166
- [ Trait ( Category . RunType , Category . DesktopOnly ) ]
167
- #else
168
118
[ Fact ]
169
- #endif
170
119
[ Trait ( Category . AcceptanceType , Category . CheckIn ) ]
171
120
public void TestSetApiManagementHostnames ( )
172
121
{
173
122
RunPowerShellTest ( "Test-SetApiManagementHostnames" ) ;
174
123
}
175
124
176
- #if NETSTANDARD
177
- [ Fact ( Skip = "Cannot construct ApiManagementClient using MockContext" ) ]
178
- [ Trait ( Category . RunType , Category . DesktopOnly ) ]
179
- #else
180
125
[ Fact ]
181
- #endif
182
126
[ Trait ( Category . AcceptanceType , Category . CheckIn ) ]
183
127
public void TestCrudApiManagementWithExternalVpn ( )
184
128
{
185
129
RunPowerShellTest ( "Test-CrudApiManagementWithExternalVpn" ) ;
186
130
}
187
131
188
- #if NETSTANDARD
189
- [ Fact ( Skip = "Cannot construct ApiManagementClient using MockContext" ) ]
190
- [ Trait ( Category . RunType , Category . DesktopOnly ) ]
191
- #else
192
132
[ Fact ]
193
- #endif
194
133
[ Trait ( Category . AcceptanceType , Category . CheckIn ) ]
195
134
public void TestCrudApiManagementWithAdditionalRegions ( )
196
135
{
@@ -203,12 +142,16 @@ private void RunPowerShellTest(params string[] scripts)
203
142
var callingClassType = sf . GetMethod ( ) . ReflectedType ? . ToString ( ) ;
204
143
var mockName = sf . GetMethod ( ) . Name ;
205
144
206
- Dictionary < string , string > d = new Dictionary < string , string > ( ) ;
207
- d . Add ( "Microsoft.Resources" , null ) ;
208
- d . Add ( "Microsoft.Features" , null ) ;
209
- d . Add ( "Microsoft.Authorization" , null ) ;
210
- var providersToIgnore = new Dictionary < string , string > ( ) ;
211
- providersToIgnore . Add ( "Microsoft.Azure.Management.Resources.ResourceManagementClient" , "2016-02-01" ) ;
145
+ Dictionary < string , string > d = new Dictionary < string , string >
146
+ {
147
+ { "Microsoft.Resources" , null } ,
148
+ { "Microsoft.Features" , null } ,
149
+ { "Microsoft.Authorization" , null }
150
+ } ;
151
+ var providersToIgnore = new Dictionary < string , string >
152
+ {
153
+ { "Microsoft.Azure.Management.Resources.ResourceManagementClient" , "2016-02-01" }
154
+ } ;
212
155
HttpMockServer . Matcher = new PermissiveRecordMatcherWithApiExclusion ( true , d , providersToIgnore ) ;
213
156
HttpMockServer . RecordsDirectory = Path . Combine ( AppDomain . CurrentDomain . BaseDirectory , "SessionRecords" ) ;
214
157
0 commit comments