From 535f6d1a8461f0d72e37352931cdb816cb36ea76 Mon Sep 17 00:00:00 2001 From: mkherani Date: Wed, 17 Jun 2015 18:18:54 +0530 Subject: [PATCH] Added powershell test cases for registration --- src/AzurePowershell.sln | 9 ++++- .../Commands.AzureBackup.Test.csproj | 8 ++-- .../ContainerTest/AzureBackupContainerTest.cs | 34 ++++++++++++++++ .../AzureBackupContainerTest.ps1 | 39 +++++++++++++++++++ .../Container/RegisterAzureBackupContainer.cs | 2 - .../UnregisterAzureBackupContainer.cs | 2 - .../Commands.AzureBackup.csproj | 8 ++-- 7 files changed, 91 insertions(+), 11 deletions(-) create mode 100644 src/ResourceManager/AzureBackup/Commands.AzureBackup.Test/ScenarioTests/ContainerTest/AzureBackupContainerTest.cs create mode 100644 src/ResourceManager/AzureBackup/Commands.AzureBackup.Test/ScenarioTests/ContainerTest/AzureBackupContainerTest.ps1 diff --git a/src/AzurePowershell.sln b/src/AzurePowershell.sln index 598c91723ee5..08402fcbf94b 100644 --- a/src/AzurePowershell.sln +++ b/src/AzurePowershell.sln @@ -1,5 +1,5 @@ Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Express 2013 for Web +# Visual Studio 2013 VisualStudioVersion = 12.0.31101.0 MinimumVisualStudioVersion = 10.0.40219.1 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{8531411A-0137-4E27-9C5E-49E07C245048}" @@ -212,6 +212,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Commands.ApiManagement.Test EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Commands.AzureBackup", "ResourceManager\AzureBackup\Commands.AzureBackup\Commands.AzureBackup.csproj", "{6C8D2337-C9D1-4F52-94B3-AB63A19F3453}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Commands.AzureBackup.Test", "ResourceManager\AzureBackup\Commands.AzureBackup.Test\Commands.AzureBackup.Test.csproj", "{678AE95D-2364-47D7-888C-3FFA6D412CC8}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -518,6 +520,10 @@ Global {6C8D2337-C9D1-4F52-94B3-AB63A19F3453}.Debug|Any CPU.Build.0 = Debug|Any CPU {6C8D2337-C9D1-4F52-94B3-AB63A19F3453}.Release|Any CPU.ActiveCfg = Release|Any CPU {6C8D2337-C9D1-4F52-94B3-AB63A19F3453}.Release|Any CPU.Build.0 = Release|Any CPU + {678AE95D-2364-47D7-888C-3FFA6D412CC8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {678AE95D-2364-47D7-888C-3FFA6D412CC8}.Debug|Any CPU.Build.0 = Debug|Any CPU + {678AE95D-2364-47D7-888C-3FFA6D412CC8}.Release|Any CPU.ActiveCfg = Release|Any CPU + {678AE95D-2364-47D7-888C-3FFA6D412CC8}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -559,5 +565,6 @@ Global {5764A3A4-586C-4536-8481-13007CAC111B} = {95C16AED-FD57-42A0-86C3-2CF4300A4817} {59D1B5DC-9175-43EC-90C6-CBA601B3565F} = {95C16AED-FD57-42A0-86C3-2CF4300A4817} {BEC9ECE9-A3D6-4B24-A682-1FA890647D9D} = {95C16AED-FD57-42A0-86C3-2CF4300A4817} + {678AE95D-2364-47D7-888C-3FFA6D412CC8} = {95C16AED-FD57-42A0-86C3-2CF4300A4817} EndGlobalSection EndGlobal diff --git a/src/ResourceManager/AzureBackup/Commands.AzureBackup.Test/Commands.AzureBackup.Test.csproj b/src/ResourceManager/AzureBackup/Commands.AzureBackup.Test/Commands.AzureBackup.Test.csproj index 2ada66c08d88..a2052acae503 100644 --- a/src/ResourceManager/AzureBackup/Commands.AzureBackup.Test/Commands.AzureBackup.Test.csproj +++ b/src/ResourceManager/AzureBackup/Commands.AzureBackup.Test/Commands.AzureBackup.Test.csproj @@ -39,6 +39,9 @@ False ..\..\..\packages\Microsoft.Azure.Common.Authentication.1.0.25-preview\lib\net45\Microsoft.Azure.Common.Authentication.dll + + ..\..\..\..\..\azure-sdk-for-net\src\ResourceManagement\AzureBackup\BackupServicesManagment\bin\Net45-Debug\Microsoft.Azure.Management.BackupServicesManagment.dll + False ..\..\..\packages\Microsoft.Azure.Management.Resources.2.18.0-preview\lib\net40\Microsoft.Azure.ResourceManager.dll @@ -80,9 +83,6 @@ ..\..\..\packages\Microsoft.WindowsAzure.Management.4.1.1\lib\net40\Microsoft.WindowsAzure.Management.dll - - ..\..\..\..\..\azure-sdk-for-net\src\ResourceManagement\AzureBackup\BackupServicesManagment\bin\Net45-Release\Microsoft.WindowsAzure.Management.BackupServicesManagment.dll - False ..\..\..\packages\Hydra.SpecTestSupport.1.0.5417.13285-prerelease\lib\net45\Microsoft.WindowsAzure.Testing.dll @@ -129,6 +129,7 @@ + @@ -167,6 +168,7 @@ Always + Always diff --git a/src/ResourceManager/AzureBackup/Commands.AzureBackup.Test/ScenarioTests/ContainerTest/AzureBackupContainerTest.cs b/src/ResourceManager/AzureBackup/Commands.AzureBackup.Test/ScenarioTests/ContainerTest/AzureBackupContainerTest.cs new file mode 100644 index 000000000000..98f8572f2e74 --- /dev/null +++ b/src/ResourceManager/AzureBackup/Commands.AzureBackup.Test/ScenarioTests/ContainerTest/AzureBackupContainerTest.cs @@ -0,0 +1,34 @@ +// ---------------------------------------------------------------------------------- +// +// 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 Microsoft.WindowsAzure.Commands.ScenarioTest; +using Xunit; + +namespace Microsoft.Azure.Commands.AzureBackup.Test.ScenarioTests +{ + public class AzureBackupContainerTest : AzureBackupTestsBase + { + [Fact] + public void RegisterAzureBackupContainerTest() + { + this.RunPowerShellTest("Test-RegisterAzureBackupContainer"); + } + + [Fact] + public void UnregisterAzureBackupContainerTest() + { + this.RunPowerShellTest("Test-UnregisterAzureBackupContainer"); + } + } +} diff --git a/src/ResourceManager/AzureBackup/Commands.AzureBackup.Test/ScenarioTests/ContainerTest/AzureBackupContainerTest.ps1 b/src/ResourceManager/AzureBackup/Commands.AzureBackup.Test/ScenarioTests/ContainerTest/AzureBackupContainerTest.ps1 new file mode 100644 index 000000000000..bb2c01db7921 --- /dev/null +++ b/src/ResourceManager/AzureBackup/Commands.AzureBackup.Test/ScenarioTests/ContainerTest/AzureBackupContainerTest.ps1 @@ -0,0 +1,39 @@ +# ---------------------------------------------------------------------------------- +# +# 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. +# ---------------------------------------------------------------------------------- + +$ResourceGroupName = "backuprg" +$ResourceName = "backuprn" +$Name = "dev01testing" +$VMServiceName = "dev01testing" +$ContainerType = "IaasVMContainer" +$Location = "westus" + +<# +.SYNOPSIS +Tests to register the container +#> +function Test-RegisterAzureBackupContainer +{ + $jobId = Register-AzureBackupContainer -ResourceGroupName $ResourceGroupName -ResourceName $ResourceName -location $Location -Name $VMName -ServiceName $VMServiceName + + Assert-NotNull $jobId 'JobID should not be null'; +} + +function Test-UnregisterAzureBackupContainer +{ + $container = Get-AzureBackupContainer -ResourceGroupName $ResourceGroupName -ResourceName $ResourceName -location $Location -ContainerResourceName $VMName -ContainerResourceGroupName $VMServiceName + $jobId = Unregister-AzureBackupContainer -ResourceGroupName $ResourceGroupName -ResourceName $ResourceName -location $Location -AzureBackupContainer $container + + Assert-NotNull $jobId 'JobID should not be null'; +} \ No newline at end of file diff --git a/src/ResourceManager/AzureBackup/Commands.AzureBackup/Cmdlets/Container/RegisterAzureBackupContainer.cs b/src/ResourceManager/AzureBackup/Commands.AzureBackup/Cmdlets/Container/RegisterAzureBackupContainer.cs index e6352835df05..8e05f25313a9 100644 --- a/src/ResourceManager/AzureBackup/Commands.AzureBackup/Cmdlets/Container/RegisterAzureBackupContainer.cs +++ b/src/ResourceManager/AzureBackup/Commands.AzureBackup/Cmdlets/Container/RegisterAzureBackupContainer.cs @@ -20,10 +20,8 @@ using System.Management.Automation; using System.Text; using System.Threading.Tasks; -using Microsoft.Azure.Commands.Compute; using Microsoft.Azure.Management.BackupServices.Models; using MBS = Microsoft.Azure.Management.BackupServices; -using Microsoft.Azure.Commands.Compute.Models; using Microsoft.WindowsAzure.Commands.ServiceManagement.Model; namespace Microsoft.Azure.Commands.AzureBackup.Cmdlets diff --git a/src/ResourceManager/AzureBackup/Commands.AzureBackup/Cmdlets/Container/UnregisterAzureBackupContainer.cs b/src/ResourceManager/AzureBackup/Commands.AzureBackup/Cmdlets/Container/UnregisterAzureBackupContainer.cs index 65004e79333a..33fd22499d9c 100644 --- a/src/ResourceManager/AzureBackup/Commands.AzureBackup/Cmdlets/Container/UnregisterAzureBackupContainer.cs +++ b/src/ResourceManager/AzureBackup/Commands.AzureBackup/Cmdlets/Container/UnregisterAzureBackupContainer.cs @@ -20,10 +20,8 @@ using System.Management.Automation; using System.Text; using System.Threading.Tasks; -using Microsoft.Azure.Commands.Compute; using Microsoft.Azure.Management.BackupServices.Models; using MBS = Microsoft.Azure.Management.BackupServices; -using Microsoft.Azure.Commands.Compute.Models; namespace Microsoft.Azure.Commands.AzureBackup.Cmdlets { diff --git a/src/ResourceManager/AzureBackup/Commands.AzureBackup/Commands.AzureBackup.csproj b/src/ResourceManager/AzureBackup/Commands.AzureBackup/Commands.AzureBackup.csproj index 011a856d1091..6b71dcb49e9f 100644 --- a/src/ResourceManager/AzureBackup/Commands.AzureBackup/Commands.AzureBackup.csproj +++ b/src/ResourceManager/AzureBackup/Commands.AzureBackup/Commands.AzureBackup.csproj @@ -65,6 +65,9 @@ ..\..\..\packages\Microsoft.Azure.Common.2.1.0\lib\net45\Microsoft.Azure.Common.NetFramework.dll + + ..\..\..\..\..\azure-sdk-for-net\src\ResourceManagement\AzureBackup\BackupServicesManagment\bin\Net45-Debug\Microsoft.Azure.Management.BackupServicesManagment.dll + ..\..\..\packages\Microsoft.Azure.Management.Resources.2.18.0-preview\lib\net40\Microsoft.Azure.ResourceManager.dll @@ -86,9 +89,6 @@ ..\..\..\packages\Microsoft.WindowsAzure.Management.4.1.1\lib\net40\Microsoft.WindowsAzure.Management.dll - - ..\..\..\..\..\..\azure-sdk-for-net\src\ResourceManagement\AzureBackup\BackupServicesManagment\bin\Net40-Debug\Microsoft.WindowsAzure.Management.BackupServicesManagment.dll - False Cmdlets\VaultCredentials\Microsoft.WindowsAzure.Management.Common.dll @@ -134,6 +134,8 @@ + +