public void OnThreeAdvancesShouldChangeActiveRecursiveSubStepAndReturnThirdInteraction() { // 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); // Act multiNivelSequentialStep.AdvanceStep(DateTime.Now); multiNivelSequentialStep.AdvanceStep(DateTime.Now); LeafStep third = multiNivelSequentialStep.AdvanceStep(DateTime.Now); // Assert Assert.AreEqual(true, hugSequentialStep.Completed); Assert.AreEqual(false, hugSequentialStep.Active); Assert.AreEqual(false, doorSequentialStep.Completed); Assert.AreEqual(true, doorSequentialStep.Active); Assert.AreEqual(_insertKeyStep.Interaction, third.Interaction); Assert.AreEqual(doorSequentialStep, multiNivelSequentialStep.CurrentSubStep); }
public void OnTwoAdvancesMultinivelSequentialStepsShouldBeNonCompletedActiveAndReturnSecondInteraction() { // 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); // Act multiNivelSequentialStep.AdvanceStep(DateTime.Now); LeafStep second = multiNivelSequentialStep.AdvanceStep(DateTime.Now); // Assert Assert.AreEqual(false, multiNivelSequentialStep.Completed); Assert.AreEqual(true, multiNivelSequentialStep.Active); Assert.AreEqual(_takeKeyStep.Interaction, second.Interaction); }
public RecursiveStepTests() { Description takeKeyDescription = new Description("Take the Key."); Duration takeKeyExpected = new Duration(1000); Duration takeKeyLimit = new Duration(2000); _keyInteraction = new Interaction(Act.Grab, takeKeyDescription, takeKeyExpected, takeKeyLimit); _takeKeyStep = new LeafStep(Standard.Mandatory, "Taking Key", _keyInteraction); Description insertKeyDescription = new Description("Insert key into door."); Duration insertKeyExpected = new Duration(1000); Duration insertKeyLimit = new Duration(2000); _keyholeInteraction = new Interaction(Act.Grab, insertKeyDescription, insertKeyExpected, insertKeyLimit); _insertKeyStep = new LeafStep(Standard.Mandatory, "Insert key.", _keyholeInteraction); Description openDoorDescription = new Description("Open door."); Duration openDoorExpected = new Duration(1000); Duration openDoorLimit = new Duration(2000); Interaction _doorInteraction = new Interaction(Act.Grab, openDoorDescription, openDoorExpected, openDoorLimit); _openDoorStep = new LeafStep(Standard.Mandatory, "Insert key.", _doorInteraction); Description grabHugDescription = new Description("Grab HUg."); Duration grabHugExpected = new Duration(1000); Duration grabHugLimit = new Duration(2000); Interaction _grabHugInteraction = new Interaction(Act.Grab, grabHugDescription, grabHugExpected, grabHugLimit); _grabHugStep = new LeafStep(Standard.Mandatory, "Insert key.", _grabHugInteraction); }
public void ErrorOnGettingDurationWithoutProcessing() { // Arrange Description description = new Description("Take the Key."); Duration expected = new Duration(20000); Duration limit = new Duration(30000); Interaction interaction = new Interaction(Act.Grab, description, expected, limit); LeafStep leafStep = new LeafStep(Standard.Mandatory, "Taking Key", interaction); /// Act var millis = leafStep.ExpectedDuration.Seconds; }
public Setup() { var keyAssetMock = new Asset("key", "key.jpg", "key.fbx"); var hugAssetMock = new Asset("hug", "hug.jpg", "hug.fbx"); var doorssetMock = new Asset("door", "door.jpg", "door.fbx"); Description takeKeyDescription = new Description("Take the Key."); Duration takeKeyExpected = new Duration(1000); Duration takeKeyLimit = new Duration(2000); _keyInteraction = new Interaction(Act.Grab, takeKeyDescription, takeKeyExpected, takeKeyLimit, keyAssetMock); _takeKeyStep = new LeafStep(Standard.Mandatory, "Taking Key", _keyInteraction); Description insertKeyDescription = new Description("Insert key into door."); Duration insertKeyExpected = new Duration(1000); Duration insertKeyLimit = new Duration(2000); _keyholeInteraction = new Interaction(Act.Grab, insertKeyDescription, insertKeyExpected, insertKeyLimit, keyAssetMock, doorssetMock); _insertKeyStep = new LeafStep(Standard.Mandatory, "Insert key.", _keyholeInteraction); Description openDoorDescription = new Description("Open door."); Duration openDoorExpected = new Duration(1000); Duration openDoorLimit = new Duration(2000); _doorInteraction = new Interaction(Act.Grab, openDoorDescription, openDoorExpected, openDoorLimit, doorssetMock); _openDoorStep = new LeafStep(Standard.Mandatory, "Insert key.", _doorInteraction); Description grabHugDescription = new Description("Grab HUg."); Duration grabHugExpected = new Duration(1000); Duration grabHugLimit = new Duration(2000); _grabHugInteraction = new Interaction(Act.Grab, grabHugDescription, grabHugExpected, grabHugLimit, hugAssetMock); _grabHugStep = new LeafStep(Standard.Mandatory, "Insert key.", _grabHugInteraction); 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>(); _MultinivelStep = new RecursiveStep(Standard.Mandatory, "Unlock Door", multiNivelSequentialSteps); _MultinivelStep.AddSubStep(hugSequentialStep); _MultinivelStep.AddSubStep(doorSequentialStep); }
public void CorrectExecutionTimeOnStart() { // Arrange Description description = new Description("Take the Key."); Duration expected = new Duration(1000); Duration limit = new Duration(2000); Interaction interaction = new Interaction(Act.Grab, description, expected, limit); LeafStep leafStep = new LeafStep(Standard.Mandatory, "Taking Key", interaction); // Act // Assert Assert.AreEqual(0, leafStep.ExecutionTime.Seconds); }
public void CorrectAdvanceStepForCompletedStep() { // Arrange Description description = new Description("Take the Key."); Duration expected = new Duration(1000); Duration limit = new Duration(2000); Interaction interaction = new Interaction(Act.Grab, description, expected, limit); LeafStep leafStep = new LeafStep(Standard.Mandatory, "Taking Key", interaction); // Act leafStep.AdvanceStep(DateTime.Now); leafStep.AdvanceStep(DateTime.Now); leafStep.AdvanceStep(DateTime.Now); }
public void LimitTime_for_Interaction() { // Arrange Description description = new Description("Take the Key."); Duration expected = new Duration(1000); Duration limit = new Duration(2000); Interaction interaction = new Interaction(Act.Grab, description, expected, limit); LeafStep leafStep = new LeafStep(Standard.Mandatory, "Taking Key", interaction); // Act leafStep.UpdateDuration(); // Assert Assert.AreEqual(limit.Seconds, leafStep.LimitDuration.Seconds); }
public void CorrectAdvanceStepForNonActiveNonCompletedStep() { // Arrange Description description = new Description("Take the Key."); Duration expected = new Duration(1000); Duration limit = new Duration(2000); Interaction interaction = new Interaction(Act.Grab, description, expected, limit); LeafStep leafStep = new LeafStep(Standard.Mandatory, "Taking Key", interaction); // Act leafStep.AdvanceStep(DateTime.Now); // Assert Assert.AreEqual(true, leafStep.Active); Assert.AreEqual(false, leafStep.Completed); }
public void CorrectInitialStatsForLeafStep() { // Arrange Description description = new Description("Take the Key."); Duration expected = new Duration(1000); Duration limit = new Duration(2000); Interaction interaction = new Interaction(Act.Grab, description, expected, limit); LeafStep leafStep = new LeafStep(Standard.Mandatory, "Taking Key", interaction); // Act // Assert Assert.AreEqual(false, leafStep.Active); Assert.AreEqual(false, leafStep.Completed); }
public void CorrectExecutionTimeOnCompletion() { // Arrange Description description = new Description("Take the Key."); Duration expected = new Duration(1000); Duration limit = new Duration(2000); Interaction interaction = new Interaction(Act.Grab, description, expected, limit); LeafStep leafStep = new LeafStep(Standard.Mandatory, "Taking Key", interaction); DateTime firstTime = DateTime.Now; DateTime secondTime = DateTime.Now; // Act leafStep.AdvanceStep(firstTime); leafStep.AdvanceStep(secondTime); // Assert Assert.AreEqual(secondTime.Subtract(firstTime).TotalSeconds, leafStep.ExecutionTime.Seconds); }