Skip to content

. #75

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Aug 24, 2015
Merged

. #75

Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,6 @@
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\packages\WindowsAzure.Storage.4.3.0\lib\net40\Microsoft.WindowsAzure.Storage.dll</HintPath>
</Reference>
<Reference Include="Microsoft.WindowsAzure.Testing, Version=1.0.5417.13285, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\packages\Hydra.SpecTestSupport.1.0.5417.13285-prerelease\lib\net45\Microsoft.WindowsAzure.Testing.dll</HintPath>
</Reference>
<Reference Include="Moq">
<HintPath>..\..\..\packages\Moq.4.2.1402.2112\lib\net40\Moq.dll</HintPath>
</Reference>
Expand Down Expand Up @@ -171,6 +167,10 @@
<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="Jobs\DisableBatchJobCommandTests.cs" />
<Compile Include="Jobs\EnableBatchJobCommandTests.cs" />
<Compile Include="Jobs\GetBatchJobCommandTests.cs" />
<Compile Include="Jobs\NewBatchJobCommandTests.cs" />
<Compile Include="Jobs\RemoveBatchJobCommandTests.cs" />
Expand Down Expand Up @@ -354,6 +354,9 @@
<None Include="SessionRecords\Microsoft.Azure.Commands.Batch.Test.ScenarioTests.JobScheduleTests\TestDeleteJobSchedulePipeline.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.Batch.Test.ScenarioTests.JobScheduleTests\TestDisableAndEnableJobSchedule.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.Batch.Test.ScenarioTests.JobScheduleTests\TestGetJobScheduleById.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
Expand All @@ -375,6 +378,9 @@
<None Include="SessionRecords\Microsoft.Azure.Commands.Batch.Test.ScenarioTests.JobTests\TestDeleteJobPipeline.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.Batch.Test.ScenarioTests.JobTests\TestDisableAndEnableJob.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.Batch.Test.ScenarioTests.JobTests\TestGetJobById.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
// ----------------------------------------------------------------------------------
//
// 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 Microsoft.Azure.Batch;
using Microsoft.Azure.Batch.Protocol;
using Microsoft.Azure.Batch.Protocol.Models;
using Microsoft.Azure.Commands.Batch.Models;
using Microsoft.WindowsAzure.Commands.ScenarioTest;
using Moq;
using System.Collections.Generic;
using System.Linq;
using System.Management.Automation;
using System.Threading.Tasks;
using Xunit;
using BatchClient = Microsoft.Azure.Commands.Batch.Models.BatchClient;

