Skip to content

Commit 4aa91b2

Browse files
Added tests
1 parent 0d87453 commit 4aa91b2

File tree

2 files changed

+70
-0
lines changed

2 files changed

+70
-0
lines changed

src/ResourceManager/Automation/Commands.Automation.Test/Commands.Automation.Test.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@
138138
<Compile Include="UnitTests\GetAzureAutomationCertificateTest.cs" />
139139
<Compile Include="UnitTests\GetAzureAutomationConnectionTest.cs" />
140140
<Compile Include="UnitTests\GetAzureAutomationCredentialTest.cs" />
141+
<Compile Include="UnitTests\GetAzureAutomationJobOutputRecord.cs" />
141142
<Compile Include="UnitTests\GetAzureAutomationJobTest.cs" />
142143
<Compile Include="UnitTests\GetAzureAutomationRunbookTest.cs" />
143144
<Compile Include="UnitTests\GetAzureAutomationScheduledRunbookTest.cs" />
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
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+
using Microsoft.Azure.Commands.Automation.Cmdlet;
17+
using Microsoft.Azure.Commands.Automation.Common;
18+
using Microsoft.VisualStudio.TestTools.UnitTesting;
19+
using Microsoft.WindowsAzure.Commands.Common.Test.Mocks;
20+
using Microsoft.WindowsAzure.Commands.ScenarioTest;
21+
using Microsoft.WindowsAzure.Commands.Test.Utilities.Common;
22+
using Moq;
23+
24+
namespace Microsoft.Azure.Commands.ResourceManager.Automation.Test.UnitTests
25+
{
26+
[TestClass]
27+
public class GetAzureAutomationJobOutputRecordTest : RMTestBase
28+
{
29+
private Mock<IAutomationClient> mockAutomationClient;
30+
31+
private MockCommandRuntime mockCommandRuntime;
32+
33+
private GetAzureAutomationJobOutputRecord cmdlet;
34+
35+
[TestInitialize]
36+
public void SetupTest()
37+
{
38+
this.mockAutomationClient = new Mock<IAutomationClient>();
39+
this.mockCommandRuntime = new MockCommandRuntime();
40+
this.cmdlet = new GetAzureAutomationJobOutputRecord
41+
{
42+
AutomationClient = this.mockAutomationClient.Object,
43+
CommandRuntime = this.mockCommandRuntime
44+
};
45+
}
46+
47+
[TestMethod]
48+
public void GetAzureAutomationJobByRunbookNameSuccessfull()
49+
{
50+
// Setup
51+
string resourceGroupName = "resourceGroup";
52+
string accountName = "automation";
53+
Guid jobId = Guid.NewGuid();
54+
string id = Guid.NewGuid().ToString();
55+
56+
this.mockAutomationClient.Setup(f => f.GetJobStreamRecord(resourceGroupName, accountName, jobId, id));
57+
58+
// Test
59+
this.cmdlet.ResourceGroupName = resourceGroupName;
60+
this.cmdlet.AutomationAccountName = accountName;
61+
this.cmdlet.JobId = jobId;
62+
this.cmdlet.Id = id;
63+
this.cmdlet.ExecuteCmdlet();
64+
65+
// Assert
66+
this.mockAutomationClient.Verify(f => f.GetJobStreamRecord(resourceGroupName, accountName, jobId, id), Times.Once());
67+
}
68+
}
69+
}

0 commit comments

Comments
 (0)