Skip to content
Merged

VMSS #40

Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
148 commits
Select commit Hold shift + click to select a range
3f2cb13
Policy Fix for Monthly Retention
pragrawa Aug 26, 2015
e6a91cc
Merge branch 'dev1' of https://github.com/MabOneSdk/azure-powershell …
pragrawa Aug 28, 2015
b151fa3
Scenario Tests improvement
swatimadhukargit Sep 8, 2015
add2821
First commit
nityasharma Sep 8, 2015
6a51d54
merge
nityasharma Sep 18, 2015
b2a0601
Merged changes
nityasharma Sep 18, 2015
260443f
Authorization: Bug fix in Get-AzureRMRoleAassignment to filter list o…
namratab Sep 21, 2015
028f32f
Merge pull request #98 from huangpf/vmss1
huangpf Sep 21, 2015
586f678
Merge branch 'vmss' of https://github.com/AzureRT/azure-powershell in…
huangpf Sep 21, 2015
4e303e7
[#103628912] Added installation script
stankovski Sep 21, 2015
2d643e9
Fix AzureRT test settings
hyonholee Sep 22, 2015
0914abd
[#102955616, #103828190] Add output types for profile cmdlets and fix…
markcowl Sep 22, 2015
7e087c9
Merge pull request #99 from Azure/dev
huangpf Sep 22, 2015
84062e0
Merge pull request #100 from AzureRT/dev
huangpf Sep 22, 2015
56de02e
Merge branch 'dev' of https://github.com/Azure/azure-powershell into …
AditTulasi Sep 22, 2015
01271f6
Bug #4674630: Register-AzureRMBackupContainer failing with mixed case…
mkherani Sep 22, 2015
045092b
fixing datetime tostring locale issue
AditTulasi Sep 22, 2015
df99235
Updated scripts to use new msbuild configuration
stankovski Sep 22, 2015
29f8f3a
Merge pull request #958 from stankovski/dev
stankovski Sep 22, 2015
73ed8eb
Update SQL help documentation
jamestao Sep 22, 2015
706889d
Merge pull request #149 from MabOneSdk/mkherani-dev1
mkherani Sep 22, 2015
2032a22
Batch update cmdlets
Sep 4, 2015
dba36ec
Tests for Batch Update cmdlets
Sep 8, 2015
1ac0309
Help for Batch update cmdlets
Sep 8, 2015
03b34fd
Fix session records for Batch update tests
Sep 8, 2015
6950060
Rename Batch interceptor helper methods
Sep 10, 2015
0e85db2
fixes #103823362 undo renaming for key vault data plane cmdlets
Sep 22, 2015
5166469
Merge pull request #948 from jamestao/dev
ogail Sep 22, 2015
ad1cf6f
Merge dev branch changes into Batch update cmdlets
Sep 22, 2015
d045e2c
Graph call optimization and parameter fixes
shuagarw Sep 22, 2015
6caf154
Merge branch 'dev' of github.com:Azure/azure-powershell into paramete…
shuagarw Sep 22, 2015
3fc36d9
fixes #103934158 Rename AzureRM cmdlets to AzureRm
Sep 22, 2015
392e3fd
Merge branch 'dev' of github.com:Azure/azure-powershell into dev
Sep 22, 2015
48f048b
reverting unintended help file parameter renaming
markcowl Sep 22, 2015
2e7fdf5
Merge pull request #101 from Azure/dev
huangpf Sep 22, 2015
f460381
Merge pull request #102 from AzureRT/vmss
huangpf Sep 22, 2015
d59aeba
Merge pull request #103 from huangpf/dev
huangpf Sep 22, 2015
0e64614
Merge pull request #37 from hyonholee/dev
AzureRT Sep 22, 2015
aa7489a
Merge pull request #104 from AzureRT/vmss
huangpf Sep 22, 2015
59e6fc5
Added AzureRM.Installer module
stankovski Sep 22, 2015
3cfe7dc
Added Publish step to msbuild
stankovski Sep 22, 2015
a0b4906
Merge pull request #962 from jianghaolu/dev
amarzavery Sep 22, 2015
06df4ed
Added AzureRM installer
stankovski Sep 22, 2015
e30bb97
Merge pull request #105 from Azure/dev
huangpf Sep 22, 2015
1f17434
RoleAssignment fixes
shuagarw Sep 23, 2015
83664bd
Merge branch 'dev' of github.com:Azure/azure-powershell into paramete…
shuagarw Sep 23, 2015
2cc2e63
Merge pull request #964 from stankovski/dev
Sep 23, 2015
9799223
Merge pull request #106 from Azure/dev
huangpf Sep 23, 2015
f7497c8
Fix a bunch of typos.
rhencke Sep 23, 2015
378af92
incorporating comments from CR
AditTulasi Sep 23, 2015
8d5b896
Merge branch 'dev1' of https://github.com/MabOneSdk/azure-powershell …
AditTulasi Sep 23, 2015
405a1ff
Merge pull request #150 from MabOneSdk/dev1
AditTulasi Sep 23, 2015
e1724ad
Merge branch 'dev1' of https://github.com/MabOneSdk/azure-powershell …
pragrawa Sep 23, 2015
3245193
Merging changes from Azure release
AditTulasi Sep 23, 2015
06dd1ed
Merge branch 'release' of https://github.com/MabOneSdk/azure-powershe…
AditTulasi Sep 23, 2015
d357653
Commenting out a test case which is not relevant
AditTulasi Sep 23, 2015
6f62d3a
Adding Force Option for Remove Commandlets
pragrawa Sep 23, 2015
a3fbfe5
Adding Force Option for Remove Commandlets
pragrawa Sep 23, 2015
ac06ca4
skip failing tests
namratab Sep 23, 2015
843d985
Merge branch 'dev' of github.com:Azure/azure-powershell into DocUpdate
namratab Sep 23, 2015
76327ed
Merge Conflict
pragrawa Sep 23, 2015
ad719be
Merge Conflict
pragrawa Sep 23, 2015
ca64e18
Merge Conflict
pragrawa Sep 23, 2015
58dfc04
Merge Conflict
pragrawa Sep 23, 2015
0270be6
Merge pull request #947 from namratab/DocUpdate
markcowl Sep 23, 2015
207a0f7
Merge branch 'dev' of github.com:Azure/azure-powershell into paramete…
shuagarw Sep 23, 2015
f69f6df
[fixes #103934158] Fix storage data plane renamings
jianghaolu Sep 23, 2015
b2adc4f
Merging with upstream changes
markcowl Sep 23, 2015
a3ca5dc
Moving model classes and updating scenario tests
markcowl Sep 23, 2015
48ccf0b
Merge pull request #960 from jasper-schneider/batchUpdateCmdlets
ogail Sep 23, 2015
6ab0000
Fix Tests
Sep 23, 2015
13a8f10
Role Assignment fixes review comments
shuagarw Sep 23, 2015
1ae79b0
Fixing output for profile types
markcowl Sep 23, 2015
2444a52
Updated parallel scripts
stankovski Sep 23, 2015
496f794
Fix reference of storage data plane in ApiManagement
jianghaolu Sep 23, 2015
81bab9e
[fixes #103937270] Add -SubscriptionName to Get-AzureRMSubscription
jianghaolu Sep 23, 2015
443c1f9
Clean up ARM EnvironmentSetupHelper
jianghaolu Sep 23, 2015
818c7dd
Merge pull request #968 from jianghaolu/dev
Sep 23, 2015
b5af0cc
Work in progress
stankovski Sep 23, 2015
b994e6b
Merge pull request #971 from jianghaolu/subname
ogail Sep 24, 2015
05be958
Additional changes for RoleAssignments
shuagarw Sep 24, 2015
9fbfcd4
Merge branch 'dev' of github.com:Azure/azure-powershell into paramete…
shuagarw Sep 24, 2015
853c11a
[#103828190, #103425146, #103697132] Fix display and reported issues …
markcowl Sep 24, 2015
d3d7a9a
Merging with upstream
markcowl Sep 24, 2015
3de5d1e
Correcting merge error
markcowl Sep 24, 2015
4043cbd
prototype to isolate the resource management related artifacts
yugangw-msft Sep 24, 2015
c1a7975
Fixing tests and updating converters to handle null values
markcowl Sep 24, 2015
7eda13a
removing app.config files
markcowl Sep 24, 2015
460cfbc
remove useless output folder copying
yugangw-msft Sep 24, 2015
8da70da
Merge Conflict
pragrawa Sep 24, 2015
2eec883
Merge Conflict
pragrawa Sep 24, 2015
319d397
Merge pull request #145 from MabOneSdk/pragrawadev1
pragrawa Sep 24, 2015
48e4ea9
Added help for Profile cmdlets [##103821006]
markcowl Sep 24, 2015
323db1b
Scrub strings
pragrawa Sep 24, 2015
2280573
Merge pull request #151 from MabOneSdk/pragrawadev1
pragrawa Sep 24, 2015
cfacd2b
TestCases
pragrawa Sep 24, 2015
af0e6b6
TestCases
pragrawa Sep 24, 2015
a6562e5
Merge pull request #153 from MabOneSdk/pragrawadev1
pragrawa Sep 24, 2015
9730290
Removing E2ETest
pragrawa Sep 24, 2015
1b43ca4
Merge pull request #154 from MabOneSdk/pragrawadev1
pragrawa Sep 24, 2015
8b14a48
Merge branch 'dev1' into release
pragrawa Sep 24, 2015
773f445
Merge Conflict
pragrawa Sep 24, 2015
f1b0975
Merge Conflict
pragrawa Sep 24, 2015
ca9097f
add scope build property
yugangw-msft Sep 24, 2015
776b344
create arm storage command solution
yugangw-msft Sep 24, 2015
1e966c4
Merge pull request #107 from Azure/dev
huangpf Sep 24, 2015
044d728
Merge pull request #954 from markcowl/pocotypes
Sep 24, 2015
ca9b6b8
Merge branch 'dev' of github.com:Azure/azure-powershell into rmprofile
markcowl Sep 24, 2015
13c321d
Merge pull request #972 from markcowl/rmprofile
Sep 24, 2015
7203eae
Merge pull request #108 from Azure/dev
huangpf Sep 24, 2015
2bc9f92
Merge branch 'dev' of github.com:Azure/azure-powershell into paramete…
shuagarw Sep 24, 2015
16ae20f
create solution for arm compute, network, resource, automation,
yugangw-msft Sep 24, 2015
2c27318
Fixing issue with AzureEndpoints.
ms-alguerra Sep 24, 2015
dfc51cb
cli
huangpf Sep 25, 2015
6389ae9
Merge branch 'vmss' of https://github.com/huangpf/azure-powershell in…
huangpf Sep 25, 2015
3970450
Add Comment Header
huangpf Sep 25, 2015
b4b91aa
create keyvault, operationalInsights siterecovery, profile, sql,
yugangw-msft Sep 24, 2015
b7599d2
Merge pull request #965 from rhencke/patch-1
markcowl Sep 25, 2015
b7a4473
Merge pull request #969 from jasper-schneider/fixTests
markcowl Sep 25, 2015
8c041a4
Merge pull request #970 from shuagarw/parameterAndBugFixes
markcowl Sep 25, 2015
5d7c796
Merge pull request #975 from t-alguer/dev
markcowl Sep 25, 2015
467889a
Merge pull request #109 from Azure/dev
huangpf Sep 25, 2015
2ffbf73
Update Create-ParameterObject.ps1
huangpf Sep 25, 2015
7e1704a
Update Code
huangpf Sep 25, 2015
c33c6dd
create rediscache solution
yugangw-msft Sep 25, 2015
aaba772
use const to represent common imported modules by test code
yugangw-msft Sep 25, 2015
b9ad912
Merge pull request #110 from Azure/dev
huangpf Sep 25, 2015
aafa531
Fixed install script
stankovski Sep 25, 2015
8d71add
clean up the build.proj by not differetiating the rm or sm solutions
yugangw-msft Sep 25, 2015
44704ab
Removed Install-Module Azure from the shortcut
stankovski Sep 25, 2015
557bdfb
Merge pull request #940 from nityasharma/dev
markcowl Sep 25, 2015
24d86ec
Added version check
stankovski Sep 25, 2015
72e481d
Merge pull request #967 from MabOneSdk/release
markcowl Sep 25, 2015
42d311c
Merge pull request #978 from stankovski/dev
stankovski Sep 25, 2015
edd300f
Merge pull request #111 from Azure/dev
huangpf Sep 25, 2015
0d1d883
Merge pull request #112 from Azure/dev
huangpf Sep 25, 2015
6da6284
Merge pull request #977 from yugangw-msft/build
stankovski Sep 25, 2015
6b38643
Merge pull request #113 from Azure/dev
huangpf Sep 25, 2015
bb38103
Merge pull request #114 from huangpf/dev
huangpf Sep 25, 2015
107e43e
Added Uninstall to AzureRM
stankovski Sep 25, 2015
50e0e90
Merge pull request #981 from stankovski/dev
stankovski Sep 25, 2015
64c136c
Merge branch 'dev' of https://github.com/Azure/azure-powershell into dev
hyonholee Sep 26, 2015
28289db
fix AzureRT test issue
hyonholee Sep 26, 2015
da9cce5
Fix Test
huangpf Sep 26, 2015
9a051fc
Merge pull request #115 from AzureRT/dev
huangpf Sep 26, 2015
8100ada
Update
huangpf Sep 26, 2015
70b9a28
Merge pull request #116 from Azure/dev
huangpf Sep 26, 2015
83437a6
Merge pull request #117 from huangpf/dev
huangpf Sep 28, 2015
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
126 changes: 111 additions & 15 deletions src/ResourceManager/AzureBatch/Commands.Batch.Test/BatchTestHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,26 +12,16 @@
// limitations under the License.
// ----------------------------------------------------------------------------------

using System.IO;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Threading.Tasks;
using Microsoft.Azure.Batch;
using Microsoft.Azure.Batch.Common;
using Microsoft.Azure.Batch.Protocol;
using Microsoft.Azure.Commands.Batch.Models;
using Microsoft.Azure.Commands.Batch.Test.ScenarioTests;
using Microsoft.Azure.Management.Batch;
using Microsoft.Azure.Management.Batch.Models;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Reflection;
using Microsoft.Azure.Management.Resources;
using Microsoft.Azure.Management.Resources.Models;
using Microsoft.Azure.Test.HttpRecorder;
using Microsoft.WindowsAzure.Storage.Shared.Protocol;
using Xunit;
using ProxyModels = Microsoft.Azure.Batch.Protocol.Models;

Expand Down Expand Up @@ -114,16 +104,22 @@ public static void AssertBatchAccountContextsAreEqual(BatchAccountContext contex
/// Creates a RequestInterceptor that does not contact the Batch Service but instead uses the supplied response body.
/// </summary>
/// <param name="responseToUse">The response the interceptor should return. If none is specified, then a new instance of the response type is instantiated.</param>
/// <param name="requestAction">An action to perform on the request.</param>
/// <typeparam name="TParameters">The type of the request parameters.</typeparam>
/// <typeparam name="TResponse">The type of the expected response.</typeparam>
public static RequestInterceptor CreateNoOpInterceptor<TParameters, TResponse>(TResponse responseToUse = null)
public static RequestInterceptor CreateFakeServiceResponseInterceptor<TParameters, TResponse>(TResponse responseToUse = null,
Action<BatchRequest<TParameters, TResponse>> requestAction = null)
where TParameters : ProxyModels.BatchParameters
where TResponse : ProxyModels.BatchOperationResponse, new()
{
RequestInterceptor interceptor = new RequestInterceptor((baseRequest) =>
{
BatchRequest<TParameters, TResponse> request =
(BatchRequest<TParameters, TResponse>)baseRequest;
BatchRequest<TParameters, TResponse> request = (BatchRequest<TParameters, TResponse>)baseRequest;

if (requestAction != null)
{
requestAction(request);
}

request.ServiceRequestFunc = (cancellationToken) =>
{
Expand All @@ -140,12 +136,12 @@ public static RequestInterceptor CreateNoOpInterceptor<TParameters, TResponse>(T
/// The interceptor must handle both request types since it's possible for one OM node file method to perform both REST APIs.
/// </summary>
/// <param name="fileName">The name of the file to put in the response body.</param>
public static RequestInterceptor CreateNoOpGetFileAndPropertiesInterceptor(string fileName)
public static RequestInterceptor CreateFakGetFileAndPropertiesResponseInterceptor(string fileName)
{
RequestInterceptor interceptor = new RequestInterceptor((baseRequest) =>
{
BatchRequest<ProxyModels.NodeFileGetParameters, ProxyModels.NodeFileGetResponse> fileRequest = baseRequest as
BatchRequest<ProxyModels.NodeFileGetParameters, ProxyModels.NodeFileGetResponse>;
BatchRequest<ProxyModels.NodeFileGetParameters, ProxyModels.NodeFileGetResponse>;

if (fileRequest != null)
{
Expand Down Expand Up @@ -401,6 +397,106 @@ public static ProxyModels.NodeFileListResponse CreateNodeFileListResponse(IEnume
return response;
}

/// <summary>
/// Fabricates a CloudJob that's in the bound state
/// </summary>
public static CloudJob CreateFakeBoundJob(BatchAccountContext context)
{
string jobId = "testJob";

RequestInterceptor interceptor = new RequestInterceptor((baseRequest) =>
{
BatchRequest<ProxyModels.CloudJobGetParameters, ProxyModels.CloudJobGetResponse> request =
(BatchRequest<ProxyModels.CloudJobGetParameters, ProxyModels.CloudJobGetResponse>)baseRequest;

request.ServiceRequestFunc = (cancellationToken) =>
{
ProxyModels.CloudJobGetResponse response = new ProxyModels.CloudJobGetResponse();
response.Job = new ProxyModels.CloudJob(jobId, new ProxyModels.PoolInformation());

Task<ProxyModels.CloudJobGetResponse> task = Task.FromResult(response);
return task;
};
});

return context.BatchOMClient.JobOperations.GetJob(jobId, additionalBehaviors: new BatchClientBehavior[] { interceptor });
}

/// <summary>
/// Fabricates a CloudJobSchedule that's in the bound state
/// </summary>
public static CloudJobSchedule CreateFakeBoundJobSchedule(BatchAccountContext context)
{
string jobScheduleId = "testJobSchedule";

RequestInterceptor interceptor = new RequestInterceptor((baseRequest) =>
{
BatchRequest<ProxyModels.CloudJobScheduleGetParameters, ProxyModels.CloudJobScheduleGetResponse> request =
(BatchRequest<ProxyModels.CloudJobScheduleGetParameters, ProxyModels.CloudJobScheduleGetResponse>)baseRequest;

request.ServiceRequestFunc = (cancellationToken) =>
{
ProxyModels.CloudJobScheduleGetResponse response = new ProxyModels.CloudJobScheduleGetResponse();
response.JobSchedule = new ProxyModels.CloudJobSchedule(jobScheduleId, new ProxyModels.Schedule(), new ProxyModels.JobSpecification());

Task<ProxyModels.CloudJobScheduleGetResponse> task = Task.FromResult(response);
return task;
};
});

return context.BatchOMClient.JobScheduleOperations.GetJobSchedule(jobScheduleId, additionalBehaviors: new BatchClientBehavior[] { interceptor });
}

/// <summary>
/// Fabricates a CloudPool that's in the bound state
/// </summary>
public static CloudPool CreateFakeBoundPool(BatchAccountContext context)
{
string poolId = "testPool";

RequestInterceptor interceptor = new RequestInterceptor((baseRequest) =>
{
BatchRequest<ProxyModels.CloudPoolGetParameters, ProxyModels.CloudPoolGetResponse> request =
(BatchRequest<ProxyModels.CloudPoolGetParameters, ProxyModels.CloudPoolGetResponse>)baseRequest;

request.ServiceRequestFunc = (cancellationToken) =>
{
ProxyModels.CloudPoolGetResponse response = new ProxyModels.CloudPoolGetResponse();
response.Pool = new ProxyModels.CloudPool(poolId, "small", "4");

Task<ProxyModels.CloudPoolGetResponse> task = Task.FromResult(response);
return task;
};
});

return context.BatchOMClient.PoolOperations.GetPool(poolId, additionalBehaviors: new BatchClientBehavior[] { interceptor });
}

/// <summary>
/// Fabricates a CloudTask that's in the bound state
/// </summary>
public static CloudTask CreateFakeBoundTask(BatchAccountContext context)
{
string taskId = "testTask";

RequestInterceptor interceptor = new RequestInterceptor((baseRequest) =>
{
BatchRequest<ProxyModels.CloudTaskGetParameters, ProxyModels.CloudTaskGetResponse> request =
(BatchRequest<ProxyModels.CloudTaskGetParameters, ProxyModels.CloudTaskGetResponse>)baseRequest;

request.ServiceRequestFunc = (cancellationToken) =>
{
ProxyModels.CloudTaskGetResponse response = new ProxyModels.CloudTaskGetResponse();
response.Task = new ProxyModels.CloudTask(taskId, "cmd /c dir /s");

Task<ProxyModels.CloudTaskGetResponse> task = Task.FromResult(response);
return task;
};
});

return context.BatchOMClient.JobOperations.GetTask("jobId", taskId, additionalBehaviors: new BatchClientBehavior[] { interceptor });
}

/// <summary>
/// Uses Reflection to set a property value on an object. Can be used to bypass restricted set accessors.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,24 +178,28 @@
<Compile Include="BatchTestHelpers.cs" />
<Compile Include="ComputeNodes\ResetBatchComputeNodeCommandTests.cs" />
<Compile Include="ComputeNodes\RestartBatchComputeNodeCommandTests.cs" />
<Compile Include="ComputeNodeUsers\SetBatchComputeNoderUserCommandTests.cs" />
<Compile Include="Files\GetBatchRemoteDesktopProtocolFileCommandTests.cs" />
<Compile Include="Files\GetBatchNodeFileCommandTests.cs" />
<Compile Include="Files\GetBatchNodeFileContentCommandTests.cs" />
<Compile Include="JobSchedules\DisableBatchJobScheduleCommandTests.cs" />
<Compile Include="JobSchedules\EnableBatchJobScheduleCommandTests.cs" />
<Compile Include="JobSchedules\SetBatchJobScheduleCommandTests.cs" />
<Compile Include="JobSchedules\StopBatchJobScheduleCommandTests.cs" />
<Compile Include="Jobs\DisableBatchJobCommandTests.cs" />
<Compile Include="Jobs\EnableBatchJobCommandTests.cs" />
<Compile Include="Jobs\GetBatchJobCommandTests.cs" />
<Compile Include="Jobs\NewBatchJobCommandTests.cs" />
<Compile Include="Jobs\RemoveBatchJobCommandTests.cs" />
<Compile Include="Jobs\SetBatchJobCommandTests.cs" />
<Compile Include="Jobs\StopBatchJobCommandTests.cs" />
<Compile Include="Models\BatchAccountContextTest.cs" />
<Compile Include="Pools\DisableBatchAutoScaleCommandTests.cs" />
<Compile Include="Pools\EnableBatchAutoScaleCommandTests.cs" />
<Compile Include="Pools\GetBatchPoolCommandTests.cs" />
<Compile Include="Pools\NewBatchPoolCommandTests.cs" />
<Compile Include="Pools\RemoveBatchPoolCommandTests.cs" />
<Compile Include="Pools\SetBatchPoolCommandTests.cs" />
<Compile Include="Pools\SetBatchPoolOSVersionCommandTests.cs" />
<Compile Include="Pools\StartBatchPoolResizeCommandTests.cs" />
<Compile Include="Pools\StopBatchPoolResizeCommandTests.cs" />
Expand All @@ -220,6 +224,7 @@
<Compile Include="JobSchedules\GetBatchJobScheduleCommandTests.cs" />
<Compile Include="JobSchedules\NewBatchJobScheduleCommandTests.cs" />
<Compile Include="JobSchedules\RemoveBatchJobScheduleCommandTests.cs" />
<Compile Include="Tasks\SetBatchTaskCommandTests.cs" />
<Compile Include="Tasks\StopBatchTaskCommandTests.cs" />
</ItemGroup>
<ItemGroup>
Expand Down Expand Up @@ -311,6 +316,9 @@
<None Include="SessionRecords\Microsoft.Azure.Commands.Batch.Test.ScenarioTests.ComputeNodeUserTests\TestDeleteComputeNodeUser.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.Batch.Test.ScenarioTests.ComputeNodeUserTests\TestUpdateComputeNodeUser.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.Batch.Test.ScenarioTests.FileTests\TestGetNodeFileByComputeNodeByName.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
Expand Down Expand Up @@ -395,6 +403,9 @@
<None Include="SessionRecords\Microsoft.Azure.Commands.Batch.Test.ScenarioTests.JobScheduleTests\TestTerminateJobSchedulePipeline.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.Batch.Test.ScenarioTests.JobScheduleTests\TestUpdateJobSchedule.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.Batch.Test.ScenarioTests.JobTests\TestDeleteJob.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
Expand Down Expand Up @@ -428,6 +439,9 @@
<None Include="SessionRecords\Microsoft.Azure.Commands.Batch.Test.ScenarioTests.JobTests\TestTerminateJobPipeline.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.Batch.Test.ScenarioTests.JobTests\TestUpdateJob.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.Batch.Test.ScenarioTests.PoolTests\TestChangeOSVersionById.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
Expand Down Expand Up @@ -485,6 +499,9 @@
<None Include="SessionRecords\Microsoft.Azure.Commands.Batch.Test.ScenarioTests.PoolTests\TestStopResizePoolByPipeline.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.Batch.Test.ScenarioTests.PoolTests\TestUpdatePool.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.Batch.Test.ScenarioTests.TaskTests\TestCreateTask.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
Expand Down Expand Up @@ -512,6 +529,9 @@
<None Include="SessionRecords\Microsoft.Azure.Commands.Batch.Test.ScenarioTests.TaskTests\TestTerminateTask.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.Batch.Test.ScenarioTests.TaskTests\TestUpdateTask.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\Common\Commands.ResourceManager.Common\Commands.ResourceManager.Common.csproj">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public void NewBatchComputeNodeUserParametersTest()
cmdlet.Password = "Password1234";

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

// Verify no exceptions when required parameters are set
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public void RemoveBatchComputeNodeUserParametersTest()
cmdlet.Name = "testUser";

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

// Verify no exceptions when required parameters are set
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
// ----------------------------------------------------------------------------------
//
// Copyright Microsoft Corporation
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// ----------------------------------------------------------------------------------

using System;
using System.Threading.Tasks;
using Microsoft.Azure.Batch;
using Microsoft.Azure.Batch.Protocol;
using Microsoft.Azure.Batch.Protocol.Models;
using Microsoft.WindowsAzure.Commands.ScenarioTest;
using Moq;
using System.Collections.Generic;
using System.Management.Automation;
using Xunit;
using BatchClient = Microsoft.Azure.Commands.Batch.Models.BatchClient;

namespace Microsoft.Azure.Commands.Batch.Test.ComputeNodeUsers
{
public class SetBatchComputeNodeUserCommandTests
{
private SetBatchComputeNodeUserCommand cmdlet;
private Mock<BatchClient> batchClientMock;
private Mock<ICommandRuntime> commandRuntimeMock;

public SetBatchComputeNodeUserCommandTests()
{
batchClientMock = new Mock<BatchClient>();
commandRuntimeMock = new Mock<ICommandRuntime>();
cmdlet = new SetBatchComputeNodeUserCommand()
{
CommandRuntime = commandRuntimeMock.Object,
BatchClient = batchClientMock.Object,
};
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void SetBatchComputeNodeUserParametersTest()
{
// Setup cmdlet without the required parameters
BatchAccountContext context = BatchTestHelpers.CreateBatchContextWithKeys();
cmdlet.BatchContext = context;

Assert.Throws<ArgumentNullException>(() => cmdlet.ExecuteCmdlet());

cmdlet.PoolId = "testPool";
cmdlet.ComputeNodeId = "computeNode1";

Assert.Throws<ArgumentNullException>(() => cmdlet.ExecuteCmdlet());

cmdlet.Name = "testUser";

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

// Verify no exceptions when required parameters are set
cmdlet.ExecuteCmdlet();
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void SetBatchComputeNodeUserRequestTest()
{
BatchAccountContext context = BatchTestHelpers.CreateBatchContextWithKeys();
cmdlet.BatchContext = context;
cmdlet.PoolId = "testPool";
cmdlet.ComputeNodeId = "computeNode1";
cmdlet.Name = "testUser";
cmdlet.Password = "Password1234";
cmdlet.ExpiryTime = DateTime.Now.AddDays(1);

string requestPassword = null;
DateTime requestExpiryTime = DateTime.Now;

// Don't go to the service on an Update ComputeNodeUser call
Action<BatchRequest<ComputeNodeUpdateUserParameters, ComputeNodeUpdateUserResponse>> extractUserUpdateParametersAction =
(request) =>
{
requestPassword = request.TypedParameters.Password;
requestExpiryTime = request.TypedParameters.ExpiryTime.Value;
};
RequestInterceptor interceptor = BatchTestHelpers.CreateFakeServiceResponseInterceptor(requestAction: extractUserUpdateParametersAction);
cmdlet.AdditionalBehaviors = new List<BatchClientBehavior>() { interceptor };

cmdlet.ExecuteCmdlet();

// Verify the request parameters match expectations
Assert.Equal(cmdlet.Password, requestPassword);
Assert.Equal(cmdlet.ExpiryTime, requestExpiryTime);
}
}
}
Loading