Skip to content

Commit 16c786f

Browse files
code changes for CR1
1 parent d686d89 commit 16c786f

File tree

52 files changed

+2902
-542
lines changed

Some content is hidden

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

52 files changed

+2902
-542
lines changed

src/ResourceManager/AzureBatch/Commands.Batch.Test/Applications/AddBatchApplicationCommandTests.cs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
11
using System;
2-
using System.Collections.Generic;
32
using System.Linq;
43
using System.Management.Automation;
5-
using System.Text;
6-
using System.Threading.Tasks;
7-
8-
using Microsoft.Azure.Commands.Batch.Applications;
94
using Microsoft.Azure.Commands.Batch.Models;
105
using Microsoft.Azure.Commands.Tags.Model;
116
using Microsoft.WindowsAzure.Commands.ScenarioTest;

src/ResourceManager/AzureBatch/Commands.Batch.Test/Applications/DeleteBatchApplicationPackageCommandTests.cs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
11
using System;
2-
using System.Collections.Generic;
32
using System.Linq;
43
using System.Management.Automation;
5-
using System.Text;
6-
using System.Threading.Tasks;
7-
8-
using Microsoft.Azure.Commands.Batch.Applications;
94
using Microsoft.Azure.Commands.Batch.Models;
105
using Microsoft.WindowsAzure.Commands.ScenarioTest;
116

