Skip to content

Commit

Permalink
Merge pull request #39 from Azure/dev
Browse files Browse the repository at this point in the history
.
  • Loading branch information
huangpf committed Jul 7, 2015
2 parents 8d080eb + af8fdf9 commit 197c382
Show file tree
Hide file tree
Showing 118 changed files with 8,376 additions and 4,069 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<ProjectGuid>{59D1B5DC-9175-43EC-90C6-CBA601B3565F}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Microsoft.Azure.Commands.Automation.Test</RootNamespace>
<RootNamespace>Microsoft.Azure.Commands.ResourceManager.Automation.Test</RootNamespace>
<AssemblyName>Microsoft.Azure.Commands.ResourceManager.Automation.Test</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
Expand Down Expand Up @@ -111,13 +111,43 @@
</ItemGroup>
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="UnitTests\GetAzureAutomationCertificateTest.cs" />
<Compile Include="UnitTests\GetAzureAutomationConnectionTest.cs" />
<Compile Include="UnitTests\GetAzureAutomationCredentialTest.cs" />
<Compile Include="UnitTests\GetAzureAutomationJobTest.cs" />
<Compile Include="UnitTests\GetAzureAutomationRunbookTest.cs" />
<Compile Include="UnitTests\GetAzureAutomationScheduledRunbookTest.cs" />
<Compile Include="UnitTests\GetAzureAutomationScheduleTest.cs" />
<Compile Include="UnitTests\GetAzureAutomationVariableTest.cs" />
<Compile Include="UnitTests\GetAzureAutomationWebhookTest.cs" />
<Compile Include="UnitTests\NewAzureAutomationAccountTest.cs" />
<Compile Include="UnitTests\GetAzureAutomationAccountTest.cs" />
<Compile Include="UnitTests\NewAzureAutomationCertificateTest.cs" />
<Compile Include="UnitTests\NewAzureAutomationConnectionTest.cs" />
<Compile Include="UnitTests\NewAzureAutomationCredentialTest.cs" />
<Compile Include="UnitTests\NewAzureAutomationRunbookTest.cs" />
<Compile Include="UnitTests\NewAzureAutomationScheduleTest.cs" />
<Compile Include="UnitTests\NewAzureAutomationVariableTest.cs" />
<Compile Include="UnitTests\NewAzureAutomationWebhookTest.cs" />
<Compile Include="UnitTests\PublishAzureAutomationRunbookTest.cs" />
<Compile Include="UnitTests\RegisterAzureAutomationScheduledRunbookTest.cs" />
<Compile Include="UnitTests\RemoveAzureAutomationAccountTest.cs" />
<Compile Include="UnitTests\RemoveAzureAutomationCertificateTest.cs" />
<Compile Include="UnitTests\RemoveAzureAutomationConnectionTest.cs" />
<Compile Include="UnitTests\RemoveAzureAutomationModuleTest.cs" />
<Compile Include="UnitTests\RemoveAzureAutomationRunbookTest.cs" />
<Compile Include="UnitTests\RemoveAzureAutomationScheduleTest.cs" />
<Compile Include="UnitTests\RemoveAzureAutomationVariableTest.cs" />
<Compile Include="UnitTests\RemoveAzureAutomationWebhookTest.cs" />
<Compile Include="UnitTests\ResumeAzureAutomationJobTest.cs" />
<Compile Include="UnitTests\SetAzureAutomationCredentialTest.cs" />
<Compile Include="UnitTests\SetAzureAutomationRunbookTest.cs" />
<Compile Include="UnitTests\SetAzureAutomationScheduleTest.cs" />
<Compile Include="UnitTests\SetAzureAutomationWebhookTest.cs" />
<Compile Include="UnitTests\StartAzureAutomationRunbookTest.cs" />
<Compile Include="UnitTests\StopAzureAutomationJobTest.cs" />
<Compile Include="UnitTests\SuspendAzureAutomationJobTest.cs" />
<Compile Include="UnitTests\UnregisterAzureAutomationScheduledRunbookTest.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\Common\Commands.Common.Test\Commands.Common.Test.csproj">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
using Microsoft.WindowsAzure.Commands.Utilities.Common;
using Moq;

