public async Task DMPendingMultiple_RMNone()
 {
     await RunCommonTestAsync(
         new TestRepairRecord[]
     {
         TestRepairRecord.CreateActive("machine1", "SoftReboot"),
         TestRepairRecord.CreateActive("machine2", "HardReboot"),
         TestRepairRecord.CreateActive("machine3", "SwitchService"),
         TestRepairRecord.CreateActive("machine4", "Reassign"),
         TestRepairRecord.CreatePending("machine1", "SoftReboot", TimeSpan.FromHours(72)),
         TestRepairRecord.CreatePending("machine2", "HardReboot", TimeSpan.FromHours(72)),
         TestRepairRecord.CreatePending("machine3", "SwitchService", TimeSpan.FromHours(72)),
         TestRepairRecord.CreatePending("machine4", "Reassign", TimeSpan.FromHours(72)),
     },
         new IRepairTask[]
     {
     },
         new string[]
     {
         "CreateRepairTaskInPreparing:MACHINE1/SoftReboot:Restart:False",
         "CreateRepairTaskInPreparing:MACHINE2/HardReboot:Restart:False",
         "CreateRepairTaskInPreparing:MACHINE3/SwitchService:Restart:False",
         "CreateRepairTaskInPreparing:MACHINE4/Reassign:RemoveData:False",
     });
 }
 public async Task DMActive_RMNone_NoOp()
 {
     await RunCommonTestAsync(
         new TestRepairRecord[]
     {
         TestRepairRecord.CreateActive("machine1", "NoOp"),
     },
         new IRepairTask[]
     {
     },
         new string[]
     {
     });
 }
 public async Task DMPending_RMNone()
 {
     await RunCommonTestAsync(
         new TestRepairRecord[]
     {
         TestRepairRecord.CreatePending("machine1", "SoftReboot", TimeSpan.FromHours(72)),
     },
         new IRepairTask[]
     {
     },
         new string[]
     {
         "CreateRepairTaskInPreparing:MACHINE1/SoftReboot:Restart:False",
     });
 }
 public async Task DMActive_RMExecuting()
 {
     await RunCommonTestAsync(
         new TestRepairRecord[]
     {
         TestRepairRecord.CreateActive("machine1", "SoftReboot"),
     },
         new IRepairTask[]
     {
         new MockRepairTask("AP/MACHINE1/SoftReboot/20170401-030813", "SoftReboot")
         {
             State = RepairTaskState.Executing,
         },
     },
         new string[]
     {
     });
 }
 public async Task DMPending_RMExecuting_NegativeDMDelay()
 {
     await RunCommonTestAsync(
         new TestRepairRecord[]
     {
         TestRepairRecord.CreatePending("machine1", "SoftReboot", TimeSpan.FromMinutes(-5)),
     },
         new IRepairTask[]
     {
         new MockRepairTask("AP/MACHINE1/SoftReboot/20170401-030813", "SoftReboot")
         {
             State = RepairTaskState.Executing,
         },
     },
         new string[]
     {
     });
 }
 public async Task DMPending_RMApprovedRecently()
 {
     await RunCommonTestAsync(
         new TestRepairRecord[]
     {
         TestRepairRecord.CreatePending("machine1", "SoftReboot", TimeSpan.FromHours(72)),
     },
         new IRepairTask[]
     {
         new MockRepairTask("AP/MACHINE1/SoftReboot/20170401-030813", "SoftReboot")
         {
             State             = RepairTaskState.Approved,
             ApprovedTimestamp = DateTime.UtcNow,
         },
     },
         new string[]
     {
     });
 }
 public async Task DMPending_RMCompleted()
 {
     await RunCommonTestAsync(
         new TestRepairRecord[]
     {
         TestRepairRecord.CreatePending("machine1", "SoftReboot", TimeSpan.FromHours(72)),
     },
         new IRepairTask[]
     {
         new MockRepairTask("AP/MACHINE1/SoftReboot/20170401-030813", "SoftReboot")
         {
             State = RepairTaskState.Completed,
         },
     },
         new string[]
     {
         "CreateRepairTaskInPreparing:MACHINE1/SoftReboot:Restart:False",
     });
 }
        public async Task DMPending_RMPreparing_Overdue()
        {
            await RunCommonTestAsync(
                new TestRepairRecord[]
            {
                TestRepairRecord.CreatePending("machine1", "SoftReboot", TimeSpan.FromHours(72)),
            },
                new IRepairTask[]
            {
                new MockRepairTask("AP/MACHINE1/SoftReboot/20170401-030813", "SoftReboot")
                {
                    State = RepairTaskState.Preparing,
                    PreparingTimestamp = DateTime.UtcNow.AddMinutes(-500),
                },
            },
                new string[]
            {
            });

            Assert.AreEqual(1, this.context.OverdueRepairTaskCount);
        }
 public async Task DMPending_RMExecuting_DoNotIncreaseDelayWhenApproved()
 {
     await RunCommonTestAsync(
         new TestRepairRecord[]
     {
         TestRepairRecord.CreatePending(
             "machine1", "SoftReboot", TimeSpan.FromMinutes(1),
             isApproved: true,
             isDelayModified: false),     // because delay is already short
     },
         new IRepairTask[]
     {
         new MockRepairTask("AP/MACHINE1/SoftReboot/20170401-030813", "SoftReboot")
         {
             State = RepairTaskState.Executing,
         },
     },
         new string[]
     {
         "ExecuteRepair:MACHINE1/SoftReboot:AP/MACHINE1/SoftReboot/20170401-030813",
     });
 }
 public async Task DMPending_RMExecuting()
 {
     await RunCommonTestAsync(
         new TestRepairRecord[]
     {
         TestRepairRecord.CreatePending(
             "machine1", "SoftReboot", TimeSpan.FromHours(72),
             isApproved: true,
             isDelayModified: true),
     },
         new IRepairTask[]
     {
         new MockRepairTask("AP/MACHINE1/SoftReboot/20170401-030813", "SoftReboot")
         {
             State = RepairTaskState.Executing,
         },
     },
         new string[]
     {
         "ExecuteRepair:MACHINE1/SoftReboot:AP/MACHINE1/SoftReboot/20170401-030813",
     });
 }