Skip to content

Commit 0d890a4

Browse files
committed
Removed long lines, scenario test context helper function, shared account
1 parent 0c59536 commit 0d890a4

File tree

51 files changed

+566
-398
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+566
-398
lines changed

src/ResourceManager/AzureBatch/Commands.Batch.Test/Certificates/GetBatchCertificateCommandTests.cs

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,10 @@ public void GetBatchCertificateTest()
5959

6060
// Build a Certificate instead of querying the service on a Get Certificate call
6161
AzureOperationResponse<ProxyModels.Certificate, ProxyModels.CertificateGetHeaders> response = BatchTestHelpers.CreateCertificateGetResponse(cmdlet.Thumbprint);
62-
RequestInterceptor interceptor = BatchTestHelpers.CreateFakeServiceResponseInterceptor<ProxyModels.CertificateGetOptions, AzureOperationResponse<ProxyModels.Certificate, ProxyModels.CertificateGetHeaders>>(response);
62+
RequestInterceptor interceptor = BatchTestHelpers.CreateFakeServiceResponseInterceptor<
63+
ProxyModels.CertificateGetOptions,
64+
AzureOperationResponse<ProxyModels.Certificate, ProxyModels.CertificateGetHeaders>>(response);
65+
6366
cmdlet.AdditionalBehaviors = new List<BatchClientBehavior>() { interceptor };
6467

6568
// Setup the cmdlet to write pipeline output to a list that can be examined later
@@ -88,12 +91,14 @@ public void GetBatchCertificateODataTest()
8891

8992
// Fetch the OData clauses off the request. The OData clauses are applied after user provided RequestInterceptors, so a ResponseInterceptor is used.
9093
AzureOperationResponse<ProxyModels.Certificate, ProxyModels.CertificateGetHeaders> getResponse = BatchTestHelpers.CreateCertificateGetResponse(cmdlet.Thumbprint);
91-
RequestInterceptor requestInterceptor = BatchTestHelpers.CreateFakeServiceResponseInterceptor<ProxyModels.CertificateGetOptions, AzureOperationResponse<ProxyModels.Certificate, ProxyModels.CertificateGetHeaders>>(getResponse);
94+
RequestInterceptor requestInterceptor = BatchTestHelpers.CreateFakeServiceResponseInterceptor<
95+
ProxyModels.CertificateGetOptions,
96+
AzureOperationResponse<ProxyModels.Certificate, ProxyModels.CertificateGetHeaders>>(getResponse);
9297
ResponseInterceptor responseInterceptor = new ResponseInterceptor((response, request) =>
9398
{
94-
ProxyModels.CertificateGetOptions certOptions = (ProxyModels.CertificateGetOptions) request.Options;
99+
ProxyModels.CertificateGetOptions certOptions = (ProxyModels.CertificateGetOptions)request.Options;
95100
requestSelect = certOptions.Select;
96-
101+
97102
return Task.FromResult(response);
98103
});
99104
cmdlet.AdditionalBehaviors = new List<BatchClientBehavior>() { requestInterceptor, responseInterceptor };
@@ -130,7 +135,7 @@ public void ListBatchCertificatesODataTest()
130135

131136
RequestInterceptor requestInterceptor = BatchTestHelpers.CreateFakeServiceResponseInterceptor(responseToUse: response, requestAction: extractCertificateListAction);
132137

133-
cmdlet.AdditionalBehaviors = new List<BatchClientBehavior>() { requestInterceptor, };
138+
cmdlet.AdditionalBehaviors = new List<BatchClientBehavior>() { requestInterceptor };
134139

135140
cmdlet.ExecuteCmdlet();
136141

@@ -153,7 +158,10 @@ public void ListBatchCertificatesWithoutFiltersTest()
153158