@@ -17,15 +12,15 @@ namespace Microsoft.Azure.Commands.Batch.Test.Applications
1712
{
1813
public class DeleteBatchApplicationPackageCommandTests
1914
{
20-
private DeleteBatchApplicationPackageCommand cmdlet;
15+
private RemoveBatchApplicationPackageCommand cmdlet;
2116
private Mock<BatchClient> batchClientMock;
2217
private Mock<ICommandRuntime> commandRuntimeMock;
2318

2419
public DeleteBatchApplicationPackageCommandTests()
2520
{
2621
batchClientMock = new Mock<BatchClient>();
2722
commandRuntimeMock = new Mock<ICommandRuntime>();
28-
cmdlet = new DeleteBatchApplicationPackageCommand()
23+
cmdlet = new RemoveBatchApplicationPackageCommand()
2924
{
3025
CommandRuntime = commandRuntimeMock.Object,
3126
BatchClient = batchClientMock.Object

src/ResourceManager/AzureBatch/Commands.Batch.Test/Applications/GetBatchApplicationCommandTests.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@
1414

1515
using System;
1616

17-
using Microsoft.Azure.Commands.Tags.Model;
18-
using Microsoft.Azure.Management.Batch.Models;
17+
using Microsoft.Azure.Commands.Batch.Models;
1918
using Microsoft.WindowsAzure.Commands.ScenarioTest;
2019
using Moq;
2120
using System.Collections.Generic;
@@ -52,7 +51,7 @@ public void ListBatchApplicationsTest()
5251
string accountName01 = "account01";
5352
string resourceGroup = "resourceGroup";
5453

55-
PSApplication expected01 = new PSApplication(){};
54+
PSApplication expected01 = new PSApplication();
5655
PSApplication expected02 = new PSApplication();
5756

5857
batchClientMock.Setup(b => b.ListApplications(resourceGroup, accountName01)).Returns(new List<PSApplication>() { expected01, expected02 });
@@ -73,6 +72,7 @@ public void GetBatchApplicationTest()
7372
string accountName = "account01";
7473
string resourceGroup = "resourceGroup";
7574
string applicationId = "applicationId";
75+
7676
PSApplication expected = new PSApplication();
7777
batchClientMock.Setup(b => b.GetApplication(resourceGroup, accountName, applicationId)).Returns(expected);
7878

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,7 @@
11
using System;
2-
using System.Collections.Generic;
32
using System.Linq;
43
using System.Management.Automation;
5-
using System.Text;
6-
using System.Threading.Tasks;
7-
8-
using Microsoft.Azure.Commands.Batch.Applications;
94
using Microsoft.Azure.Commands.Batch.Models;
10-
using Microsoft.Azure.Commands.Tags.Model;
115
using Microsoft.WindowsAzure.Commands.ScenarioTest;
126

137
using Moq;
@@ -16,17 +10,17 @@
1610

1711
namespace Microsoft.Azure.Commands.Batch.Test.Applications
1812
{
19-
public class DeleteBatchApplicationCommandTests
13+
public class RemoveBatchApplicationCommandTests
2014
{
21-
private DeleteBatchApplicationCommand cmdlet;
15+
private RemoveBatchApplicationCommand cmdlet;
2216
private Mock<BatchClient> batchClientMock;
2317
private Mock<ICommandRuntime> commandRuntimeMock;
2418

25-
public DeleteBatchApplicationCommandTests()
19+
public RemoveBatchApplicationCommandTests()
2620
{
2721
batchClientMock = new Mock<BatchClient>();
2822
commandRuntimeMock = new Mock<ICommandRuntime>();
29-
cmdlet = new DeleteBatchApplicationCommand()
23+
cmdlet = new RemoveBatchApplicationCommand()
3024
{
3125
CommandRuntime = commandRuntimeMock.Object,
3226
BatchClient = batchClientMock.Object

src/ResourceManager/AzureBatch/Commands.Batch.Test/Applications/UpdateBatchApplicationCommandTests.cs

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
11
using System;
2-
3-
using Microsoft.Azure.Commands.Batch.Applications;
4-
using Microsoft.Azure.Commands.Tags.Model;
5-
using Microsoft.Azure.Management.Batch.Models;
62
using Microsoft.WindowsAzure.Commands.ScenarioTest;
73
using Moq;
8-
using System.Collections.Generic;
94
using System.Management.Automation;
105
using Xunit;
116
using BatchClient = Microsoft.Azure.Commands.Batch.Models.BatchClient;
@@ -14,15 +9,15 @@ namespace Microsoft.Azure.Commands.Batch.Test.Applications
149
{
1510
public class UpdateBatchApplicationCommandTests
1611
{
17-
private UpdateBatchApplicationCommand cmdlet;
12+
private SetBatchApplicationCommand cmdlet;
1813
private Mock<BatchClient> batchClientMock;
1914
private Mock<ICommandRuntime> commandRuntimeMock;
2015

2116
public UpdateBatchApplicationCommandTests()
2217
{
2318
batchClientMock = new Mock<BatchClient>();
2419
commandRuntimeMock = new Mock<ICommandRuntime>();
25-
cmdlet = new UpdateBatchApplicationCommand()
20+
cmdlet = new SetBatchApplicationCommand()
2621
{
2722
CommandRuntime = commandRuntimeMock.Object,
2823
BatchClient = batchClientMock.Object
@@ -46,14 +41,36 @@ public void UpdateBatchApplicationTest()
4641
cmdlet.AccountName = accountName;
4742
cmdlet.ResourceGroupName = resourceGroup;
4843
cmdlet.ApplicationId = applicationId;
49-
cmdlet.allowUpdates = true;
50-
cmdlet.defaultVersion = defaultVersion;
51-
cmdlet.displayName = displayName;
44+
cmdlet.AllowUpdates = true;
45+
cmdlet.DefaultVersion = defaultVersion;
46+
cmdlet.DisplayName = displayName;
5247

5348
commandRuntimeMock.Setup(f => f.ShouldProcess(It.IsAny<string>(), It.IsAny<string>())).Returns(true);
5449
cmdlet.ExecuteCmdlet();
5550

5651
batchClientMock.Verify(b => b.UpdateApplication(resourceGroup, accountName, applicationId, true, defaultVersion, displayName), Times.Once());
5752
}
53+
54+
[Fact]
55+
[Trait(Category.AcceptanceType, Category.CheckIn)]
56+
public void UpdateBatchApplicationTest2()
57+
{
58+
string accountName = "account01";
59+
string resourceGroup = "resourceGroup";
60+
string applicationId = "applicationId";
61+
62+
AzureOperationResponse updateResponse = new AzureOperationResponse();
63+
64+
batchClientMock.Setup(b => b.UpdateApplication(resourceGroup, accountName, applicationId, false, null, null)).Returns(updateResponse);
65+
66+
cmdlet.AccountName = accountName;
67+
cmdlet.ResourceGroupName = resourceGroup;
68+
cmdlet.ApplicationId = applicationId;
69+
70+
commandRuntimeMock.Setup(f => f.ShouldProcess(It.IsAny<string>(), It.IsAny<string>())).Returns(true);
71+
cmdlet.ExecuteCmdlet();
72+
73+
batchClientMock.Verify(b => b.UpdateApplication(resourceGroup, accountName, applicationId, false, null, null), Times.Once());
74+
}
5875
}
5976
}

src/ResourceManager/AzureBatch/Commands.Batch.Test/Applications/UploadBatchApplicationCommandTests.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
using System.Text;
66
using System.Threading.Tasks;
77

8-
using Microsoft.Azure.Commands.Batch.Applications;
98
using Microsoft.Azure.Commands.Batch.Models;
109
using Microsoft.Azure.Commands.Tags.Model;
1110
using Microsoft.WindowsAzure.Commands.ScenarioTest;
@@ -46,7 +45,7 @@ public void UploadBatchApplicationPackageTest()
4645

4746
PSApplicationPackage applicationPackageResponse = new PSApplicationPackage();
4847

49-
batchClientMock.Setup(b => b.UploadApplicationPackage(resourceGroup, accountName, applicationId, version, filePath, format)).Returns(applicationPackageResponse);
48+
batchClientMock.Setup(b => b.AddAndUploadApplicationPackage(resourceGroup, accountName, applicationId, version, filePath, format)).Returns(applicationPackageResponse);
5049

5150
cmdlet.AccountName = accountName;
5251
cmdlet.ResourceGroupName = resourceGroup;
@@ -58,7 +57,7 @@ public void UploadBatchApplicationPackageTest()
5857
commandRuntimeMock.Setup(f => f.ShouldProcess(It.IsAny<string>(), It.IsAny<string>())).Returns(true);
5958
cmdlet.ExecuteCmdlet();
6059

61-
batchClientMock.Verify(b => b.UploadApplicationPackage(resourceGroup, accountName, applicationId, version, filePath, format), Times.Once());
60+
batchClientMock.Verify(b => b.AddAndUploadApplicationPackage(resourceGroup, accountName, applicationId, version, filePath, format), Times.Once());
6261
}
6362
}
6463
}

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ public static void AssertBatchAccountContextsAreEqual(BatchAccountContext contex
112112
Assert.Equal<string>(context1.Subscription, context2.Subscription);
113113
Assert.Equal<string>(context1.TagsTable, context2.TagsTable);
114114
Assert.Equal<string>(context1.TaskTenantUrl, context2.TaskTenantUrl);
115-
Assert.Equal<string>(context1.StorageAccountId, context2.StorageAccountId);
115+
Assert.Equal<string>(context1.AutoStorageProperties.StorageAccountId, context2.AutoStorageProperties.StorageAccountId);
116116
}
117117

118118
/// <summary>
@@ -773,6 +773,7 @@ internal static void SetField(object obj, string fieldName, object fieldValue)
773773
FieldInfo fieldInfo = t.GetField(fieldName, BindingFlags.NonPublic | BindingFlags.Instance);
774774
fieldInfo.SetValue(obj, fieldValue);
775775
}
776+
776777
internal static T MapEnum<T>(Enum otherEnum) where T : struct
777778
{
778779
if (otherEnum == null)

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

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,9 @@
6464
<Reference Include="Microsoft.Azure.Management.Authorization">
6565
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Authorization.2.0.0\lib\net40\Microsoft.Azure.Management.Authorization.dll</HintPath>
6666
</Reference>
67-
<Reference Include="Microsoft.Azure.Management.Batch">
68-
<HintPath>..\lib\Microsoft.Azure.Management.Batch.dll</HintPath>
67+
<Reference Include="Microsoft.Azure.Management.Batch, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
68+
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Batch.1.6.0\lib\net40\Microsoft.Azure.Management.Batch.dll</HintPath>
69+
<Private>True</Private>
6970
</Reference>
7071
<Reference Include="Microsoft.Azure.ResourceManager">
7172
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Resources.2.18.11-preview\lib\net40\Microsoft.Azure.ResourceManager.dll</HintPath>
@@ -192,7 +193,7 @@
192193
<Compile Include="Applications\AddBatchApplicationCommandTests.cs" />
193194
<Compile Include="Applications\DeleteBatchApplicationPackageCommandTests.cs" />
194195
<Compile Include="Applications\GetBatchApplicationCommandTests.cs" />
195-
<Compile Include="Applications\DeleteBatchApplicationCommandTests.cs" />
196+
<Compile Include="Applications\RemoveBatchApplicationCommandTests.cs" />
196197
<Compile Include="Applications\GetBatchApplicationPackageCommandTests.cs" />
197198
<Compile Include="Applications\UpdateBatchApplicationCommandTests.cs" />
198199
<Compile Include="Applications\UploadBatchApplicationCommandTests.cs" />
@@ -245,7 +246,6 @@
245246
<Compile Include="ScenarioTests\ScenarioTestContext.cs" />
246247
<Compile Include="ScenarioTests\ScenarioTestHelpers.cs" />
247248
<Compile Include="ScenarioTests\SubscriptionTests.cs" />
248-
<Compile Include="ScenarioTests\TaskDependenciesTests.cs" />
249249
<Compile Include="ScenarioTests\TaskTests.cs" />
250250
<Compile Include="ScenarioTests\ComputeNodeUserTests.cs" />
251251
<Compile Include="ScenarioTests\ComputeNodeTests.cs" />
@@ -311,9 +311,6 @@
311311
<None Include="ScenarioTests\SubscriptionTests.ps1">
312312
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
313313
</None>
314-
<None Include="ScenarioTests\TaskDependenciesTests.ps1">
315-
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
316-
</None>
317314
<None Include="ScenarioTests\TaskTests.ps1">
318315
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
319316
</None>

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

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,40 +27,42 @@ 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";
3031

3132
[Fact]
3233
public void TestUploadApplication()
3334
{
34-
BatchController.NewInstance.RunPsTest(string.Format("Test-UploadApplication '{0}' '{1}'", accountName, accountResourceGroup));
35+
string accountName = Environment.GetEnvironmentVariable(ScenarioTestHelpers.BatchAccountName);
36+
BatchController.NewInstance.RunPsTest(string.Format("Test-UploadApplication '{0}' '{1}' ", accountName, accountResourceGroup));
3537
}
3638

3739
[Fact]
3840
public void TestUploadApplicationPackage()
3941
{
4042
BatchController controller = BatchController.NewInstance;
41-
controller.RunPsTest(string.Format("Test-UploadApplicationPackage '{0}' '{1}'", accountName, accountResourceGroup));
43+
controller.RunPsTest(string.Format("Test-UploadApplicationPackage '{0}' '{1}' '{2}'", accountName, accountResourceGroup, filePath));
4244
}
4345

4446
[Fact]
4547
public void TestUpdateApplicationPackage()
4648
{
4749
BatchController controller = BatchController.NewInstance;
48-
controller.RunPsTest(string.Format("Test-UpdateApplicationPackage '{0}' '{1}'", accountName, accountResourceGroup));
50+
controller.RunPsTest(string.Format("Test-UpdateApplicationPackage '{0}' '{1}' '{2}'", accountName, accountResourceGroup, filePath));
4951
}
5052

5153
[Fact]
5254
public void TestCreatePoolWithApplicationPackage()
5355
{
5456
BatchController controller = BatchController.NewInstance;
5557

56-
controller.RunPsTest(string.Format("Test-CreatePoolWithApplicationPackage '{0}' '{1}' {2}", accountName, accountName + "pool-id" + Guid.NewGuid().ToString().Substring(0, 5), accountResourceGroup));
58+
controller.RunPsTest(string.Format("Test-CreatePoolWithApplicationPackage '{0}' '{1}' '{2}' '{3}'", accountName, accountName + "pool-id" + Guid.NewGuid().ToString().Substring(0, 5), accountResourceGroup, filePath));
5759
}
5860

5961
[Fact]
6062
public void TestUpdatePoolWithApplicationPackage()
6163
{
6264
BatchController controller = BatchController.NewInstance;
63-
controller.RunPsTest(string.Format("Test-UpdatePoolWithApplicationPackage '{0}' '{1}' '{2}'", accountName, accountName + "pool-id" + Guid.NewGuid().ToString().Substring(0, 5), accountResourceGroup));
65+
controller.RunPsTest(string.Format("Test-UpdatePoolWithApplicationPackage '{0}' '{1}' '{2}' '{3}'", accountName, accountName + "pool-id" + Guid.NewGuid().ToString().Substring(0, 5), accountResourceGroup, filePath));
6466
}
6567
}
6668
}

0 commit comments

Comments
 (0)