Skip to content

Commit c7d31c7

Browse files
committed
Policy Test Cases
1 parent fa9ece2 commit c7d31c7

File tree

4 files changed

+155
-48
lines changed

4 files changed

+155
-48
lines changed

src/ResourceManager/AzureBackup/Commands.AzureBackup.Test/Commands.AzureBackup.Test.csproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@
3535
<WarningLevel>4</WarningLevel>
3636
</PropertyGroup>
3737
<ItemGroup>
38+
<Reference Include="Microsoft.Azure.Commands.AzureBackup">
39+
<HintPath>..\..\..\Package\Debug\ResourceManager\AzureResourceManager\AzureBackup\Microsoft.Azure.Commands.AzureBackup.dll</HintPath>
40+
</Reference>
3841
<Reference Include="Microsoft.Azure.Common.Authentication, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
3942
<SpecificVersion>False</SpecificVersion>
4043
<HintPath>..\..\..\packages\Microsoft.Azure.Common.Authentication.1.0.25-preview\lib\net45\Microsoft.Azure.Common.Authentication.dll</HintPath>

src/ResourceManager/AzureBackup/Commands.AzureBackup.Test/ScenarioTests/AzureBackupTests.cs renamed to src/ResourceManager/AzureBackup/Commands.AzureBackup.Test/ScenarioTests/AzureBackupPolicyTests.cs

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,38 @@
1717