154159
// Build some Certificates instead of querying the service on a List Certificates call
155160
AzureOperationResponse<IPage<ProxyModels.Certificate>, ProxyModels.CertificateListHeaders> response = BatchTestHelpers.CreateCertificateListResponse(thumbprintsOfConstructedCerts);
156-
RequestInterceptor interceptor = BatchTestHelpers.CreateFakeServiceResponseInterceptor<ProxyModels.CertificateListOptions, AzureOperationResponse<IPage<ProxyModels.Certificate>, ProxyModels.CertificateListHeaders>>(response);
161+
RequestInterceptor interceptor = BatchTestHelpers.CreateFakeServiceResponseInterceptor<
162+
ProxyModels.CertificateListOptions,
163+
AzureOperationResponse<IPage<ProxyModels.Certificate>, ProxyModels.CertificateListHeaders>>(response);
164+
157165
cmdlet.AdditionalBehaviors = new List<BatchClientBehavior>() { interceptor };
158166

159167
// Setup the cmdlet to write pipeline output to a list that can be examined later
@@ -195,7 +203,10 @@ public void ListCertificatesMaxCountTest()
195203

196204
// Build some Certificates instead of querying the service on a List Certificates call
197205
AzureOperationResponse<IPage<ProxyModels.Certificate>, ProxyModels.CertificateListHeaders> response = BatchTestHelpers.CreateCertificateListResponse(thumbprintsOfConstructedCerts);
198-
RequestInterceptor interceptor = BatchTestHelpers.CreateFakeServiceResponseInterceptor<ProxyModels.CertificateListOptions, AzureOperationResponse<IPage<ProxyModels.Certificate>, ProxyModels.CertificateListHeaders>>(response);
206+
RequestInterceptor interceptor = BatchTestHelpers.CreateFakeServiceResponseInterceptor<
207+
ProxyModels.CertificateListOptions,
208+
AzureOperationResponse<IPage<ProxyModels.Certificate>, ProxyModels.CertificateListHeaders>>(response);
209+
199210
cmdlet.AdditionalBehaviors = new List<BatchClientBehavior>() { interceptor };
200211

201212
// Setup the cmdlet to write pipeline output to a list that can be examined later

src/ResourceManager/AzureBatch/Commands.Batch.Test/Certificates/NewBatchCertificateCommandTests.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,11 @@ public void NewBatchCertificateParametersTest()
5858
cmdlet.FilePath = BatchTestHelpers.TestCertificateFileName1;
5959

6060
// Don't go to the service on an Add Certificate call
61-
RequestInterceptor interceptor = BatchTestHelpers.CreateFakeServiceResponseInterceptor<CertificateAddParameter, CertificateAddOptions, AzureOperationHeaderResponse<CertificateAddHeaders>>();
61+
RequestInterceptor interceptor = BatchTestHelpers.CreateFakeServiceResponseInterceptor<
62+
CertificateAddParameter,
63+
CertificateAddOptions,
64+
AzureOperationHeaderResponse<CertificateAddHeaders>>();
65+
6266
cmdlet.AdditionalBehaviors = new List<BatchClientBehavior>() { interceptor };
6367

6468
// Verify no exceptions when required parameters are set

src/ResourceManager/AzureBatch/Commands.Batch.Test/Certificates/StopBatchCertificateDeletionCommandTests.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,10 @@ public void StopCertificateDeletionParametersTest()
5959
cmdlet.Thumbprint = "123456789";
6060

6161
// Don't go to the service on a Certificate Cancel Deletion call
62-
RequestInterceptor interceptor = BatchTestHelpers.CreateFakeServiceResponseInterceptor<CertificateCancelDeletionOptions, AzureOperationHeaderResponse<CertificateCancelDeletionHeaders>>();
62+
RequestInterceptor interceptor = BatchTestHelpers.CreateFakeServiceResponseInterceptor<
63+
CertificateCancelDeletionOptions,
64+
AzureOperationHeaderResponse<CertificateCancelDeletionHeaders>>();
65+
6366
cmdlet.AdditionalBehaviors = new List<BatchClientBehavior>() { interceptor };
6467

