Skip to content

Commit 8c64af3

Browse files
committed
Merge branch 'feature/app-and-td' into feature/swagger-app-and-td
2 parents 2e40cf0 + e3be17a commit 8c64af3

File tree

62 files changed

+6170
-588
lines changed

Some content is hidden

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

62 files changed

+6170
-588
lines changed

src/ResourceManager/AzureBatch/Commands.Batch.Test/Accounts/NewBatchAccountCommandTests.cs

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public void NewBatchAccountTest()
5050
AccountResource accountResource = BatchTestHelpers.CreateAccountResource(accountName, resourceGroup);
5151
BatchAccountContext expected = BatchAccountContext.ConvertAccountResourceToNewAccountContext(accountResource);
5252

53-
batchClientMock.Setup(b => b.CreateAccount(resourceGroup, accountName, location, null)).Returns(expected);
53+
batchClientMock.Setup(b => b.CreateAccount(resourceGroup, accountName, location, null, null)).Returns(expected);
5454

5555
cmdlet.AccountName = accountName;
5656
cmdlet.ResourceGroupName = resourceGroup;
@@ -60,5 +60,29 @@ public void NewBatchAccountTest()
6060

6161
commandRuntimeMock.Verify(r => r.WriteObject(expected), Times.Once());
6262
}
63+
64+
[Fact]
65+
[Trait(Category.AcceptanceType, Category.CheckIn)]
66+
public void NewBatchWithAutoStorageAccountTest()
67+
{
68+
string accountName = "account01";
69+
string resourceGroup = "resourceGroup";
70+
string location = "location";
71+
string storageId = "storageId";
72+
73+
AccountResource accountResource = BatchTestHelpers.CreateAccountResource(accountName, resourceGroup);
74+
BatchAccountContext expected = BatchAccountContext.ConvertAccountResourceToNewAccountContext(accountResource);
75+
76+
batchClientMock.Setup(b => b.CreateAccount(resourceGroup, accountName, location, null, storageId)).Returns(expected);
77+
78+
cmdlet.AccountName = accountName;
79+
cmdlet.ResourceGroupName = resourceGroup;
80+
cmdlet.Location = location;
81+
cmdlet.StorageId = storageId;
82+
83+
cmdlet.ExecuteCmdlet();
84+
85+
commandRuntimeMock.Verify(r => r.WriteObject(expected), Times.Once());
86+
}
6387
}
6488
}

src/ResourceManager/AzureBatch/Commands.Batch.Test/Accounts/SetBatchAccountCommandTests.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ public void UpdateAccountTest()
4646
{
4747
string accountName = "account01";
4848
string resourceGroup = "resourceGroup";
49+
string storageId = "storageId";
50+
4951
Hashtable[] tags = new[]
5052
{
5153
new Hashtable
@@ -54,19 +56,21 @@ public void UpdateAccountTest()
5456
{"Value", "tagValue"}
5557
}
5658
};
59+
5760
AccountResource accountResource = BatchTestHelpers.CreateAccountResource(accountName, resourceGroup, tags);
61+
5862
BatchAccountContext expected = BatchAccountContext.ConvertAccountResourceToNewAccountContext(accountResource);
5963

60-
batchClientMock.Setup(b => b.UpdateAccount(resourceGroup, accountName, tags)).Returns(expected);
64+
batchClientMock.Setup(b => b.UpdateAccount(resourceGroup, accountName, tags, storageId)).Returns(expected);
6165

6266
cmdlet.AccountName = accountName;
6367
cmdlet.ResourceGroupName = resourceGroup;
6468
cmdlet.Tag = tags;
69+
cmdlet.StorageId = storageId;
6570

6671
cmdlet.ExecuteCmdlet();
6772

