Skip to content

Commit 54cb6f7

Browse files
CR2 changes
1 parent d1cf22a commit 54cb6f7

20 files changed

+271
-215
lines changed

src/ResourceManager/AzureBatch/Commands.Batch.Test/Applications/AddBatchApplicationCommandTests.cs renamed to src/ResourceManager/AzureBatch/Commands.Batch.Test/Applications/NewBatchApplicationCommandTests.cs

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,17 @@
1212

1313
namespace Microsoft.Azure.Commands.Batch.Test.Applications
1414
{
15-
public class AddBatchApplicationCommandTests : RMTestBase
15+
public class NewBatchApplicationCommandTests : RMTestBase
1616
{
17-
private AddBatchApplicationCommand cmdlet;
17+
private NewBatchApplicationCommand cmdlet;
1818
private Mock<BatchClient> batchClientMock;
1919
private Mock<ICommandRuntime> commandRuntimeMock;
2020

21-
public AddBatchApplicationCommandTests()
21+
public NewBatchApplicationCommandTests()
2222
{
2323
batchClientMock = new Mock<BatchClient>();
2424
commandRuntimeMock = new Mock<ICommandRuntime>();
25-
cmdlet = new AddBatchApplicationCommand()
25+
cmdlet = new NewBatchApplicationCommand()
2626
{
2727
CommandRuntime = commandRuntimeMock.Object,
2828
BatchClient = batchClientMock.Object
@@ -52,5 +52,29 @@ public void AddBatchApplicationTest()
5252

5353
commandRuntimeMock.Verify(r => r.WriteObject(expected), Times.Once());
5454
}
55+
56+
[Fact]
57+
[Trait(Category.AcceptanceType, Category.CheckIn)]
58+
public void AddBatchApplicationTestWithoutAllowUpdates()
59+
{
60+
string accountName = "account01";
61+
string resourceGroup = "resourceGroup";
62+
string applicationId = "applicationId";
63+
string displayName = "displayName";
64+
65+
PSApplication expected = new PSApplication();
66+
67+
batchClientMock.Setup(b => b.AddApplication(resourceGroup, accountName, applicationId, null, displayName)).Returns(expected);
68+
69+
cmdlet.ResourceGroupName = resourceGroup;
70+
cmdlet.AccountName = accountName;
71+
cmdlet.ApplicationId = applicationId;
72+
73+
cmdlet.DisplayName = displayName;
74+
75+
cmdlet.ExecuteCmdlet();
76+
77+
commandRuntimeMock.Verify(r => r.WriteObject(expected), Times.Once());
78+
}
5579
}
5680
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@
1010

1111
namespace Microsoft.Azure.Commands.Batch.Test.Applications
1212
{
13-
public class DeleteBatchApplicationPackageCommandTests
13+
public class RemoveBatchApplicationPackageCommandTests
1414
{
1515
private RemoveBatchApplicationPackageCommand cmdlet;
1616
private Mock<BatchClient> batchClientMock;
1717
private Mock<ICommandRuntime> commandRuntimeMock;
1818

19-
public DeleteBatchApplicationPackageCommandTests()
19+
public RemoveBatchApplicationPackageCommandTests()
2020
{
2121
batchClientMock = new Mock<BatchClient>();
2222
commandRuntimeMock = new Mock<ICommandRuntime>();
Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@
77

88
namespace Microsoft.Azure.Commands.Batch.Test.Applications
99
{
10-
public class UpdateBatchApplicationCommandTests
10+
public class SetBatchApplicationCommandTests
1111
{
1212
private SetBatchApplicationCommand cmdlet;
1313
private Mock<BatchClient> batchClientMock;
1414
private Mock<ICommandRuntime> commandRuntimeMock;
1515

16-
public UpdateBatchApplicationCommandTests()
16+
public SetBatchApplicationCommandTests()
1717
{
1818
batchClientMock = new Mock<BatchClient>();
1919
commandRuntimeMock = new Mock<ICommandRuntime>();
@@ -53,15 +53,38 @@ public void UpdateBatchApplicationTest()
5353

5454
[Fact]
5555
[Trait(Category.AcceptanceType, Category.CheckIn)]
56-
public void UpdateBatchApplicationTest2()
56+
public void UpdateBatchApplicationAllowUpdatesOnlyTest()
5757
{
5858
string accountName = "account01";
5959
string resourceGroup = "resourceGroup";
6060
string applicationId = "applicationId";
6161

6262
AzureOperationResponse updateResponse = new AzureOperationResponse();
6363

64-
batchClientMock.Setup(b => b.UpdateApplication(resourceGroup, accountName, applicationId, false, null, null)).Returns(updateResponse);
64+
batchClientMock.Setup(b => b.UpdateApplication(resourceGroup, accountName, applicationId, true, null, null)).Returns(updateResponse);
65+
66+
cmdlet.AccountName = accountName;
67+
cmdlet.ResourceGroupName = resourceGroup;
68+
cmdlet.ApplicationId = applicationId;
69+
cmdlet.AllowUpdates = true;
70+
71+
commandRuntimeMock.Setup(f => f.ShouldProcess(It.IsAny<string>(), It.IsAny<string>())).Returns(true);
72+
cmdlet.ExecuteCmdlet();
73+
74+
batchClientMock.Verify(b => b.UpdateApplication(resourceGroup, accountName, applicationId, true, null, null), Times.Once());
75+
}
76+
77+
[Fact]
78+
[Trait(Category.AcceptanceType, Category.CheckIn)]
79+
public void UpdateBatchApplicationDefault()
80+
{
81+
string accountName = "account01";
82+
string resourceGroup = "resourceGroup";
83+
string applicationId = "applicationId";
84+
85+
AzureOperationResponse updateResponse = new AzureOperationResponse();
86+
87+
batchClientMock.Setup(b => b.UpdateApplication(resourceGroup, accountName, applicationId, null, null, null)).Returns(updateResponse);
6588

6689
cmdlet.AccountName = accountName;
6790
cmdlet.ResourceGroupName = resourceGroup;
@@ -70,7 +93,7 @@ public void UpdateBatchApplicationTest2()
7093
commandRuntimeMock.Setup(f => f.ShouldProcess(It.IsAny<string>(), It.IsAny<string>())).Returns(true);
7194
cmdlet.ExecuteCmdlet();
7295

73-
batchClientMock.Verify(b => b.UpdateApplication(resourceGroup, accountName, applicationId, false, null, null), Times.Once());
96+
batchClientMock.Verify(b => b.UpdateApplication(resourceGroup, accountName, applicationId, null, null, null), Times.Once());
7497
}
7598
}
7699
}

src/ResourceManager/AzureBatch/Commands.Batch.Test/Commands.Batch.Test.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -190,12 +190,12 @@
190190
<Compile Include="Accounts\RegenBatchAccountKeyCommandTests.cs" />
191191
<Compile Include="Accounts\RemoveBatchAccountCommandTests.cs" />
192192
<Compile Include="Accounts\SetBatchAccountCommandTests.cs" />
193-
<Compile Include="Applications\AddBatchApplicationCommandTests.cs" />
194-
<Compile Include="Applications\DeleteBatchApplicationPackageCommandTests.cs" />
193+
<Compile Include="Applications\NewBatchApplicationCommandTests.cs" />
194+
<Compile Include="Applications\RemoveBatchApplicationPackageCommandTests.cs" />
195195
<Compile Include="Applications\GetBatchApplicationCommandTests.cs" />
196196
<Compile Include="Applications\RemoveBatchApplicationCommandTests.cs" />
197197
<Compile Include="Applications\GetBatchApplicationPackageCommandTests.cs" />
198-
<Compile Include="Applications\UpdateBatchApplicationCommandTests.cs" />
198+
<Compile Include="Applications\SetBatchApplicationCommandTests.cs" />
199199
<Compile Include="Applications\UploadBatchApplicationCommandTests.cs" />
200200
<Compile Include="BatchTestHelpers.cs" />
201201
<Compile Include="Certificates\GetBatchCertificateCommandTests.cs" />

src/ResourceManager/AzureBatch/Commands.Batch.Test/ScenarioTests/BatchApplicationTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,13 @@ public class BatchApplicationTests : WindowsAzure.Commands.Test.Utilities.Common
2727
{
2828
private string accountName = Environment.GetEnvironmentVariable(ScenarioTestHelpers.BatchAccountName);
2929
private string accountResourceGroup = Environment.GetEnvironmentVariable(ScenarioTestHelpers.BatchAccountResourceGroup);
30-
private string filePath = "Resources\\foo.zip";
30+
private const string filePath = "Resources\\foo.zip";
3131

3232
[Fact]
3333
public void TestUploadApplication()
3434
{
3535
string accountName = Environment.GetEnvironmentVariable(ScenarioTestHelpers.BatchAccountName);
36-
BatchController.NewInstance.RunPsTest(string.Format("Test-UploadApplication '{0}' '{1}' ", accountName, accountResourceGroup));
36+
BatchController.NewInstance.RunPsTest(string.Format("Test-AddApplication '{0}' '{1}' ", accountName, accountResourceGroup));
3737
}
3838

3939
[Fact]

0 commit comments

Comments
 (0)