6568
// Verify no exceptions when required parameter is set

src/ResourceManager/AzureBatch/Commands.Batch.Test/ComputeNodeUsers/NewBatchComputeNodeUserCommandTests.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,11 @@ public void NewBatchComputeNodeUserParametersTest()
5959
cmdlet.Password = "Password1234";
6060

6161
// Don't go to the service on an Add ComputeNodeUser call
62-
RequestInterceptor interceptor = BatchTestHelpers.CreateFakeServiceResponseInterceptor<ProxyModels.ComputeNodeUser, ProxyModels.ComputeNodeAddUserOptions, AzureOperationHeaderResponse<ProxyModels.ComputeNodeAddUserHeaders>>();
62+
RequestInterceptor interceptor = BatchTestHelpers.CreateFakeServiceResponseInterceptor<
63+
ProxyModels.ComputeNodeUser,
64+
ProxyModels.ComputeNodeAddUserOptions,
65+
AzureOperationHeaderResponse<ProxyModels.ComputeNodeAddUserHeaders>>();
66+
6367
cmdlet.AdditionalBehaviors = new List<BatchClientBehavior>() { interceptor };
6468

6569
// Verify no exceptions when required parameters are set

src/ResourceManager/AzureBatch/Commands.Batch.Test/ComputeNodeUsers/RemoveBatchComputeNodeUserCommandTests.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,10 @@ public void RemoveBatchComputeNodeUserParametersTest()
6262
cmdlet.Name = "testUser";
6363

6464
// Don't go to the service on a Delete ComputeNodeUser call
65-
RequestInterceptor interceptor = BatchTestHelpers.CreateFakeServiceResponseInterceptor<ComputeNodeDeleteUserOptions, AzureOperationHeaderResponse<ComputeNodeDeleteUserHeaders>>();
65+
RequestInterceptor interceptor = BatchTestHelpers.CreateFakeServiceResponseInterceptor<
66+
ComputeNodeDeleteUserOptions,
67+
AzureOperationHeaderResponse<ComputeNodeDeleteUserHeaders>>();
68+
6669
cmdlet.AdditionalBehaviors = new List<BatchClientBehavior>() { interceptor };
6770

6871
// Verify no exceptions when required parameters are set

src/ResourceManager/AzureBatch/Commands.Batch.Test/ComputeNodeUsers/SetBatchComputeNoderUserCommandTests.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,11 @@ public void SetBatchComputeNodeUserParametersTest()
6363
cmdlet.Name = "testUser";
6464

6565
// Don't go to the service on an Update ComputeNodeUser call
66-
RequestInterceptor interceptor = BatchTestHelpers.CreateFakeServiceResponseInterceptor<NodeUpdateUserParameter, ComputeNodeUpdateUserOptions, AzureOperationHeaderResponse<ComputeNodeUpdateUserHeaders>>();
66+
RequestInterceptor interceptor = BatchTestHelpers.CreateFakeServiceResponseInterceptor<
67+
NodeUpdateUserParameter,
68+
ComputeNodeUpdateUserOptions,
69+
AzureOperationHeaderResponse<ComputeNodeUpdateUserHeaders>>();
70+
6771
cmdlet.AdditionalBehaviors = new List<BatchClientBehavior>() { interceptor };
6872

6973
// Verify no exceptions when required parameters are set

src/ResourceManager/AzureBatch/Commands.Batch.Test/ComputeNodes/DisableBatchComputeNodeSchedulingCommandTests.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,10 @@ public void DisableComputeNodeSchedulingParametersTest()
6161
cmdlet.Id = "computeNode01";
6262

