示例#1
0
        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!");
        }
示例#2
0
        public IEnumerator MultiStepChapterCompletesSteps()
        {
            // Setup Chapter
            TestLinearChapterBuilder builder = TestLinearChapterBuilder.SetupChapterBuilder(2, true);
            Chapter chapter = builder.Build();

            chapter.Configure(RuntimeConfigurator.Configuration.GetCurrentMode());

            // 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");
        }