namespace Microsoft.Azure.Commands.Automation.Test.UnitTests
namespace Microsoft.Azure.Commands.ResourceManager.Automation.Test.UnitTests
{
[TestClass]
public class GetAzureAutomationAccountTest : TestBase
Expand Down Expand Up @@ -55,6 +55,7 @@ public void GetAzureAutomationAllAccountsSuccessfull()
this.mockAutomationClient.Setup(f => f.ListAutomationAccounts(resourceGroupName, ref nextLink)).Returns((string a, string b) => new List<AutomationAccount>());

// Test
this.cmdlet.ResourceGroupName = resourceGroupName;
this.cmdlet.ExecuteCmdlet();

// Assert
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
// ----------------------------------------------------------------------------------
//
// Copyright Microsoft Corporation
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// ----------------------------------------------------------------------------------

using System;
using System.Collections.Generic;
using Microsoft.Azure.Commands.Automation.Cmdlet;
using Microsoft.Azure.Commands.Automation.Common;
using Microsoft.Azure.Commands.Automation.Model;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Microsoft.WindowsAzure.Commands.Common.Test.Mocks;
using Microsoft.WindowsAzure.Commands.Test.Utilities.Common;
using Microsoft.WindowsAzure.Commands.Utilities.Common;
using Moq;

namespace Microsoft.Azure.Commands.ResourceManager.Automation.Test.UnitTests
{
[TestClass]
public class GetAzureAutomationCertificateTest : TestBase
{
private Mock<IAutomationClient> mockAutomationClient;

private MockCommandRuntime mockCommandRuntime;

private GetAzureAutomationCertificate cmdlet;

[TestInitialize]
public void SetupTest()
{
this.mockAutomationClient = new Mock<IAutomationClient>();
this.mockCommandRuntime = new MockCommandRuntime();
this.cmdlet = new GetAzureAutomationCertificate
{
AutomationClient = this.mockAutomationClient.Object,
CommandRuntime = this.mockCommandRuntime
};
}

[TestMethod]
public void GetAzureAutomationCertificateByNameSuccessfull()
{
// Setup
string resourceGroupName = "resourceGroup";
string accountName = "automation";
string certificateName = "certificate";

this.mockAutomationClient.Setup(f => f.GetCertificate(resourceGroupName, accountName, certificateName));

// Test
this.cmdlet.ResourceGroupName = resourceGroupName;
this.cmdlet.AutomationAccountName = accountName;
this.cmdlet.Name = certificateName;
this.cmdlet.SetParameterSet("ByCertificateName");
this.cmdlet.ExecuteCmdlet();

// Assert
this.mockAutomationClient.Verify(f => f.GetCertificate(resourceGroupName, accountName, certificateName), Times.Once());
}

[TestMethod]
public void GetAzureAutomationCertificateByAllSuccessfull()
{
// Setup
string resourceGroupName = "resourceGroup";
string accountName = "automation";
string nextLink = string.Empty;

this.mockAutomationClient.Setup(f => f.ListCertificates(resourceGroupName, accountName, ref nextLink)).Returns((string a, string b, string c) => new List<CertificateInfo>());

// Test
this.cmdlet.ResourceGroupName = resourceGroupName;
this.cmdlet.AutomationAccountName = accountName;
this.cmdlet.ExecuteCmdlet();

// Assert
this.mockAutomationClient.Verify(f => f.ListCertificates(resourceGroupName, accountName, ref nextLink), Times.Once());
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
// ----------------------------------------------------------------------------------
//
// Copyright Microsoft Corporation
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// ----------------------------------------------------------------------------------

using System;
using System.Collections.Generic;
using Microsoft.Azure.Commands.Automation.Cmdlet;
using Microsoft.Azure.Commands.Automation.Common;
using Microsoft.Azure.Commands.Automation.Model;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Microsoft.WindowsAzure.Commands.Common.Test.Mocks;
using Microsoft.WindowsAzure.Commands.Test.Utilities.Common;
using Microsoft.WindowsAzure.Commands.Utilities.Common;
using Moq;

namespace Microsoft.Azure.Commands.ResourceManager.Automation.Test.UnitTests
{
[TestClass]
public class GetAzureAutomationConnectionTest : TestBase
{
private Mock<IAutomationClient> mockAutomationClient;

private MockCommandRuntime mockCommandRuntime;

private GetAzureAutomationConnection cmdlet;

[TestInitialize]
public void SetupTest()
{
this.mockAutomationClient = new Mock<IAutomationClient>();
this.mockCommandRuntime = new MockCommandRuntime();
this.cmdlet = new GetAzureAutomationConnection
{
AutomationClient = this.mockAutomationClient.Object,
CommandRuntime = this.mockCommandRuntime
};
}

[TestMethod]
public void GetAzureAutomationConnectionByNameSuccessfull()
{
// Setup
string resourceGroupName = "resourceGroup";
string accountName = "automation";
string connectionName = "connection";

this.mockAutomationClient.Setup(f => f.GetConnection(resourceGroupName, accountName, connectionName));

// Test
this.cmdlet.ResourceGroupName = resourceGroupName;
this.cmdlet.AutomationAccountName = accountName;
this.cmdlet.Name = connectionName;
this.cmdlet.SetParameterSet("ByConnectionName");
this.cmdlet.ExecuteCmdlet();

// Assert
this.mockAutomationClient.Verify(f => f.GetConnection(resourceGroupName, accountName, connectionName), Times.Once());
}

[TestMethod]
public void GetAzureAutomationConnectionByAllSuccessfull()
{
// Setup
string resourceGroupName = "resourceGroup";
string accountName = "automation";
string nextLink = string.Empty;

this.mockAutomationClient.Setup(f => f.ListConnections(resourceGroupName, accountName, ref nextLink)).Returns((string a, string b, string c) => new List<Connection>());

// Test
this.cmdlet.ResourceGroupName = resourceGroupName;
this.cmdlet.AutomationAccountName = accountName;
this.cmdlet.ExecuteCmdlet();

// Assert
this.mockAutomationClient.Verify(f => f.ListConnections(resourceGroupName, accountName, ref nextLink), Times.Once());
}

[TestMethod]
public void GetAzureAutomationConnectionByTypeSuccessfull()
{
// Setup
string resourceGroupName = "resourceGroup";
string accountName = "automation";
string connectionTypeName = "connectionType";

this.mockAutomationClient.Setup(f => f.ListConnectionsByType(resourceGroupName, accountName, connectionTypeName)).Returns((string a, string b, string c) => new List<Connection>());

// Test
this.cmdlet.ResourceGroupName = resourceGroupName;
this.cmdlet.AutomationAccountName = accountName;
this.cmdlet.ConnectionTypeName = connectionTypeName;
this.cmdlet.SetParameterSet("ByConnectionTypeName");
this.cmdlet.ExecuteCmdlet();

// Assert
this.mockAutomationClient.Verify(f => f.ListConnectionsByType(resourceGroupName, accountName, connectionTypeName), Times.Once());
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
// ----------------------------------------------------------------------------------
//
// Copyright Microsoft Corporation
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// ----------------------------------------------------------------------------------

using System;
using System.Collections.Generic;
using Microsoft.Azure.Commands.Automation.Cmdlet;
using Microsoft.Azure.Commands.Automation.Common;
using Microsoft.Azure.Commands.Automation.Model;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Microsoft.WindowsAzure.Commands.Common.Test.Mocks;
using Microsoft.WindowsAzure.Commands.Test.Utilities.Common;
using Moq;

namespace Microsoft.Azure.Commands.ResourceManager.Automation.Test.UnitTests
{
[TestClass]
public class GetAzureAutomationCredentialTest : TestBase
{
private Mock<IAutomationClient> mockAutomationClient;

private MockCommandRuntime mockCommandRuntime;

private GetAzureAutomationCredential cmdlet;

[TestInitialize]
public void SetupTest()
{
this.mockAutomationClient = new Mock<IAutomationClient>();
this.mockCommandRuntime = new MockCommandRuntime();
this.cmdlet = new GetAzureAutomationCredential
{
AutomationClient = this.mockAutomationClient.Object,
CommandRuntime = this.mockCommandRuntime
};
}

[TestMethod]
public void GetAzureAutomationCredentialByNameSuccessfull()
{
// Setup
string resourceGroupName = "resourceGroup";
string accountName = "automation";
string credentialName = "credential";

this.mockAutomationClient.Setup(f => f.GetCredential(resourceGroupName, accountName, credentialName));

// Test
this.cmdlet.ResourceGroupName = resourceGroupName;
this.cmdlet.AutomationAccountName = accountName;
this.cmdlet.Name = credentialName;
this.cmdlet.ExecuteCmdlet();

// Assert
this.mockAutomationClient.Verify(f => f.GetCredential(resourceGroupName, accountName, credentialName), Times.Once());
}

[TestMethod]
public void GetAzureAutomationCredentialByAllSuccessfull()
{
// Setup
string resourceGroupName = "resourceGroup";
string accountName = "automation";
string nextLink = string.Empty;

this.mockAutomationClient.Setup(f => f.ListCredentials(resourceGroupName, accountName, ref nextLink)).Returns((string a, string b, string c) => new List<CredentialInfo>());

// Test
this.cmdlet.ResourceGroupName = resourceGroupName;
this.cmdlet.AutomationAccountName = accountName;
this.cmdlet.ExecuteCmdlet();

// Assert
this.mockAutomationClient.Verify(f => f.ListCredentials(resourceGroupName, accountName, ref nextLink), Times.Once());
}
}
}
Loading

0 comments on commit 197c382

Please sign in to comment.