namespace Microsoft.Azure.Commands.Batch.Test.Pools
{
public class DisableBatchJobScheduleCommandTests
{
private DisableBatchJobScheduleCommand cmdlet;
private Mock<BatchClient> batchClientMock;
private Mock<ICommandRuntime> commandRuntimeMock;

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

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void DisableJobScheduleParametersTest()
{
BatchAccountContext context = BatchTestHelpers.CreateBatchContextWithKeys();
cmdlet.BatchContext = context;
cmdlet.Id = null;

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

cmdlet.Id = "testJobSchedule";

// Don't go to the service on a Disable CloudJobSchedule call
RequestInterceptor interceptor = new RequestInterceptor((baseRequest) =>
{
BatchRequest<CloudJobScheduleDisableParameters, CloudJobScheduleDisableResponse> request =
(BatchRequest<CloudJobScheduleDisableParameters, CloudJobScheduleDisableResponse>)baseRequest;

request.ServiceRequestFunc = (cancellationToken) =>
{
CloudJobScheduleDisableResponse response = new CloudJobScheduleDisableResponse();
Task<CloudJobScheduleDisableResponse> task = Task.FromResult(response);
return task;
};
});
cmdlet.AdditionalBehaviors = new List<BatchClientBehavior>() { interceptor };

// Verify no exceptions when required parameter is set
cmdlet.ExecuteCmdlet();
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
// ----------------------------------------------------------------------------------
//
// 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 Microsoft.Azure.Batch;
using Microsoft.Azure.Batch.Protocol;
using Microsoft.Azure.Batch.Protocol.Models;
using Microsoft.Azure.Commands.Batch.Models;
using Microsoft.WindowsAzure.Commands.ScenarioTest;
using Moq;
using System.Collections.Generic;
using System.Linq;
using System.Management.Automation;
using System.Threading.Tasks;
using Xunit;
using BatchClient = Microsoft.Azure.Commands.Batch.Models.BatchClient;

namespace Microsoft.Azure.Commands.Batch.Test.Pools
{
public class EnableBatchJobScheduleCommandTests
{
private EnableBatchJobScheduleCommand cmdlet;
private Mock<BatchClient> batchClientMock;
private Mock<ICommandRuntime> commandRuntimeMock;

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

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void EnableJobScheduleParametersTest()
{
BatchAccountContext context = BatchTestHelpers.CreateBatchContextWithKeys();
cmdlet.BatchContext = context;
cmdlet.Id = null;

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

cmdlet.Id = "testJobSchedule";

// Don't go to the service on an Enable CloudJobSchedule call
RequestInterceptor interceptor = new RequestInterceptor((baseRequest) =>
{
BatchRequest<CloudJobScheduleEnableParameters, CloudJobScheduleEnableResponse> request =
(BatchRequest<CloudJobScheduleEnableParameters, CloudJobScheduleEnableResponse>)baseRequest;

request.ServiceRequestFunc = (cancellationToken) =>
{
CloudJobScheduleEnableResponse response = new CloudJobScheduleEnableResponse();
Task<CloudJobScheduleEnableResponse> task = Task.FromResult(response);
return task;
};
});
cmdlet.AdditionalBehaviors = new List<BatchClientBehavior>() { interceptor };

// Verify no exceptions when required parameter is set
cmdlet.ExecuteCmdlet();
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
// ----------------------------------------------------------------------------------
//
// 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 Microsoft.Azure.Batch;
using Microsoft.Azure.Batch.Common;
using Microsoft.Azure.Batch.Protocol;
using Microsoft.Azure.Batch.Protocol.Models;
using Microsoft.Azure.Commands.Batch.Models;
using Microsoft.WindowsAzure.Commands.ScenarioTest;
using Moq;
using System.Collections.Generic;
using System.Linq;
using System.Management.Automation;
using System.Threading.Tasks;
using Xunit;
using BatchClient = Microsoft.Azure.Commands.Batch.Models.BatchClient;

namespace Microsoft.Azure.Commands.Batch.Test.Pools
{
public class DisableBatchJobCommandTests
{
private DisableBatchJobCommand cmdlet;
private Mock<BatchClient> batchClientMock;
private Mock<ICommandRuntime> commandRuntimeMock;

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

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void DisableJobParametersTest()
{
BatchAccountContext context = BatchTestHelpers.CreateBatchContextWithKeys();
cmdlet.BatchContext = context;
cmdlet.Id = null;

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

cmdlet.Id = "testJob";
cmdlet.DisableJobOption = DisableJobOption.Terminate;

// Don't go to the service on a Disable CloudJob call
RequestInterceptor interceptor = new RequestInterceptor((baseRequest) =>
{
BatchRequest<CloudJobDisableParameters, CloudJobDisableResponse> request =
(BatchRequest<CloudJobDisableParameters, CloudJobDisableResponse>)baseRequest;

request.ServiceRequestFunc = (cancellationToken) =>
{
CloudJobDisableResponse response = new CloudJobDisableResponse();
Task<CloudJobDisableResponse> task = Task.FromResult(response);
return task;
};
});
cmdlet.AdditionalBehaviors = new List<BatchClientBehavior>() { interceptor };

// Verify no exceptions when required parameter is set
cmdlet.ExecuteCmdlet();
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void DisableJobRequestTest()
{
BatchAccountContext context = BatchTestHelpers.CreateBatchContextWithKeys();
cmdlet.BatchContext = context;

DisableJobOption disableOption = DisableJobOption.Terminate;
DisableJobOption requestDisableOption = DisableJobOption.Requeue;

cmdlet.Id = "testJob";
cmdlet.DisableJobOption = disableOption;

// Don't go to the service on an Enable AutoScale call
RequestInterceptor interceptor = new RequestInterceptor((baseRequest) =>
{
BatchRequest<CloudJobDisableParameters, CloudJobDisableResponse> request =
(BatchRequest<CloudJobDisableParameters, CloudJobDisableResponse>)baseRequest;

requestDisableOption = request.TypedParameters.DisableJobOption;

request.ServiceRequestFunc = (cancellationToken) =>
{
CloudJobDisableResponse response = new CloudJobDisableResponse();
Task<CloudJobDisableResponse> task = Task.FromResult(response);
return task;
};
});
cmdlet.AdditionalBehaviors = new List<BatchClientBehavior>() { interceptor };

cmdlet.ExecuteCmdlet();

// Verify that the job disable option was properly set on the outgoing request
Assert.Equal(disableOption, requestDisableOption);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
// ----------------------------------------------------------------------------------
//
// 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 Microsoft.Azure.Batch;
using Microsoft.Azure.Batch.Protocol;
using Microsoft.Azure.Batch.Protocol.Models;
using Microsoft.Azure.Commands.Batch.Models;
using Microsoft.WindowsAzure.Commands.ScenarioTest;
using Moq;
using System.Collections.Generic;
using System.Linq;
using System.Management.Automation;
using System.Threading.Tasks;
using Xunit;
using BatchClient = Microsoft.Azure.Commands.Batch.Models.BatchClient;

namespace Microsoft.Azure.Commands.Batch.Test.Pools
{
public class EnableBatchJobCommandTests
{
private EnableBatchJobCommand cmdlet;
private Mock<BatchClient> batchClientMock;
private Mock<ICommandRuntime> commandRuntimeMock;

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

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void EnableJobParametersTest()
{
BatchAccountContext context = BatchTestHelpers.CreateBatchContextWithKeys();
cmdlet.BatchContext = context;
cmdlet.Id = null;

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

cmdlet.Id = "testJob";

// Don't go to the service on an Enable CloudJob call
RequestInterceptor interceptor = new RequestInterceptor((baseRequest) =>
{
BatchRequest<CloudJobEnableParameters, CloudJobEnableResponse> request =
(BatchRequest<CloudJobEnableParameters, CloudJobEnableResponse>)baseRequest;

request.ServiceRequestFunc = (cancellationToken) =>
{
CloudJobEnableResponse response = new CloudJobEnableResponse();
Task<CloudJobEnableResponse> task = Task.FromResult(response);
return task;
};
});
cmdlet.AdditionalBehaviors = new List<BatchClientBehavior>() { interceptor };

// Verify no exceptions when required parameter is set
cmdlet.ExecuteCmdlet();
}
}
}
Loading