public void FirstStepIsSet() { TestLinearChapterBuilder builder = TestLinearChapterBuilder.SetupChapterBuilder(); Chapter chapter = builder.Build(); Assert.IsNotNull(chapter.Data.FirstStep, "First step not set!"); Assert.AreEqual(builder.Steps.First(), chapter.Data.FirstStep, "Wrong Step set as first!"); }
public IEnumerator StepWithHighlightBehavior() { // Given a HighlightObjectBehavior with a HighlightProperty in a linear chapter. Color highlightColor = Color.yellow; GameObject interactable = GameObject.CreatePrimitive(PrimitiveType.Cube); interactable.name = targetName; DummyHighlightProperty highlightProperty = interactable.AddComponent <DummyHighlightProperty>(); HighlightObjectBehavior highlightBehavior = new HighlightObjectBehavior(highlightProperty, highlightColor); TestLinearChapterBuilder chapterBuilder = TestLinearChapterBuilder.SetupChapterBuilder(1); chapterBuilder.Steps[0].Data.Behaviors.Data.Behaviors.Add(highlightBehavior); Chapter chapter = chapterBuilder.Build(); chapter.Configure(RuntimeConfigurator.Configuration.Modes.CurrentMode); // When we activate the chapter. chapter.LifeCycle.Activate(); while (highlightBehavior.LifeCycle.Stage != Stage.Active) { yield return(null); chapter.Update(); } Stage highlightStageInStep = highlightBehavior.LifeCycle.Stage; bool objectHighlightedActiveInStep = highlightProperty.IsHighlighted; Color?colorInStep = highlightProperty.CurrentHighlightColor; chapter.Data.FirstStep.LifeCycle.Deactivate(); while (chapter.Data.FirstStep.LifeCycle.Stage != Stage.Inactive) { yield return(null); chapter.Update(); } Stage highlightStageAfterStep = highlightBehavior.LifeCycle.Stage; bool objectHighlightedActiveAfterStep = highlightProperty.IsHighlighted; Color?colorAfterStep = highlightProperty.CurrentHighlightColor; // Then the highlight behavior is active during the step and inactive after it. Assert.AreEqual(Stage.Active, highlightStageInStep, "The HighlightObjectBehavior should be active during step"); Assert.IsTrue(objectHighlightedActiveInStep, "The HighlightProperty should be active during step"); Assert.AreEqual(highlightColor, colorInStep, $"The highlight color should be {highlightColor}"); Assert.AreEqual(Stage.Inactive, highlightStageAfterStep, "The HighlightObjectBehavior should be deactivated after step"); Assert.IsFalse(objectHighlightedActiveAfterStep, "The HighlightProperty should be inactive after step"); Assert.IsNull(colorAfterStep, "The highlight color should be null after deactivation of step."); }
public IEnumerator MultiStepChapterCompletesSteps() { // Setup Chapter TestLinearChapterBuilder builder = TestLinearChapterBuilder.SetupChapterBuilder(2, true); Chapter chapter = builder.Build(); chapter.Configure(RuntimeConfigurator.Configuration.Modes.CurrentMode); // Activate should work on simple steps. chapter.LifeCycle.Activate(); while (chapter.Data.FirstStep.LifeCycle.Stage != Stage.Active) { yield return(null); chapter.Update(); } Stage chapterInitalStage = chapter.LifeCycle.Stage; Stage step1InitialStage = builder.Steps[0].LifeCycle.Stage; Stage step2InitialStage = builder.Steps[1].LifeCycle.Stage; builder.StepTriggerConditions[0].Autocomplete(); while (chapter.Data.Steps[1].LifeCycle.Stage != Stage.Active) { yield return(null); chapter.Update(); } Stage chapterStageAfterFirstComplete = chapter.LifeCycle.Stage; Stage step1StageAfterFirstComplete = builder.Steps[0].LifeCycle.Stage; Stage step2StageAfterFirstComplete = builder.Steps[1].LifeCycle.Stage; builder.StepTriggerConditions[1].Autocomplete(); while (chapter.LifeCycle.Stage != Stage.Active) { yield return(null); chapter.Update(); } Stage chapterStageInEnd = chapter.LifeCycle.Stage; Stage step1StageInEnd = builder.Steps[0].LifeCycle.Stage; Stage step2StageInEnd = builder.Steps[1].LifeCycle.Stage; // check steps are activated and completed in correct order Assert.AreEqual(Stage.Activating, chapterInitalStage, "Chapter should be active in the beginning"); Assert.AreEqual(Stage.Active, step1InitialStage, "First Step should be active in the beginning"); Assert.AreEqual(Stage.Inactive, step2InitialStage, "Second Step should not be active in the beginning"); Assert.AreEqual(Stage.Activating, chapterStageAfterFirstComplete, "Chapter should be active after first complete"); Assert.AreEqual(Stage.Inactive, step1StageAfterFirstComplete, "First Step should not be active after first complete"); Assert.AreEqual(Stage.Active, step2StageAfterFirstComplete, "Second Step should be active after first complete"); Assert.AreEqual(Stage.Active, chapterStageInEnd, "Chapter should still be active, as nothing deactivated it."); Assert.AreEqual(Stage.Inactive, step1StageInEnd, "First Step should not be active in the end"); Assert.AreEqual(Stage.Inactive, step2StageInEnd, "Second Step should not be active in the end"); }