6363
// Don't go to the service on an Disable Compute Node Scheduling call
64-
RequestInterceptor interceptor = BatchTestHelpers.CreateFakeServiceResponseInterceptor<DisableComputeNodeSchedulingOption?, ComputeNodeDisableSchedulingOptions, AzureOperationHeaderResponse<ComputeNodeDisableSchedulingHeaders>>();
64+
RequestInterceptor interceptor = BatchTestHelpers.CreateFakeServiceResponseInterceptor<
65+
DisableComputeNodeSchedulingOption?,
66+
ComputeNodeDisableSchedulingOptions,
67+
AzureOperationHeaderResponse<ComputeNodeDisableSchedulingHeaders>>();
6568
cmdlet.AdditionalBehaviors = new List<BatchClientBehavior>() { interceptor };
6669

6770
// Verify no exceptions when required parameter is set

src/ResourceManager/AzureBatch/Commands.Batch.Test/ComputeNodes/EnableBatchComputeNodeSchedulingCommandTests.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,9 @@ public void EnableComputeNodeSchedulingParametersTest()
5858
cmdlet.Id = "computeNode01";
5959

6060
// Don't go to the service on an Enable Compute Node Scheduling call
61-
RequestInterceptor interceptor = BatchTestHelpers.CreateFakeServiceResponseInterceptor<ComputeNodeEnableSchedulingOptions, AzureOperationHeaderResponse<ComputeNodeEnableSchedulingHeaders>>();
61+
RequestInterceptor interceptor = BatchTestHelpers.CreateFakeServiceResponseInterceptor<
62+
ComputeNodeEnableSchedulingOptions,
63+
AzureOperationHeaderResponse<ComputeNodeEnableSchedulingHeaders>>();
6264
cmdlet.AdditionalBehaviors = new List<BatchClientBehavior>() { interceptor };
6365

6466
// Verify no exceptions when required parameter is set

src/ResourceManager/AzureBatch/Commands.Batch.Test/ComputeNodes/GetBatchComputeNodeCommandTests.cs

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,10 @@ public void GetBatchComputeNodeTest()
5959

6060
// Build a compute node instead of querying the service on a Get ComputeNode call
6161
AzureOperationResponse<ProxyModels.ComputeNode, ProxyModels.ComputeNodeGetHeaders> response = BatchTestHelpers.CreateComputeNodeGetResponse(cmdlet.Id);
62-
RequestInterceptor interceptor = BatchTestHelpers.CreateFakeServiceResponseInterceptor<ProxyModels.ComputeNodeGetOptions, AzureOperationResponse<ProxyModels.ComputeNode, ProxyModels.ComputeNodeGetHeaders>>(response);
62+
RequestInterceptor interceptor = BatchTestHelpers.CreateFakeServiceResponseInterceptor<
63+
ProxyModels.ComputeNodeGetOptions,
64+
AzureOperationResponse<ProxyModels.ComputeNode, ProxyModels.ComputeNodeGetHeaders>>(response);
65+
6366
cmdlet.AdditionalBehaviors = new List<BatchClientBehavior>() { interceptor };
6467

6568
// Setup the cmdlet to write pipeline output to a list that can be examined later
@@ -88,7 +91,10 @@ public void GetBatchComputeNodeODataTest()
8891