1818
namespace Microsoft.Azure.Commands.AzureBackup.Test.ScenarioTests
1919
{
20-
public class AzureBackupTests : AzureBackupTestsBase
20+
public class AzureBackupPolicyTests : AzureBackupTestsBase
2121
{
2222
[Fact]
2323
public void ListProtectionPolicyTests()
2424
{
2525
this.RunPowerShellTest("Test-GetAzureBackupProtectionPolicyTests");
2626
}
27+
28+
[Fact]
29+
public void NewProtectionPolicyTests()
30+
{
31+
this.RunPowerShellTest("Test-NewAzureBackupProtectionPolicyTests");
32+
}
33+
34+
[Fact]
35+
public void ListProtectionPolicyByNameTests()
36+
{
37+
this.RunPowerShellTest("Test-GetAzureBackupProtectionPolicyByNameTests");
38+
}
39+
40+
[Fact]
41+
public void SetProtectionPolicyTests()
42+
{
43+
this.RunPowerShellTest("Test-SetAzureBackupProtectionPolicyTests");
44+
}
45+
46+
[Fact]
47+
public void RemoveProtectionPolicyTests()
48+
{
49+
this.RunPowerShellTest("Test-RemoveAzureBackupProtectionPolicyTests");
50+
}
51+
52+
2753
}
2854
}
Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
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+
$ResourceGroupName = "backuprg"
16+
$ResourceName = "backuprn"
17+
$DataSourceType = "VM"
18+
$Location = "SouthEast Asia"
19+
$PolicyName = "Policy9";
20+
$PolicyId = "c87bbada-6e1b-4db2-b76c-9062d28959a4";
21+
$POName = "iaasvmcontainer;dev01testing;dev01testing"
22+
$WorkloadType = "VM"
23+
$RetentionType = "Days"
24+
$ScheduleRunTimes = "2015-06-13T20:30:00"
25+
$ScheduleRunDays = "Monday"
26+
$RetentionDuration = 30
27+
$BackupType = "Full"
28+
$ScheduleType = "Daily"
29+
30+
<#
31+
.SYNOPSIS
32+
Tests creating new resource group and a simple resource.
33+
#>
34+
function Test-GetAzureBackupProtectionPolicyTests
35+
{
36+
$protectionPolicies = Get-AzureBackupProtectionPolicy -ResourceGroupName $ResourceGroupName -ResourceName $ResourceName -Location $Location
37+
Assert-NotNull $protectionPolicies 'Protection Policies should not be null'
38+
foreach($protectionPolicy in $protectionPolicies)
39+
{
40+
Assert-NotNull $protectionPolicy.InstanceId 'InstanceId should not be null'
41+
Assert-NotNull $protectionPolicy.Name 'Name should not be null'
42+
Assert-NotNull $protectionPolicy.WorkloadType 'WorkloadType should not be null'
43+
Assert-NotNull $protectionPolicy.BackupType 'BackupType should not be null'
44+
Assert-NotNull $protectionPolicy.ScheduleRunTimes 'ScheduleRunTimes should not be null'
45+
Assert-NotNull $protectionPolicy.RetentionDuration 'RetentionDuration should not be null'
46+
Assert-NotNull $protectionPolicy.ResourceGroupName 'ResourceGroupName should not be null'
47+
Assert-NotNull $protectionPolicy.ResourceName 'ResourceName should not be null'
48+
Assert-NotNull $protectionPolicy.Location 'Location should not be null'
49+
}
50+
}
51+
52+
function Test-GetAzureBackupProtectionPolicyByNameTests
53+
{
54+
$protectionPolicy = Get-AzureBackupProtectionPolicy -ResourceGroupName $ResourceGroupName -ResourceName $ResourceName -Location $Location -Name $PolicyName
55+
56+
Assert-NotNull $protectionPolicy.InstanceId 'InstanceId should not be null'
57+
Assert-NotNull $protectionPolicy.Name 'Name should not be null'
58+
Assert-NotNull $protectionPolicy.WorkloadType 'WorkloadType should not be null'
59+
Assert-NotNull $protectionPolicy.BackupType 'BackupType should not be null'
60+
Assert-NotNull $protectionPolicy.ScheduleRunTimes 'ScheduleRunTimes should not be null'
61+
Assert-NotNull $protectionPolicy.RetentionDuration 'RetentionDuration should not be null'
62+
Assert-NotNull $protectionPolicy.ResourceGroupName 'ResourceGroupName should not be null'
63+
Assert-NotNull $protectionPolicy.ResourceName 'ResourceName should not be null'
64+
Assert-NotNull $protectionPolicy.Location 'Location should not be null'
65+
66+
}
67+
68+
function Test-NewAzureBackupProtectionPolicyTests
69+
{
70+
$protectionPolicy = New-AzureBackupProtectionPolicy -Name $PolicyName -WorkloadType $WorkloadType -BackupType $BackupType -Daily -RetentionType $RetentionType -RetentionDuration $RetentionDuration -ScheduleRunTimes $ScheduleRunTimes -ResourceGroupName $ResourceGroupName -ResourceName $ResourceName -Location $Location
71+
72+
Assert-NotNull $protectionPolicy.InstanceId 'InstanceId should not be null'
73+
Assert-NotNull $protectionPolicy.Name 'Name should not be null'
74+
Assert-NotNull $protectionPolicy.WorkloadType 'WorkloadType should not be null'
75+
Assert-NotNull $protectionPolicy.BackupType 'BackupType should not be null'
76+
Assert-NotNull $protectionPolicy.ScheduleRunTimes 'ScheduleRunTimes should not be null'
77+
Assert-NotNull $protectionPolicy.RetentionDuration 'RetentionDuration should not be null'
78+
Assert-NotNull $protectionPolicy.ResourceGroupName 'ResourceGroupName should not be null'
79+
Assert-NotNull $protectionPolicy.ResourceName 'ResourceName should not be null'
80+
Assert-NotNull $protectionPolicy.Location 'Location should not be null'
81+
}
82+
83+
function Test-SetAzureBackupProtectionPolicyTests
84+
{
85+
$policy = New-Object Microsoft.Azure.Commands.AzureBackup.Cmdlets.AzureBackupProtectionPolicy
86+
$policy.InstanceId = $PolicyId
87+
$policy.Name = $PolicyName
88+
$policy.ResourceGroupName = $ResourceGroupName
89+
$policy.ResourceName = $ResourceName
90+
$policy.Location = $Location
91+
$policy.WorkloadType = $WorkloadType
92+
$policy.RetentionType = $RetentionType
93+
$policy.ScheduleRunTimes = $ScheduleRunTimes
94+
$policy.ScheduleType = $ScheduleType
95+
$policyNewName = "policy09_new"
96+
97+
$protectionPolicy = New-AzureBackupProtectionPolicy -ProtectionPolicy $policy -NewName $policyNewName
98+
99+
Assert-NotNull $protectionPolicy.InstanceId 'InstanceId should not be null'
100+
Assert-NotNull $protectionPolicy.Name 'Name should not be null'
101+
Assert-NotNull $protectionPolicy.WorkloadType 'WorkloadType should not be null'
102+
Assert-NotNull $protectionPolicy.BackupType 'BackupType should not be null'
103+
Assert-NotNull $protectionPolicy.ScheduleRunTimes 'ScheduleRunTimes should not be null'
104+
Assert-NotNull $protectionPolicy.RetentionDuration 'RetentionDuration should not be null'
105+
Assert-NotNull $protectionPolicy.ResourceGroupName 'ResourceGroupName should not be null'
106+
Assert-NotNull $protectionPolicy.ResourceName 'ResourceName should not be null'
107+
Assert-NotNull $protectionPolicy.Location 'Location should not be null'
108+
}
109+
110+
function Test-RemoveAzureBackupProtectionPolicyTests
111+
{
112+
$policyNewName = "policy09_new"
113+
$policy = New-Object Microsoft.Azure.Commands.AzureBackup.Cmdlets.AzureBackupProtectionPolicy
114+
$policy.InstanceId = $PolicyId
115+
$policy.Name = $policyNewName
116+
$policy.ResourceGroupName = $ResourceGroupName
117+
$policy.ResourceName = $ResourceName
118+
$policy.Location = $Location
119+
$policy.WorkloadType = $WorkloadType
120+
$policy.RetentionType = $RetentionType
121+
$policy.ScheduleRunTimes = $ScheduleRunTimes
122+
$policy.ScheduleType = $ScheduleType
123+
124+
Remove-AzureBackupProtectionPolicy -ProtectionPolicy $policy
125+
}

src/ResourceManager/AzureBackup/Commands.AzureBackup.Test/ScenarioTests/AzureBackupTests.ps1

Lines changed: 0 additions & 47 deletions
This file was deleted.

0 commit comments

Comments
 (0)