public IEnumerator GameObjectIsDisabledAfterActivation() { // Given an active training scene object and a training course with disable game object behavior, TrainingSceneObject toDisable = TestingUtils.CreateSceneObject("ToDisable"); EndlessCondition trigger = new EndlessCondition(); ICourse course = new LinearTrainingBuilder("Course") .AddChapter(new LinearChapterBuilder("Chapter") .AddStep(new BasicStepBuilder("Step") .DisableAutomaticAudioHandling() .Disable(toDisable) .AddCondition(trigger))) .Build(); course.Configure(RuntimeConfigurator.Configuration.GetCurrentMode()); // When the behavior is activated TrainingRunner.Initialize(course); TrainingRunner.Run(); yield return(new WaitUntil(() => course.Data.FirstChapter.Data.Steps[0].LifeCycle.Stage == Stage.Active)); trigger.Autocomplete(); yield return(new WaitUntil(() => course.Data.FirstChapter.Data.Steps[0].LifeCycle.Stage == Stage.Inactive)); // Then the training scene object is disabled. Assert.False(toDisable.GameObject.activeSelf); // Cleanup. TestingUtils.DestroySceneObject(toDisable); yield break; }
public IEnumerator ActivationIsDone() { // Setup Chapter Chapter chapter = TestLinearChapterBuilder.SetupChapterBuilder(1, false).Build(); // Activate should work on simple steps. TrainingRunner.Initialize(new Course("Course", chapter)); TrainingRunner.Run(); while (chapter.LifeCycle.Stage != Stage.Inactive) { yield return(null); } // Chapter should be finished now. Assert.AreEqual(Stage.Inactive, chapter.LifeCycle.Stage); }
public IEnumerator FastForwardActivatingCourse() { // Given an activated training Course course = new LinearTrainingBuilder("Training Course") .AddChapter(new LinearChapterBuilder("Chapter") .AddStep(new BasicStepBuilder("Step") .DisableAutomaticAudioHandling() .AddCondition(new EndlessCondition()))) .Build(); TrainingRunner.Initialize(course); TrainingRunner.Run(); // When you mark it to fast-forward, course.LifeCycle.MarkToFastForward(); // Then it finishes activation. Assert.AreEqual(Stage.Active, course.LifeCycle.Stage); yield break; }
public IEnumerator OneChapterCourse() { Chapter chapter1 = TestLinearChapterBuilder.SetupChapterBuilder(3, false).Build(); Course course = new Course("MyCourse", chapter1); TrainingRunner.Initialize(course); TrainingRunner.Run(); Debug.Log(chapter1.LifeCycle.Stage); yield return(null); Assert.AreEqual(Stage.Activating, chapter1.LifeCycle.Stage); while (chapter1.LifeCycle.Stage != Stage.Inactive) { Debug.Log(chapter1.LifeCycle.Stage); yield return(null); } Assert.AreEqual(Stage.Inactive, chapter1.LifeCycle.Stage); }
public IEnumerator TwoChapterCourse() { Chapter chapter1 = TestLinearChapterBuilder.SetupChapterBuilder(3, false).Build(); Chapter chapter2 = TestLinearChapterBuilder.SetupChapterBuilder().Build(); Course course = new Course("MyCourse", new List <IChapter> { chapter1, chapter2 }); TrainingRunner.Initialize(course); TrainingRunner.Run(); yield return(new WaitUntil(() => chapter1.LifeCycle.Stage == Stage.Activating)); Assert.AreEqual(Stage.Inactive, chapter2.LifeCycle.Stage); yield return(new WaitUntil(() => chapter2.LifeCycle.Stage == Stage.Activating)); Assert.AreEqual(Stage.Inactive, chapter1.LifeCycle.Stage); Assert.AreEqual(Stage.Activating, chapter2.LifeCycle.Stage); }
public IEnumerator FastForwardInactiveCourseAndActivateIt() { // Given a training Course course = new LinearTrainingBuilder("Training Course") .AddChapter(new LinearChapterBuilder("Chapter") .AddStep(new BasicStepBuilder("Step") .DisableAutomaticAudioHandling() .AddCondition(new EndlessCondition()))) .Build(); // When you mark it to fast-forward and activate it, course.LifeCycle.MarkToFastForward(); TrainingRunner.Initialize(course); TrainingRunner.Run(); yield return(null); // Then it autocompletes. Assert.AreEqual(Stage.Inactive, course.LifeCycle.Stage); yield break; }
public IEnumerator EventsAreThrown() { Chapter chapter1 = TestLinearChapterBuilder.SetupChapterBuilder(3, false).Build(); Chapter chapter2 = TestLinearChapterBuilder.SetupChapterBuilder(3, false).Build(); Course course = new Course("MyCourse", new List <IChapter> { chapter1, chapter2 }); bool wasStarted = false; bool wasCompleted = false; course.LifeCycle.StageChanged += (obj, args) => { if (args.Stage == Stage.Activating) { wasStarted = true; } else if (args.Stage == Stage.Active) { wasCompleted = true; } }; TrainingRunner.Initialize(course); TrainingRunner.Run(); while (course.LifeCycle.Stage != Stage.Inactive) { yield return(null); } Assert.IsTrue(wasStarted); Assert.IsTrue(wasCompleted); }