8992
// Fetch the OData clauses off the request. The OData clauses are applied after user provided RequestInterceptors, so a ResponseInterceptor is used.
9093
AzureOperationResponse<ProxyModels.ComputeNode, ProxyModels.ComputeNodeGetHeaders> getResponse = BatchTestHelpers.CreateComputeNodeGetResponse(cmdlet.Id);
91-
RequestInterceptor requestInterceptor = BatchTestHelpers.CreateFakeServiceResponseInterceptor<ProxyModels.ComputeNodeGetOptions, AzureOperationResponse<ProxyModels.ComputeNode, ProxyModels.ComputeNodeGetHeaders>>(getResponse);
94+
RequestInterceptor requestInterceptor = BatchTestHelpers.CreateFakeServiceResponseInterceptor<
95+
ProxyModels.ComputeNodeGetOptions,
96+
AzureOperationResponse<ProxyModels.ComputeNode, ProxyModels.ComputeNodeGetHeaders>>(getResponse);
97+
9298
ResponseInterceptor responseInterceptor = new ResponseInterceptor((response, request) =>
9399
{
94100
ProxyModels.ComputeNodeGetOptions computeNodeOptions = (ProxyModels.ComputeNodeGetOptions) request.Options;
@@ -118,7 +124,8 @@ public void ListBatchComputeNodesODataTest()
118124
string requestFilter = null;
119125
string requestSelect = null;
120126

121-
AzureOperationResponse<IPage<ProxyModels.ComputeNode>, ProxyModels.ComputeNodeListHeaders> response = BatchTestHelpers.CreateGenericAzureOperationListResponse<ProxyModels.ComputeNode, ProxyModels.ComputeNodeListHeaders>();
127+
AzureOperationResponse<IPage<ProxyModels.ComputeNode>, ProxyModels.ComputeNodeListHeaders> response =
128+
BatchTestHelpers.CreateGenericAzureOperationListResponse<ProxyModels.ComputeNode, ProxyModels.ComputeNodeListHeaders>();
122129

123130
Action<BatchRequest<ProxyModels.ComputeNodeListOptions, AzureOperationResponse<IPage<ProxyModels.ComputeNode>, ProxyModels.ComputeNodeListHeaders>>> listComputeNodeAction =
124131
(request) =>
@@ -153,8 +160,13 @@ public void ListBatchComputeNodesWithoutFiltersTest()
153160
string[] idsOfConstructedComputeNodes = new[] { "computeNode1", "computeNode2", "computeNode3" };
154161

155162
// Build some compute nodes instead of querying the service on a List ComputeNodes call
156-
AzureOperationResponse<IPage<ProxyModels.ComputeNode>, ProxyModels.ComputeNodeListHeaders> response = BatchTestHelpers.CreateComputeNodeListResponse(idsOfConstructedComputeNodes);
157-
RequestInterceptor interceptor = BatchTestHelpers.CreateFakeServiceResponseInterceptor<ProxyModels.ComputeNodeListOptions, AzureOperationResponse<IPage<ProxyModels.ComputeNode>, ProxyModels.ComputeNodeListHeaders>>(response);
163+
AzureOperationResponse<IPage<ProxyModels.ComputeNode>, ProxyModels.ComputeNodeListHeaders> response =
164+
BatchTestHelpers.CreateComputeNodeListResponse(idsOfConstructedComputeNodes);
165+
RequestInterceptor interceptor = BatchTestHelpers.CreateFakeServiceResponseInterceptor<
166+
ProxyModels.ComputeNodeListOptions,
167+
AzureOperationResponse<IPage<ProxyModels.ComputeNode>,
168+
ProxyModels.ComputeNodeListHeaders>>(response);
169+
158170
cmdlet.AdditionalBehaviors = new List<BatchClientBehavior>() { interceptor };
159171

160172
// Setup the cmdlet to write pipeline output to a list that can be examined later
@@ -196,7 +208,10 @@ public void ListComputeNodesMaxCountTest()
196208

197209
// Build some compute nodes instead of querying the service on a List ComputeNodes call
198210
AzureOperationResponse<IPage<ProxyModels.ComputeNode>, ProxyModels.ComputeNodeListHeaders> response = BatchTestHelpers.CreateComputeNodeListResponse(idsOfConstructedComputeNodes);
199-
RequestInterceptor interceptor = BatchTestHelpers.CreateFakeServiceResponseInterceptor<ProxyModels.ComputeNodeListOptions, AzureOperationResponse<IPage<ProxyModels.ComputeNode>, ProxyModels.ComputeNodeListHeaders>>(response);
211+
RequestInterceptor interceptor = BatchTestHelpers.CreateFakeServiceResponseInterceptor<
212+
ProxyModels.ComputeNodeListOptions,
213+
AzureOperationResponse<IPage<ProxyModels.ComputeNode>, ProxyModels.ComputeNodeListHeaders>>(response);
214+
200215
cmdlet.AdditionalBehaviors = new List<BatchClientBehavior>() { interceptor };
201216

202217
// Setup the cmdlet to write pipeline output to a list that can be examined later

src/ResourceManager/AzureBatch/Commands.Batch.Test/ComputeNodes/RemoveBatchComputeNodeCommandTests.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,11 @@ public void RemoveBatchComputeNodeParametersTest()
6767
cmdlet.Ids = new string[] { "computeNode1" };
6868

6969
// Don't go to the service on a Remove ComputeNode call
70-
RequestInterceptor interceptor = BatchTestHelpers.CreateFakeServiceResponseInterceptor<NodeRemoveParameter, PoolRemoveNodesOptions, AzureOperationHeaderResponse<PoolRemoveNodesHeaders>>();
70+
RequestInterceptor interceptor = BatchTestHelpers.CreateFakeServiceResponseInterceptor<
71+
NodeRemoveParameter,
72+
PoolRemoveNodesOptions,
73+
AzureOperationHeaderResponse<PoolRemoveNodesHeaders>>();
74+
7175
cmdlet.AdditionalBehaviors = new List<BatchClientBehavior>() { interceptor };
7276

7377
// Verify no exceptions when required parameter is set
@@ -106,7 +110,7 @@ public void RemoveComputeNodeRequestTest()
106110
requestResizeTimeout = request.Parameters.ResizeTimeout;
107111
requestComputeNodeIds = request.Parameters.NodeList;
108112

109-
AzureOperationHeaderResponse<PoolRemoveNodesHeaders> response = new AzureOperationHeaderResponse<PoolRemoveNodesHeaders>();
113+
var response = new AzureOperationHeaderResponse<PoolRemoveNodesHeaders>();
110114
Task<AzureOperationHeaderResponse<PoolRemoveNodesHeaders>> task = Task.FromResult(response);
111115
return task;
112116
};

src/ResourceManager/AzureBatch/Commands.Batch.Test/ComputeNodes/ResetBatchComputeNodeCommandTests.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,11 @@ public void ResetBatchComputeNodeParametersTest()
6363
cmdlet.Id = "computeNode1";
6464

6565
// Don't go to the service on a Reimage ComputeNode call
66-
RequestInterceptor interceptor = BatchTestHelpers.CreateFakeServiceResponseInterceptor<ComputeNodeReimageOption?, ComputeNodeReimageOptions, AzureOperationHeaderResponse<ComputeNodeReimageHeaders>>();
66+
RequestInterceptor interceptor = BatchTestHelpers.CreateFakeServiceResponseInterceptor<
67+
ComputeNodeReimageOption?,
68+
ComputeNodeReimageOptions,
69+
AzureOperationHeaderResponse<ComputeNodeReimageHeaders>>();
70+
6771
cmdlet.AdditionalBehaviors = new List<BatchClientBehavior>() { interceptor };
6872

6973
// Verify no exceptions when required parameter is set
@@ -93,7 +97,7 @@ public void ResetComputeNodeRequestTest()
9397
// Grab the reimage option from the outgoing request.
9498
requestReimageOption = request.Parameters;
9599

96-
AzureOperationHeaderResponse<ComputeNodeReimageHeaders> response = new AzureOperationHeaderResponse<ComputeNodeReimageHeaders>();
100+
var response = new AzureOperationHeaderResponse<ComputeNodeReimageHeaders>();
97101
Task<AzureOperationHeaderResponse<ComputeNodeReimageHeaders>> task = Task.FromResult(response);
98102
return task;
99103
};

0 commit comments

Comments
 (0)