Skip to content

Commit 2f90a56

Browse files
committed
unit testing fixes for policy
1 parent 530d150 commit 2f90a56

File tree

5 files changed

+15
-9
lines changed

5 files changed

+15
-9
lines changed

src/ResourceManager/RecoveryServices.Backup/Cmdlets/ProtectionPolicy/GetAzureRmRecoveryServicesBackupRetentionPolicyObject.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
namespace Microsoft.Azure.Commands.RecoveryServices.Backup.Cmdlets
2525
{
2626
[Cmdlet(VerbsCommon.Get, "AzureRmRecoveryServicesBackupRetentionPolicyObject"), OutputType(typeof(AzureRmRecoveryServicesRetentionPolicyBase))]
27-
class GetAzureRmRecoveryServicesBackupRetentionPolicyObject : RecoveryServicesBackupCmdletBase
27+
public class GetAzureRmRecoveryServicesBackupRetentionPolicyObject : RecoveryServicesBackupCmdletBase
2828
{
2929
[Parameter(Mandatory = true, HelpMessage = "Temp Help message. Need to update it")]
3030
[ValidateNotNullOrEmpty]

src/ResourceManager/RecoveryServices.Backup/Cmdlets/ProtectionPolicy/GetAzureRmRecoveryServicesSchedulePolicyObject.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
namespace Microsoft.Azure.Commands.RecoveryServices.Backup.Cmdlets
2525
{
2626
[Cmdlet(VerbsCommon.Get, "AzureRmRecoveryServicesSchedulePolicyObject"), OutputType(typeof(AzureRmRecoveryServicesSchedulePolicyBase))]
27-
class GetAzureRmRecoveryServicesSchedulePolicyObject : RecoveryServicesBackupCmdletBase
27+
public class GetAzureRmRecoveryServicesSchedulePolicyObject : RecoveryServicesBackupCmdletBase
2828
{
2929
[Parameter(Mandatory = true, HelpMessage = "Temp Help message. Need to update it")]
3030
[ValidateNotNullOrEmpty]

src/ResourceManager/RecoveryServices.Backup/Commands.RecoveryServices.Backup.Helpers/Conversions/RetentionPolicyConversions.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -419,8 +419,7 @@ private static HydraModels.MonthlyRetentionSchedule GetHydraLTRMonthlySchedule(M
419419
};
420420
hydraMonthly.RetentionTimes = psMonthly.RetentionTimes;
421421

422-
hydraMonthly.RetentionScheduleFormatType = Enum.Parse(typeof(HydraModels.RetentionScheduleFormat),
423-
psMonthly.RetentionScheduleFormatType.ToString()).ToString();
422+
hydraMonthly.RetentionScheduleFormatType = psMonthly.RetentionScheduleFormatType.ToString();
424423
if (psMonthly.RetentionScheduleFormatType == RetentionScheduleFormat.Daily)
425424
{
426425
hydraMonthly.RetentionScheduleDaily = GetHydraLTRDailyRetentionFormat(psMonthly.RetentionScheduleDaily);
@@ -449,8 +448,7 @@ private static HydraModels.YearlyRetentionSchedule GetHydraLTRYearlySchedule(Yea
449448
};
450449
hydraYearly.RetentionTimes = psYearly.RetentionTimes;
451450

452-
hydraYearly.RetentionScheduleFormatType = Enum.Parse(typeof(HydraModels.RetentionScheduleFormat),
453-
psYearly.RetentionScheduleFormatType.ToString()).ToString();
451+
hydraYearly.RetentionScheduleFormatType = psYearly.RetentionScheduleFormatType.ToString();
454452
if (psYearly.RetentionScheduleFormatType == RetentionScheduleFormat.Daily)
455453
{
456454
hydraYearly.RetentionScheduleDaily = GetHydraLTRDailyRetentionFormat(psYearly.RetentionScheduleDaily);

src/ResourceManager/RecoveryServices.Backup/Commands.RecoveryServices.Backup.Providers/Providers/IaasVmPsBackupProvider.cs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,8 @@ public AzureRmRecoveryServicesRetentionPolicyBase GetDefaultRetentionPolicyObjec
398398
defaultRetention.IsMonthlyScheduleEnabled = true;
399399
defaultRetention.MonthlySchedule = new Models.MonthlyRetentionSchedule();
400400
defaultRetention.MonthlySchedule.DurationCountInMonths = 60; //tbd: make it const
401+
defaultRetention.MonthlySchedule.RetentionTimes = new List<DateTime>();
402+
defaultRetention.MonthlySchedule.RetentionTimes.Add(retentionTime);
401403
defaultRetention.MonthlySchedule.RetentionScheduleFormatType = Models.RetentionScheduleFormat.Weekly;
402404

403405
//Initialize day based schedule
@@ -410,6 +412,8 @@ public AzureRmRecoveryServicesRetentionPolicyBase GetDefaultRetentionPolicyObjec
410412
defaultRetention.IsYearlyScheduleEnabled = true;
411413
defaultRetention.YearlySchedule = new Models.YearlyRetentionSchedule();
412414
defaultRetention.YearlySchedule.DurationCountInYears = 10;
415+
defaultRetention.YearlySchedule.RetentionTimes = new List<DateTime>();
416+
defaultRetention.YearlySchedule.RetentionTimes.Add(retentionTime);
413417
defaultRetention.YearlySchedule.RetentionScheduleFormatType = Models.RetentionScheduleFormat.Weekly;
414418
defaultRetention.YearlySchedule.MonthsOfYear = new List<Models.Month>();
415419
defaultRetention.YearlySchedule.MonthsOfYear.Add(Models.Month.January);
@@ -666,17 +670,17 @@ private void CopyScheduleTimeToRetentionTimes(AzureRmRecoveryServicesLongTermRet
666670

667671
if (retPolicy.IsWeeklyScheduleEnabled && retPolicy.WeeklySchedule != null)
668672
{
669-
retPolicy.DailySchedule.RetentionTimes = schPolicy.ScheduleRunTimes;
673+
retPolicy.WeeklySchedule.RetentionTimes = schPolicy.ScheduleRunTimes;
670674
}
671675

672676
if (retPolicy.IsMonthlyScheduleEnabled && retPolicy.MonthlySchedule != null)
673677
{
674-
retPolicy.DailySchedule.RetentionTimes = schPolicy.ScheduleRunTimes;
678+
retPolicy.MonthlySchedule.RetentionTimes = schPolicy.ScheduleRunTimes;
675679
}
676680

677681
if (retPolicy.IsYearlyScheduleEnabled && retPolicy.YearlySchedule != null)
678682
{
679-
retPolicy.DailySchedule.RetentionTimes = schPolicy.ScheduleRunTimes;
683+
retPolicy.YearlySchedule.RetentionTimes = schPolicy.ScheduleRunTimes;
680684
}
681685
}
682686

src/ResourceManager/RecoveryServices.Backup/Commands.RecoveryServices.Backup.Test/Commands.RecoveryServices.Backup.Test.csproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,10 @@
9191
<Project>{3436a126-edc9-4060-8952-9a1be34cdd95}</Project>
9292
<Name>Commands.ScenarioTests.ResourceManager.Common</Name>
9393
</ProjectReference>
94+
<ProjectReference Include="..\..\RecoveryServices\Commands.RecoveryServices\Commands.RecoveryServices.csproj">
95+
<Project>{604260dc-b392-4cf4-81ec-34b14591e2d2}</Project>
96+
<Name>Commands.RecoveryServices</Name>
97+
</ProjectReference>
9498
<ProjectReference Include="..\Commands.RecoveryServices.Backup.Cmdlets.csproj">
9599
<Project>{3b3e879a-f856-46bf-aff9-8ad6760cf7b9}</Project>
96100
<Name>Commands.RecoveryServices.Backup.Cmdlets</Name>

0 commit comments

Comments
 (0)