6873
commandRuntimeMock.Verify(r => r.WriteObject(expected), Times.Once());
6974
}
70-
7175
}
7276
}
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
// ----------------------------------------------------------------------------------
2+
//
3+
// Copyright Microsoft Corporation
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
// Unless required by applicable law or agreed to in writing, software
9+
// distributed under the License is distributed on an "AS IS" BASIS,
10+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
// See the License for the specific language governing permissions and
12+
// limitations under the License.
13+
// ----------------------------------------------------------------------------------
14+
15+
using System;
16+
17+
using Microsoft.Azure.Commands.Batch.Models;
18+
using Microsoft.WindowsAzure.Commands.ScenarioTest;
19+
using Moq;
20+
using System.Collections.Generic;
21+
using System.Management.Automation;
22+
using Xunit;
23+
using BatchClient = Microsoft.Azure.Commands.Batch.Models.BatchClient;
24+
using Microsoft.WindowsAzure.Commands.Test.Utilities.Common;
25+
26+
namespace Microsoft.Azure.Commands.Batch.Test.Accounts
27+
{
28+
public class GetBatchApplicationCommandTests : RMTestBase
29+
{
30+
private GetBatchApplicationCommand cmdlet;
31+
private Mock<BatchClient> batchClientMock;
32+
private Mock<ICommandRuntime> commandRuntimeMock;
33+
34+
public GetBatchApplicationCommandTests()
35+
{
36+
batchClientMock = new Mock<BatchClient>();
37+
commandRuntimeMock = new Mock<ICommandRuntime>();
38+
cmdlet = new GetBatchApplicationCommand()
39+
{
40+
CommandRuntime = commandRuntimeMock.Object,
41+
BatchClient = batchClientMock.Object
42+
};
43+
}
44+
45+
[Fact]
46+
[Trait(Category.AcceptanceType, Category.CheckIn)]
47+
public void ListBatchApplicationsTest()
48+
{
49+
List<BatchAccountContext> pipelineOutput = new List<BatchAccountContext>();
50+
51+
string accountName01 = "account01";
52+
string resourceGroup = "resourceGroup";
53+
54+
PSApplication expected01 = new PSApplication();
55+
PSApplication expected02 = new PSApplication();
56+
57+
batchClientMock.Setup(b => b.ListApplications(resourceGroup, accountName01)).Returns(new List<PSApplication>() { expected01, expected02 });
58+
59+
cmdlet.AccountName = accountName01;
60+
cmdlet.ResourceGroupName = resourceGroup;
61+
62+
cmdlet.ExecuteCmdlet();
63+
64+
commandRuntimeMock.Verify(r => r.WriteObject(expected01), Times.Once());
65+
commandRuntimeMock.Verify(r => r.WriteObject(expected02), Times.Once());
66+
}
67+
68+
[Fact]
69+
[Trait(Category.AcceptanceType, Category.CheckIn)]
70+
public void GetBatchApplicationTest()
71+
{
72+
string accountName = "account01";
73+
string resourceGroup = "resourceGroup";
74+
string applicationId = "applicationId";
75+
76+
PSApplication expected = new PSApplication();
77+
batchClientMock.Setup(b => b.GetApplication(resourceGroup, accountName, applicationId)).Returns(expected);
78+
79+
cmdlet.AccountName = accountName;
80+
cmdlet.ResourceGroupName = resourceGroup;
81+
cmdlet.ApplicationId = applicationId;
82+
83+
cmdlet.ExecuteCmdlet();
84+
85+
commandRuntimeMock.Verify(r => r.WriteObject(expected), Times.Once());
86+
}
87+
}
88+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Management.Automation;
5+
using System.Text;
6+
using System.Threading.Tasks;
7+
8+
using Microsoft.Azure.Commands.Batch.Models;
9+
using Microsoft.WindowsAzure.Commands.ScenarioTest;
10+
11+
using Moq;
12+
13+
using Xunit;
14+
15+
namespace Microsoft.Azure.Commands.Batch.Test.Applications
16+
{
17+
public class GetBatchApplicationPackageCommandTests
18+
{
19+
private GetBatchApplicationPackageCommand cmdlet;
20+
private Mock<BatchClient> batchClientMock;
21+
private Mock<ICommandRuntime> commandRuntimeMock;
22+
23+
public GetBatchApplicationPackageCommandTests()
24+
{
25+
batchClientMock = new Mock<BatchClient>();
26+
commandRuntimeMock = new Mock<ICommandRuntime>();
27+
cmdlet = new GetBatchApplicationPackageCommand()
28+
{
29+
CommandRuntime = commandRuntimeMock.Object,
30+
BatchClient = batchClientMock.Object
31+
};
32+
}
33+
34+
[Fact]
35+
[Trait(Category.AcceptanceType, Category.CheckIn)]
36+
public void GetBatchApplicationsTest()
37+
{
38+
string accountName = "account01";
39+
string resourceGroup = "resourceGroup";
40+
string applicationId = "test";
41+
string applicationVersion = "foo";
42+
43+
PSApplicationPackage expected = new PSApplicationPackage() { Id = applicationId, Version = applicationVersion };
44+
batchClientMock.Setup(b => b.GetApplicationPackage(resourceGroup, accountName, applicationId, applicationVersion)).Returns(expected);
45+
46+
cmdlet.AccountName = accountName;
47+
cmdlet.ResourceGroupName = resourceGroup;
48+
cmdlet.ApplicationId = applicationId;
49+
cmdlet.ApplicationVersion = applicationVersion;
50+
51+
cmdlet.ExecuteCmdlet();
52+
53+
commandRuntimeMock.Verify(r => r.WriteObject(expected), Times.Once());
54+
}
55+
}
56+
}
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
using System;
2+
using System.Linq;
3+
using System.Management.Automation;
4+
using Microsoft.Azure.Commands.Batch.Models;
5+
using Microsoft.WindowsAzure.Commands.ScenarioTest;
6+
using Microsoft.WindowsAzure.Commands.Test.Utilities.Common;
7+
8+
using Moq;
9+
10+
using Xunit;
11+
12+
namespace Microsoft.Azure.Commands.Batch.Test.Applications
13+
{
14+
public class NewBatchApplicationCommandTests : RMTestBase
15+
{
16+
private NewBatchApplicationCommand cmdlet;
17+
private Mock<BatchClient> batchClientMock;
18+
private Mock<ICommandRuntime> commandRuntimeMock;
19+
20+
public NewBatchApplicationCommandTests()
21+
{
22+
batchClientMock = new Mock<BatchClient>();
23+
commandRuntimeMock = new Mock<ICommandRuntime>();
24+
cmdlet = new NewBatchApplicationCommand()
25+
{
26+
CommandRuntime = commandRuntimeMock.Object,
27+
BatchClient = batchClientMock.Object
28+
};
29+
}
30+
31+
[Fact]
32+
[Trait(Category.AcceptanceType, Category.CheckIn)]
33+
public void AddBatchApplicationTest()
34+
{
35+
string accountName = "account01";
36+
string resourceGroup = "resourceGroup";
37+
string applicationId = "applicationId";
38+
string displayName = "displayName";
39+
40+
PSApplication expected = new PSApplication();
41+
42+
batchClientMock.Setup(b => b.AddApplication(resourceGroup, accountName, applicationId, true, displayName)).Returns(expected);
43+
44+
cmdlet.ResourceGroupName = resourceGroup;
45+
cmdlet.AccountName = accountName;
46+
cmdlet.ApplicationId = applicationId;
47+
cmdlet.AllowUpdates = true;
48+
cmdlet.DisplayName = displayName;
49+
50+
cmdlet.ExecuteCmdlet();
51+
52+
commandRuntimeMock.Verify(r => r.WriteObject(expected), Times.Once());
53+
}
54+
55+
[Fact]
56+
[Trait(Category.AcceptanceType, Category.CheckIn)]
57+
public void AddBatchApplicationTestWithoutAllowUpdates()
58+
{
59+
string accountName = "account01";
60+
string resourceGroup = "resourceGroup";
61+
string applicationId = "applicationId";
62+
string displayName = "displayName";
63+
64+
PSApplication expected = new PSApplication();
65+
66+
batchClientMock.Setup(b => b.AddApplication(resourceGroup, accountName, applicationId, null, displayName)).Returns(expected);
67+
68+
cmdlet.ResourceGroupName = resourceGroup;
69+
cmdlet.AccountName = accountName;
70+
cmdlet.ApplicationId = applicationId;
71+
72+
cmdlet.DisplayName = displayName;
73+
74+
cmdlet.ExecuteCmdlet();
75+
76+
commandRuntimeMock.Verify(r => r.WriteObject(expected), Times.Once());
77+
}
78+
}
79+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Management.Automation;
5+
using System.Text;
6+
using System.Threading.Tasks;
7+
8+
using Microsoft.Azure.Commands.Batch.Models;
9+
using Microsoft.WindowsAzure.Commands.ScenarioTest;
10+
11+
using Moq;
12+
13+
using Xunit;
14+
15+
namespace Microsoft.Azure.Commands.Batch.Test.Applications
16+
{
17+
public class NewBatchApplicationPackageCommandTests
18+
{
19+
private NewBatchApplicationPackageCommand cmdlet;
20+
private Mock<BatchClient> batchClientMock;
21+
private Mock<ICommandRuntime> commandRuntimeMock;
22+
23+
public NewBatchApplicationPackageCommandTests()
24+
{
25+
batchClientMock = new Mock<BatchClient>();
26+
commandRuntimeMock = new Mock<ICommandRuntime>();
27+
cmdlet = new NewBatchApplicationPackageCommand()
28+
{
29+
CommandRuntime = commandRuntimeMock.Object,
30+
BatchClient = batchClientMock.Object
31+
};
32+
}
33+
34+
[Fact]
35+
[Trait(Category.AcceptanceType, Category.CheckIn)]
36+
public void UploadBatchApplicationPackageTest()
37+
{
38+
string accountName = "account01";
39+
string resourceGroup = "resourceGroup";
40+
string applicationId = "applicationId";
41+
string filePath = "~/fake/filepath";
42+
string version = "version";
43+
string format = "zip";
44+
45+
PSApplicationPackage applicationPackageResponse = new PSApplicationPackage();
46+
47+
batchClientMock.Setup(b => b.UploadApplicationPackage(resourceGroup, accountName, applicationId, version, filePath, format, false)).Returns(applicationPackageResponse);
48+
49+
cmdlet.AccountName = accountName;
50+
cmdlet.ResourceGroupName = resourceGroup;
51+
cmdlet.ApplicationId = applicationId;
52+
cmdlet.FilePath = filePath;
53+
cmdlet.ApplicationVersion = version;
54+
cmdlet.Format = format;
55+
56+
57+
commandRuntimeMock.Setup(f => f.ShouldProcess(It.IsAny<string>(), It.IsAny<string>())).Returns(true);
58+
cmdlet.ExecuteCmdlet();
59+
60+
batchClientMock.Verify(b => b.UploadApplicationPackage(resourceGroup, accountName, applicationId, version, filePath, format, false), Times.Once());
61+
}
62+
63+
[Fact]
64+
[Trait(Category.AcceptanceType, Category.CheckIn)]
65+
public void ActivateApplicationPackage()
66+
{
67+
string accountName = "account01";
68+
string resourceGroup = "resourceGroup";
69+
string applicationId = "applicationId";
70+
string filePath = "~/fake/filepath";
71+
string version = "version";
72+
string format = "zip";
73+
74+
PSApplicationPackage applicationPackageResponse = new PSApplicationPackage();
75+
76+
batchClientMock.Setup(b => b.UploadApplicationPackage(resourceGroup, accountName, applicationId, version, filePath, format, true)).Returns(applicationPackageResponse);
77+
78+
cmdlet.AccountName = accountName;
79+
cmdlet.ResourceGroupName = resourceGroup;
80+
cmdlet.ApplicationId = applicationId;
81+
cmdlet.FilePath = filePath;
82+
cmdlet.ApplicationVersion = version;
83+
cmdlet.Format = format;
84+
cmdlet.ActivateOnly = true;
85+
86+
87+
commandRuntimeMock.Setup(f => f.ShouldProcess(It.IsAny<string>(), It.IsAny<string>())).Returns(true);
88+
cmdlet.ExecuteCmdlet();
89+
90+
batchClientMock.Verify(b => b.UploadApplicationPackage(resourceGroup, accountName, applicationId, version, filePath, format, true), Times.Once());
91+
}
92+
}
93+
}

0 commit comments

Comments
 (0)