public IEnumerator BuildingTouchTest() { // Given you have a touchable property and a builder for a training with Touch default step GameObject touchableGo = new GameObject("Touchable"); TrainingSceneObject touchable = touchableGo.AddComponent <TrainingSceneObject>(); touchableGo.AddComponent <TouchableProperty>(); touchable.ChangeUniqueName("Touchable"); LinearTrainingBuilder builder = new LinearTrainingBuilder("TestTraining") .AddChapter(new LinearChapterBuilder("TestChapter") .AddStep(DefaultSteps.Touch("TestTouchStep", "Touchable"))); // When you build a training with it IStep step = builder.Build().Data.FirstChapter.Data.FirstStep; // Then it has a step with a TouchCOndition Assert.True(step != null); Assert.True(step.Data.Name == "TestTouchStep"); Assert.True(step.Data.Transitions.Data.Transitions.First().Data.Conditions.Count == 1); Assert.True(step.Data.Transitions.Data.Transitions.First().Data.Conditions.First() is TouchedCondition); Assert.True(ReferenceEquals((step.Data.Transitions.Data.Transitions.First().Data.Conditions.First() as TouchedCondition).Data.TouchableProperty.Value.SceneObject, touchable)); // Cleanup Object.DestroyImmediate(touchableGo); return(null); }
public IEnumerator BuildingSnapZonePutTest() { // Given a snap zone and snappable property and a builder for a training with a PutIntoSnapZone default step GameObject snapZoneGo = new GameObject("SnapZone"); TrainingSceneObject snapZone = snapZoneGo.AddComponent <TrainingSceneObject>(); snapZoneGo.AddComponent <SnapZoneProperty>(); snapZone.ChangeUniqueName("SnapZone"); GameObject putGo = new GameObject("Puttable"); TrainingSceneObject objectToPut = putGo.AddComponent <TrainingSceneObject>(); putGo.AddComponent <SnappableProperty>(); objectToPut.ChangeUniqueName("ToPut"); LinearTrainingBuilder builder = new LinearTrainingBuilder("TestTraining") .AddChapter(new LinearChapterBuilder("TestChapter") .AddStep(DefaultSteps.PutIntoSnapZone("TestSnapZonePutStep", "SnapZone", "ToPut"))); // When you build a training with it IStep step = builder.Build().Data.FirstChapter.Data.FirstStep; // Then it has a step with a SnappedCondition Assert.True(step != null); Assert.True(step.Data.Name == "TestSnapZonePutStep"); Assert.True(step.Data.Transitions.Data.Transitions.First().Data.Conditions.Count == 1); Assert.True(step.Data.Transitions.Data.Transitions.First().Data.Conditions.First() is SnappedCondition); Assert.True(ReferenceEquals((step.Data.Transitions.Data.Transitions.First().Data.Conditions.First() as SnappedCondition).Data.Target.Value.SceneObject, objectToPut)); // Cleanup Object.DestroyImmediate(snapZoneGo); Object.DestroyImmediate(putGo); return(null); }
public IEnumerator BuildingGrabTest() { // Given a `GrabbableProperty` and a builder for a training with a Grab default step GameObject go = new GameObject("TestGrabbable"); TrainingSceneObject to = go.AddComponent <TrainingSceneObject>(); go.AddComponent <GrabbableProperty>(); to.ChangeUniqueName("Grabbable"); LinearTrainingBuilder builder = new LinearTrainingBuilder("TestTraining") .AddChapter(new LinearChapterBuilder("TestChapter") .AddStep(DefaultSteps.Grab("TestGrabStep", "Grabbable"))); // When we build a training from it IStep step = builder.Build().Data.FirstChapter.Data.FirstStep; //Then it should has a stap with a GrabbedCondition which refers to the `GrabbableProperty`. Assert.True(step != null); Assert.True(step.Data.Name == "TestGrabStep"); Assert.True(step.Data.Transitions.Data.Transitions.First().Data.Conditions.Count == 1); GrabbedCondition condition = step.Data.Transitions.Data.Transitions.First().Data.Conditions.First() as GrabbedCondition; Assert.True(ReferenceEquals(to, condition.Data.GrabbableProperty.Value.SceneObject)); // Cleanup Object.DestroyImmediate(go); yield return(null); }
public void BuildingIntroTest() { // Given a builder with a predefined Intro step LinearTrainingBuilder builder = new LinearTrainingBuilder("TestTraining") .AddChapter(new LinearChapterBuilder("TestChapter") .AddStep(DefaultSteps.Intro("TestIntroStep"))); // When we build a training from it, IStep step = builder.Build().Data.FirstChapter.Data.FirstStep; // Then a training with an Intro step is created. Assert.True(step != null); Assert.True(step.Data.Name == "TestIntroStep"); Assert.True(step.Data.Transitions.Data.Transitions.First().Data.Conditions.Any() == false); }
public IEnumerator BuildingColliderPutTest() { // Given two training scene objects with `ColliderWithTriggerProperty` and a builder for at raining with a PutIntoCollider default step GameObject colliderGo = new GameObject("Collider"); TrainingSceneObject testCollider = colliderGo.AddComponent <TrainingSceneObject>(); colliderGo.AddComponent <SphereCollider>().isTrigger = true; colliderGo.AddComponent <ColliderWithTriggerProperty>(); testCollider.ChangeUniqueName("Collider"); GameObject putGo = new GameObject("Puttable"); TrainingSceneObject testObjectToPut = putGo.AddComponent <TrainingSceneObject>(); putGo.AddComponent <SphereCollider>().isTrigger = true; putGo.AddComponent <ColliderWithTriggerProperty>(); testObjectToPut.ChangeUniqueName("ToPut"); LinearTrainingBuilder builder = new LinearTrainingBuilder("TestTraining") .AddChapter(new LinearChapterBuilder("TestChapter") .AddStep(DefaultSteps.PutIntoCollider("TestColliderPutStep", "Collider", 1f, "ToPut"))); // When you build a training from it IStep step = builder.Build().Data.FirstChapter.Data.FirstStep; // Then it has a step with a ObjectInColliderCondition. Assert.True(step != null); Assert.True(step.Data.Name == "TestColliderPutStep"); Assert.True(step.Data.Transitions.Data.Transitions.First().Data.Conditions.Count == 1); Assert.True(step.Data.Transitions.Data.Transitions.First().Data.Conditions.First() is ObjectInColliderCondition); // Cleanup Object.DestroyImmediate(colliderGo); Object.DestroyImmediate(putGo); return(null); }