Skip to content

Commit 6950060

Browse files
author
jasper-schneider
committed
Rename Batch interceptor helper methods
1 parent 03b34fd commit 6950060

39 files changed

+72
-71
lines changed

src/ResourceManager/AzureBatch/Commands.Batch.Test/BatchTestHelpers.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,8 @@ public static void AssertBatchAccountContextsAreEqual(BatchAccountContext contex
107107
/// <param name="requestAction">An action to perform on the request.</param>
108108
/// <typeparam name="TParameters">The type of the request parameters.</typeparam>
109109
/// <typeparam name="TResponse">The type of the expected response.</typeparam>
110-
public static RequestInterceptor CreateNoOpInterceptor<TParameters, TResponse>(TResponse responseToUse = null, Action<BatchRequest<TParameters, TResponse>> requestAction = null)
110+
public static RequestInterceptor CreateFakeServiceResponseInterceptor<TParameters, TResponse>(TResponse responseToUse = null,
111+
Action<BatchRequest<TParameters, TResponse>> requestAction = null)
111112
where TParameters : ProxyModels.BatchParameters
112113
where TResponse : ProxyModels.BatchOperationResponse, new()
113114
{
@@ -135,7 +136,7 @@ public static RequestInterceptor CreateNoOpInterceptor<TParameters, TResponse>(T
135136
/// The interceptor must handle both request types since it's possible for one OM node file method to perform both REST APIs.
136137
/// </summary>
137138
/// <param name="fileName">The name of the file to put in the response body.</param>
138-
public static RequestInterceptor CreateNoOpGetFileAndPropertiesInterceptor(string fileName)
139+
public static RequestInterceptor CreateFakGetFileAndPropertiesResponseInterceptor(string fileName)
139140
{
140141
RequestInterceptor interceptor = new RequestInterceptor((baseRequest) =>
141142
{

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public void NewBatchComputeNodeUserParametersTest()
6262
cmdlet.Password = "Password1234";
6363

6464
// Don't go to the service on an Add ComputeNodeUser call
65-
RequestInterceptor interceptor = BatchTestHelpers.CreateNoOpInterceptor<ComputeNodeAddUserParameters, ComputeNodeAddUserResponse>();
65+
RequestInterceptor interceptor = BatchTestHelpers.CreateFakeServiceResponseInterceptor<ComputeNodeAddUserParameters, ComputeNodeAddUserResponse>();
6666
cmdlet.AdditionalBehaviors = new List<BatchClientBehavior>() { interceptor };
6767

6868
// Verify no exceptions when required parameters are set

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public void RemoveBatchComputeNodeUserParametersTest()
6161
cmdlet.Name = "testUser";
6262

6363
// Don't go to the service on a Delete ComputeNodeUser call
64-
RequestInterceptor interceptor = BatchTestHelpers.CreateNoOpInterceptor<ComputeNodeDeleteUserParameters, ComputeNodeDeleteUserResponse>();
64+
RequestInterceptor interceptor = BatchTestHelpers.CreateFakeServiceResponseInterceptor<ComputeNodeDeleteUserParameters, ComputeNodeDeleteUserResponse>();
6565
cmdlet.AdditionalBehaviors = new List<BatchClientBehavior>() { interceptor };
6666

6767
// Verify no exceptions when required parameters are set

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public void SetBatchComputeNodeUserParametersTest()
6161
cmdlet.Name = "testUser";
6262

6363
// Don't go to the service on an Update ComputeNodeUser call
64-
RequestInterceptor interceptor = BatchTestHelpers.CreateNoOpInterceptor<ComputeNodeUpdateUserParameters, ComputeNodeUpdateUserResponse>();
64+
RequestInterceptor interceptor = BatchTestHelpers.CreateFakeServiceResponseInterceptor<ComputeNodeUpdateUserParameters, ComputeNodeUpdateUserResponse>();
6565
cmdlet.AdditionalBehaviors = new List<BatchClientBehavior>() { interceptor };
6666

6767
// Verify no exceptions when required parameters are set
@@ -90,7 +90,7 @@ public void SetBatchComputeNodeUserRequestTest()
9090
requestPassword = request.TypedParameters.Password;
9191
requestExpiryTime = request.TypedParameters.ExpiryTime.Value;
9292
};
93-
RequestInterceptor interceptor = BatchTestHelpers.CreateNoOpInterceptor(requestAction: extractUserUpdateParametersAction);
93+
RequestInterceptor interceptor = BatchTestHelpers.CreateFakeServiceResponseInterceptor(requestAction: extractUserUpdateParametersAction);
9494
cmdlet.AdditionalBehaviors = new List<BatchClientBehavior>() { interceptor };
9595

9696
cmdlet.ExecuteCmdlet();

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public void GetBatchComputeNodeTest()
5656

5757
// Build a compute node instead of querying the service on a Get ComputeNode call
5858
ComputeNodeGetResponse response = BatchTestHelpers.CreateComputeNodeGetResponse(cmdlet.Id);
59-
RequestInterceptor interceptor = BatchTestHelpers.CreateNoOpInterceptor<ComputeNodeGetParameters, ComputeNodeGetResponse>(response);
59+
RequestInterceptor interceptor = BatchTestHelpers.CreateFakeServiceResponseInterceptor<ComputeNodeGetParameters, ComputeNodeGetResponse>(response);
6060
cmdlet.AdditionalBehaviors = new List<BatchClientBehavior>() { interceptor };
6161

6262
// Setup the cmdlet to write pipeline output to a list that can be examined later
@@ -85,7 +85,7 @@ public void ListBatchComputeNodesByODataFilterTest()
8585

8686
// Build some compute nodes instead of querying the service on a List ComputeNodes call
8787
ComputeNodeListResponse response = BatchTestHelpers.CreateComputeNodeListResponse(idsOfConstructedComputeNodes);
88-
RequestInterceptor interceptor = BatchTestHelpers.CreateNoOpInterceptor<ComputeNodeListParameters, ComputeNodeListResponse>(response);
88+
RequestInterceptor interceptor = BatchTestHelpers.CreateFakeServiceResponseInterceptor<ComputeNodeListParameters, ComputeNodeListResponse>(response);
8989
cmdlet.AdditionalBehaviors = new List<BatchClientBehavior>() { interceptor };
9090

9191
// Setup the cmdlet to write pipeline output to a list that can be examined later
@@ -122,7 +122,7 @@ public void ListBatchComputeNodesWithoutFiltersTest()
122122

123123
// Build some compute nodes instead of querying the service on a List ComputeNodes call
124124
ComputeNodeListResponse response = BatchTestHelpers.CreateComputeNodeListResponse(idsOfConstructedComputeNodes);
125-
RequestInterceptor interceptor = BatchTestHelpers.CreateNoOpInterceptor<ComputeNodeListParameters, ComputeNodeListResponse>(response);
125+
RequestInterceptor interceptor = BatchTestHelpers.CreateFakeServiceResponseInterceptor<ComputeNodeListParameters, ComputeNodeListResponse>(response);
126126
cmdlet.AdditionalBehaviors = new List<BatchClientBehavior>() { interceptor };
127127

128128
// Setup the cmdlet to write pipeline output to a list that can be examined later
@@ -164,7 +164,7 @@ public void ListComputeNodesMaxCountTest()
164164

165165
// Build some compute nodes instead of querying the service on a List ComputeNodes call
166166
ComputeNodeListResponse response = BatchTestHelpers.CreateComputeNodeListResponse(idsOfConstructedComputeNodes);
167-
RequestInterceptor interceptor = BatchTestHelpers.CreateNoOpInterceptor<ComputeNodeListParameters, ComputeNodeListResponse>(response);
167+
RequestInterceptor interceptor = BatchTestHelpers.CreateFakeServiceResponseInterceptor<ComputeNodeListParameters, ComputeNodeListResponse>(response);
168168
cmdlet.AdditionalBehaviors = new List<BatchClientBehavior>() { interceptor };
169169

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

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public void ResetBatchComputeNodeParametersTest()
6161
cmdlet.Id = "computeNode1";
6262

6363
// Don't go to the service on a Reimage ComputeNode call
64-
RequestInterceptor interceptor = BatchTestHelpers.CreateNoOpInterceptor<ComputeNodeReimageParameters, ComputeNodeReimageResponse>();
64+
RequestInterceptor interceptor = BatchTestHelpers.CreateFakeServiceResponseInterceptor<ComputeNodeReimageParameters, ComputeNodeReimageResponse>();
6565
cmdlet.AdditionalBehaviors = new List<BatchClientBehavior>() { interceptor };
6666

6767
// Verify no exceptions when required parameter is set

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public void RestartBatchComputeNodeParametersTest()
6161
cmdlet.Id = "computeNode1";
6262

6363
// Don't go to the service on a Reboot ComputeNode call
64-
RequestInterceptor interceptor = BatchTestHelpers.CreateNoOpInterceptor<ComputeNodeRebootParameters, ComputeNodeRebootResponse>();
64+
RequestInterceptor interceptor = BatchTestHelpers.CreateFakeServiceResponseInterceptor<ComputeNodeRebootParameters, ComputeNodeRebootResponse>();
6565
cmdlet.AdditionalBehaviors = new List<BatchClientBehavior>() { interceptor };
6666

6767
// Verify no exceptions when required parameter is set

src/ResourceManager/AzureBatch/Commands.Batch.Test/Files/GetBatchNodeFileCommandTests.cs

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

6060
// Build a NodeFile instead of querying the service on a List NodeFile call
6161
NodeFileListResponse response = BatchTestHelpers.CreateNodeFileListResponse(new string[] {cmdlet.Name});
62-
RequestInterceptor interceptor = BatchTestHelpers.CreateNoOpInterceptor<NodeFileListParameters, NodeFileListResponse>(response);
62+
RequestInterceptor interceptor = BatchTestHelpers.CreateFakeServiceResponseInterceptor<NodeFileListParameters, NodeFileListResponse>(response);
6363
cmdlet.AdditionalBehaviors = new List<BatchClientBehavior>() { interceptor };
6464

6565
Assert.Throws<ArgumentException>(() => cmdlet.ExecuteCmdlet());
@@ -92,7 +92,7 @@ public void GetBatchNodeFileByTaskTest()
9292

9393
// Build a NodeFile instead of querying the service on a Get NodeFile Properties call
9494
NodeFileGetPropertiesResponse response = BatchTestHelpers.CreateNodeFileGetPropertiesResponse(cmdlet.Name);
95-
RequestInterceptor interceptor = BatchTestHelpers.CreateNoOpInterceptor<NodeFileGetPropertiesParameters, NodeFileGetPropertiesResponse>(response);
95+
RequestInterceptor interceptor = BatchTestHelpers.CreateFakeServiceResponseInterceptor<NodeFileGetPropertiesParameters, NodeFileGetPropertiesResponse>(response);
9696
cmdlet.AdditionalBehaviors = new List<BatchClientBehavior>() { interceptor };
9797

9898
// Setup the cmdlet to write pipeline output to a list that can be examined later
@@ -122,7 +122,7 @@ public void ListBatchNodeFilesByTaskByODataFilterTest()
122122

123123
// Build some NodeFiles instead of querying the service on a List NodeFiles call
124124
NodeFileListResponse response = BatchTestHelpers.CreateNodeFileListResponse(namesOfConstructedNodeFiles);
125-
RequestInterceptor interceptor = BatchTestHelpers.CreateNoOpInterceptor<NodeFileListParameters, NodeFileListResponse>(response);
125+
RequestInterceptor interceptor = BatchTestHelpers.CreateFakeServiceResponseInterceptor<NodeFileListParameters, NodeFileListResponse>(response);
126126
cmdlet.AdditionalBehaviors = new List<BatchClientBehavior>() { interceptor };
127127

128128
// Setup the cmdlet to write pipeline output to a list that can be examined later
@@ -160,7 +160,7 @@ public void ListBatchNodeFilesByTaskWithoutFiltersTest()
160160

161161
// Build some NodeFiles instead of querying the service on a List NodeFiles call
162162
NodeFileListResponse response = BatchTestHelpers.CreateNodeFileListResponse(namesOfConstructedNodeFiles);
163-
RequestInterceptor interceptor = BatchTestHelpers.CreateNoOpInterceptor<NodeFileListParameters, NodeFileListResponse>(response);
163+
RequestInterceptor interceptor = BatchTestHelpers.CreateFakeServiceResponseInterceptor<NodeFileListParameters, NodeFileListResponse>(response);
164164
cmdlet.AdditionalBehaviors = new List<BatchClientBehavior>() { interceptor };
165165

166166
// Setup the cmdlet to write pipeline output to a list that can be examined later
@@ -203,7 +203,7 @@ public void ListNodeFilesByTaskMaxCountTest()
203203

204204
// Build some NodeFiles instead of querying the service on a List NodeFiles call
205205
NodeFileListResponse response = BatchTestHelpers.CreateNodeFileListResponse(namesOfConstructedNodeFiles);
206-
RequestInterceptor interceptor = BatchTestHelpers.CreateNoOpInterceptor<NodeFileListParameters, NodeFileListResponse>(response);
206+
RequestInterceptor interceptor = BatchTestHelpers.CreateFakeServiceResponseInterceptor<NodeFileListParameters, NodeFileListResponse>(response);
207207
cmdlet.AdditionalBehaviors = new List<BatchClientBehavior>() { interceptor };
208208

209209
// Setup the cmdlet to write pipeline output to a list that can be examined later
@@ -240,7 +240,7 @@ public void GetBatchNodeFileByComputeNodeParametersTest()
240240

241241
// Build a NodeFile instead of querying the service on a List NodeFile call
242242
NodeFileListResponse response = BatchTestHelpers.CreateNodeFileListResponse(new string[] {cmdlet.Name});
243-
RequestInterceptor interceptor = BatchTestHelpers.CreateNoOpInterceptor<NodeFileListParameters, NodeFileListResponse>(response);
243+
RequestInterceptor interceptor = BatchTestHelpers.CreateFakeServiceResponseInterceptor<NodeFileListParameters, NodeFileListResponse>(response);
244244
cmdlet.AdditionalBehaviors = new List<BatchClientBehavior>() { interceptor };
245245

246246
Assert.Throws<ArgumentException>(() => cmdlet.ExecuteCmdlet());
@@ -266,7 +266,7 @@ public void GetBatchNodeFileByComputeNodeTest()
266266

267267
// Build a NodeFile instead of querying the service on a Get NodeFile Properties call
268268
NodeFileGetPropertiesResponse response = BatchTestHelpers.CreateNodeFileGetPropertiesResponse(cmdlet.Name);
269-
RequestInterceptor interceptor = BatchTestHelpers.CreateNoOpInterceptor<NodeFileGetPropertiesParameters, NodeFileGetPropertiesResponse>(response);
269+
RequestInterceptor interceptor = BatchTestHelpers.CreateFakeServiceResponseInterceptor<NodeFileGetPropertiesParameters, NodeFileGetPropertiesResponse>(response);
270270
cmdlet.AdditionalBehaviors = new List<BatchClientBehavior>() { interceptor };
271271

272272
// Setup the cmdlet to write pipeline output to a list that can be examined later
@@ -296,7 +296,7 @@ public void ListBatchNodeFilesByComputeNodeByODataFilterTest()
296296

297297
// Build some NodeFiles instead of querying the service on a List NodeFiles call
298298
NodeFileListResponse response = BatchTestHelpers.CreateNodeFileListResponse(namesOfConstructedNodeFiles);
299-
RequestInterceptor interceptor = BatchTestHelpers.CreateNoOpInterceptor<NodeFileListParameters, NodeFileListResponse>(response);
299+
RequestInterceptor interceptor = BatchTestHelpers.CreateFakeServiceResponseInterceptor<NodeFileListParameters, NodeFileListResponse>(response);
300300
cmdlet.AdditionalBehaviors = new List<BatchClientBehavior>() { interceptor };
301301

302302
// Setup the cmdlet to write pipeline output to a list that can be examined later
@@ -334,7 +334,7 @@ public void ListBatchNodeFilesByComputeNodeWithoutFiltersTest()
334334

335335
// Build some NodeFiles instead of querying the service on a List NodeFiles call
336336
NodeFileListResponse response = BatchTestHelpers.CreateNodeFileListResponse(namesOfConstructedNodeFiles);
337-
RequestInterceptor interceptor = BatchTestHelpers.CreateNoOpInterceptor<NodeFileListParameters, NodeFileListResponse>(response);
337+
RequestInterceptor interceptor = BatchTestHelpers.CreateFakeServiceResponseInterceptor<NodeFileListParameters, NodeFileListResponse>(response);
338338
cmdlet.AdditionalBehaviors = new List<BatchClientBehavior>() { interceptor };
339339

340340
// Setup the cmdlet to write pipeline output to a list that can be examined later
@@ -377,7 +377,7 @@ public void ListNodeFilesByComputeNodeMaxCountTest()
377377

378378
// Build some NodeFiles instead of querying the service on a List NodeFiles call
379379
NodeFileListResponse response = BatchTestHelpers.CreateNodeFileListResponse(namesOfConstructedNodeFiles);
380-
RequestInterceptor interceptor = BatchTestHelpers.CreateNoOpInterceptor<NodeFileListParameters, NodeFileListResponse>(response);
380+
RequestInterceptor interceptor = BatchTestHelpers.CreateFakeServiceResponseInterceptor<NodeFileListParameters, NodeFileListResponse>(response);
381381
cmdlet.AdditionalBehaviors = new List<BatchClientBehavior>() { interceptor };
382382

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

src/ResourceManager/AzureBatch/Commands.Batch.Test/Files/GetBatchNodeFileContentCommandTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public void GetBatchNodeFileByTaskParametersTest()
5858
string fileName = "stdout.txt";
5959

6060
// Don't go to the service on a Get NodeFile call or Get NodeFile Properties call
61-
RequestInterceptor interceptor = BatchTestHelpers.CreateNoOpGetFileAndPropertiesInterceptor(cmdlet.Name);
61+
RequestInterceptor interceptor = BatchTestHelpers.CreateFakGetFileAndPropertiesResponseInterceptor(cmdlet.Name);
6262
cmdlet.AdditionalBehaviors = new List<BatchClientBehavior>() { interceptor };
6363

6464
using (MemoryStream memStream = new MemoryStream())
@@ -94,7 +94,7 @@ public void GetBatchNodeFileByComputeNodeContentParametersTest()
9494
string fileName = "startup\\stdout.txt";
9595

9696
// Don't go to the service on a Get NodeFile call or Get NodeFile Properties call
97-
RequestInterceptor interceptor = BatchTestHelpers.CreateNoOpGetFileAndPropertiesInterceptor(cmdlet.Name);
97+
RequestInterceptor interceptor = BatchTestHelpers.CreateFakGetFileAndPropertiesResponseInterceptor(cmdlet.Name);
9898
cmdlet.AdditionalBehaviors = new List<BatchClientBehavior>() { interceptor };
9999

100100
using (MemoryStream memStream = new MemoryStream())

src/ResourceManager/AzureBatch/Commands.Batch.Test/Files/GetBatchRemoteDesktopProtocolFileCommandTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public void GetBatchRemoteDesktopProtocolFileParametersTest()
5656
cmdlet.DestinationPath = null;
5757

5858
// Don't go to the service on a Get ComputeNode Remote Desktop call
59-
RequestInterceptor interceptor = BatchTestHelpers.CreateNoOpInterceptor<ComputeNodeGetRemoteDesktopParameters, ComputeNodeGetRemoteDesktopResponse>();
59+
RequestInterceptor interceptor = BatchTestHelpers.CreateFakeServiceResponseInterceptor<ComputeNodeGetRemoteDesktopParameters, ComputeNodeGetRemoteDesktopResponse>();
6060
cmdlet.AdditionalBehaviors = new List<BatchClientBehavior>() { interceptor };
6161

6262
using (MemoryStream memStream = new MemoryStream())

src/ResourceManager/AzureBatch/Commands.Batch.Test/JobSchedules/DisableBatchJobScheduleCommandTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public void DisableJobScheduleParametersTest()
5555
cmdlet.Id = "testJobSchedule";
5656

5757
// Don't go to the service on a Disable CloudJobSchedule call
58-
RequestInterceptor interceptor = BatchTestHelpers.CreateNoOpInterceptor<CloudJobScheduleDisableParameters, CloudJobScheduleDisableResponse>();
58+
RequestInterceptor interceptor = BatchTestHelpers.CreateFakeServiceResponseInterceptor<CloudJobScheduleDisableParameters, CloudJobScheduleDisableResponse>();
5959
cmdlet.AdditionalBehaviors = new List<BatchClientBehavior>() { interceptor };
6060

6161
// Verify no exceptions when required parameter is set

src/ResourceManager/AzureBatch/Commands.Batch.Test/JobSchedules/EnableBatchJobScheduleCommandTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public void EnableJobScheduleParametersTest()
5656
cmdlet.Id = "testJobSchedule";
5757

5858
// Don't go to the service on an Enable CloudJobSchedule call
59-
RequestInterceptor interceptor = BatchTestHelpers.CreateNoOpInterceptor<CloudJobScheduleEnableParameters, CloudJobScheduleEnableResponse>();
59+
RequestInterceptor interceptor = BatchTestHelpers.CreateFakeServiceResponseInterceptor<CloudJobScheduleEnableParameters, CloudJobScheduleEnableResponse>();
6060
cmdlet.AdditionalBehaviors = new List<BatchClientBehavior>() { interceptor };
6161

6262
// Verify no exceptions when required parameter is set

0 commit comments

Comments
 (0)