public void OnInitialStateExecutionAndLimitTimeShouldBeCorrectCalculated() { // Arrange List <Step> steps = new List <Step>(); RecursiveStep sequentialStep = new RecursiveStep(Standard.Mandatory, "Door", steps); sequentialStep.AddSubStep(_takeKeyStep); sequentialStep.AddSubStep(_insertKeyStep); sequentialStep.AddSubStep(_openDoorStep); sequentialStep.UpdateDuration(); // Assert Assert.AreEqual(3000, sequentialStep.ExpectedDuration.Seconds); Assert.AreEqual(6000, sequentialStep.LimitDuration.Seconds); }
public void OnCompletionAndCalculationAllTimesShouldBeCorrect() { // Arrange List <Step> hugSteps = new List <Step>(); RecursiveStep hugSequentialStep = new RecursiveStep(Standard.Mandatory, "Hug.", hugSteps); hugSequentialStep.AddSubStep(_grabHugStep); hugSequentialStep.AddSubStep(_takeKeyStep); List <Step> doorSteps = new List <Step>(); RecursiveStep doorSequentialStep = new RecursiveStep(Standard.Mandatory, "Door", doorSteps); doorSequentialStep.AddSubStep(_insertKeyStep); doorSequentialStep.AddSubStep(_openDoorStep); List <Step> multiNivelSequentialSteps = new List <Step>(); RecursiveStep multiNivelSequentialStep = new RecursiveStep(Standard.Mandatory, "Unlock Door", multiNivelSequentialSteps); multiNivelSequentialStep.AddSubStep(hugSequentialStep); multiNivelSequentialStep.AddSubStep(doorSequentialStep); DateTime firstTime = DateTime.Now; DateTime secondTime = DateTime.Now; DateTime thirdTime = DateTime.Now; DateTime fourthTime = DateTime.Now; DateTime fifthTime = DateTime.Now; // Act multiNivelSequentialStep.UpdateDuration(); multiNivelSequentialStep.AdvanceStep(firstTime); multiNivelSequentialStep.AdvanceStep(secondTime); multiNivelSequentialStep.AdvanceStep(thirdTime); System.Threading.Thread.Sleep(2000); multiNivelSequentialStep.AdvanceStep(fourthTime); multiNivelSequentialStep.AdvanceStep(fifthTime); // Assert Assert.AreEqual(4000, multiNivelSequentialStep.ExpectedDuration.Seconds); Assert.AreEqual(8000, multiNivelSequentialStep.LimitDuration.Seconds); var timeOffset = fifthTime.Subtract(firstTime).TotalSeconds; Assert.AreEqual((long)timeOffset, (long)multiNivelSequentialStep.ExecutionTime.Seconds); }