|
| 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