public IEnumerator SecondPropertyStaysLocked() { // Given two steps and two scene objects with each one lockable property // where only the first property is referenced in the first step. ISceneObject o1 = TestingUtils.CreateSceneObject("o1"); LockablePropertyMock property1 = o1.GameObject.AddComponent <LockablePropertyMock>(); ISceneObject o2 = TestingUtils.CreateSceneObject("o2"); LockablePropertyMock property2 = o2.GameObject.AddComponent <LockablePropertyMock>(); LockableReferencingConditionMock doNotLockAtEndOfStepCondition = new LockableReferencingConditionMock(); doNotLockAtEndOfStepCondition.Data.LockablePropertyMock = new ScenePropertyReference <ILockablePropertyMock>(o1.UniqueName); doNotLockAtEndOfStepCondition.LockableProperties = new[] { new LockablePropertyData(property1, false) }; Step step2 = new BasicStepBuilder("step2").Build(); Step step = new BasicStepBuilder("step") .AddCondition(doNotLockAtEndOfStepCondition) .Build(); property1.SetLocked(true); property2.SetLocked(true); step.Data.Transitions.Data.Transitions[0].Data.TargetStep = step2; // When executing the locking routine in the first step. LockHandling.Unlock(step.Data, new List <LockablePropertyData>()); // Then property 2 is locked during the first step. Assert.IsTrue(property2.IsLocked); yield return(null); }
public IEnumerator KeepUnlockedAtEndPropertyIsUnlockedAfterFinishingStep() { // Given a transition with a condition referencing a scene object with a lockable property // that should not be locked in the end of a step. ISceneObject o1 = TestingUtils.CreateSceneObject("o1"); LockablePropertyMock property = o1.GameObject.AddComponent <LockablePropertyMock>(); LockableReferencingConditionMock doNotLockAtEndOfStepCondition = new LockableReferencingConditionMock(); doNotLockAtEndOfStepCondition.Data.LockablePropertyMock = new ScenePropertyReference <ILockablePropertyMock>(o1.UniqueName); doNotLockAtEndOfStepCondition.LockableProperties = new[] { new LockablePropertyData(property, false) }; Step step2 = new BasicStepBuilder("step2").Build(); Step step = new BasicStepBuilder("step").AddCondition(doNotLockAtEndOfStepCondition).Build(); step.Data.Transitions.Data.Transitions[0].Data.TargetStep = step2; // When executing the locking routine and completing the step. LockHandling.Unlock(step.Data, new List <LockablePropertyData>()); step.Data.Transitions.Data.Transitions.First().Autocomplete(); step.Data.Transitions.Data.Transitions.First().Data.IsCompleted = true; LockHandling.Lock(step.Data, new List <LockablePropertyData>()); // Then the property is not locked in the end. Assert.IsFalse(property.IsLocked); yield return(null); }
public IEnumerator SamePropertyInSecondStepStaysUnlocked() { // Given a scene object with a lockable property which is referenced in the transitions of the first and second step // and should normally lock at the end of a step. ISceneObject o1 = TestingUtils.CreateSceneObject("o1"); LockablePropertyMock property = o1.GameObject.AddComponent <LockablePropertyMock>(); LockableReferencingConditionMock lockAtEndOfStepCondition = new LockableReferencingConditionMock(); lockAtEndOfStepCondition.Data.LockablePropertyMock = new ScenePropertyReference <ILockablePropertyMock>(o1.UniqueName); lockAtEndOfStepCondition.LockableProperties = new[] { new LockablePropertyData(property, true) }; Step step2 = new BasicStepBuilder("step2").AddCondition(lockAtEndOfStepCondition).Build(); Step step = new BasicStepBuilder("step").AddCondition(lockAtEndOfStepCondition).Build(); step.Data.Transitions.Data.Transitions[0].Data.TargetStep = step2; // When executing the locking routine in the first step. LockHandling.Unlock(step.Data, new List <LockablePropertyData>()); step.Data.Transitions.Data.Transitions.First().Autocomplete(); step.Data.Transitions.Data.Transitions.First().Data.IsCompleted = true; LockHandling.Lock(step.Data, new List <LockablePropertyData>()); // Then the property is not locked at the end of the first step because it is needed in the second step. Assert.IsFalse(property.IsLocked); yield return(null); }
public IEnumerator GetLockablePropertiesObjectInMultipleConditions() { // Given a scene object with one lockable property and one non-lockable property used by two conditions in a transition. ISceneObject o1 = TestingUtils.CreateSceneObject("o1"); LockablePropertyMock property = o1.GameObject.AddComponent <LockablePropertyMock>(); o1.GameObject.AddComponent <PropertyMock>(); LockableReferencingConditionMock condition1 = new LockableReferencingConditionMock(); condition1.Data.LockablePropertyMock = new ScenePropertyReference <ILockablePropertyMock>(o1.UniqueName); condition1.LockableProperties = new[] { new LockablePropertyData(property, true) }; LockableReferencingConditionMock condition2 = new LockableReferencingConditionMock(); condition2.Data.LockablePropertyMock = new ScenePropertyReference <ILockablePropertyMock>(o1.UniqueName); condition2.LockableProperties = new[] { new LockablePropertyData(property, false) }; Step step2 = new BasicStepBuilder("step2").Build(); Step step = new BasicStepBuilder("step").AddCondition(condition1).AddCondition(condition2).Build(); Transition transition = (Transition)step.Data.Transitions.Data.Transitions[0]; transition.Data.TargetStep = step2; // When counting the lockable properties in the transition. // Then there is exactly one lockable property. Assert.IsTrue(transition.GetLockableProperties().Count() == 1); yield return(null); }
public IEnumerator GetLockablePropertiesMultipleObjectsAndConditions() { // Given three scene objects, // one of them with one lockable property and one non-lockable property, // one of them with only one non-lockable property, // and one of them with only one lockable property, // used by three different conditions in a transition. ISceneObject o1 = TestingUtils.CreateSceneObject("o1"); LockablePropertyMock property = o1.GameObject.AddComponent <LockablePropertyMock>(); o1.GameObject.AddComponent <PropertyMock>(); ISceneObject o2 = TestingUtils.CreateSceneObject("o2"); o2.GameObject.AddComponent <PropertyMock>(); ISceneObject o3 = TestingUtils.CreateSceneObject("o3"); LockablePropertyMock property2 = o2.GameObject.AddComponent <LockablePropertyMock>(); LockableReferencingConditionMock condition1 = new LockableReferencingConditionMock(); condition1.Data.LockablePropertyMock = new ScenePropertyReference <ILockablePropertyMock>(o1.UniqueName); condition1.LockableProperties = new[] { new LockablePropertyData(property, true) }; ReferencingConditionMock condition2 = new ReferencingConditionMock(); condition2.Data.PropertyMock = new ScenePropertyReference <PropertyMock>(o2.UniqueName); LockableReferencingConditionMock condition3 = new LockableReferencingConditionMock(); condition3.Data.LockablePropertyMock = new ScenePropertyReference <ILockablePropertyMock>(o3.UniqueName); condition3.LockableProperties = new[] { new LockablePropertyData(property2, true) }; Step step2 = new BasicStepBuilder("step2").Build(); Step step = new BasicStepBuilder("step") .AddCondition(condition1) .AddCondition(condition2) .AddCondition(condition3) .Build(); Transition transition = (Transition)step.Data.Transitions.Data.Transitions[0]; transition.Data.TargetStep = step2; // When counting the lockable properties in the transition. // Then there are exactly two lockable properties. Assert.IsTrue(transition.GetLockableProperties().Count() == 2); yield return(null); }
public IEnumerator ObjectInConditionIsNotInManualUnlockList() { // Given a step with a condition with a LockableProperty ISceneObject o1 = TestingUtils.CreateSceneObject("o1"); LockableProperty lockableProperty = o1.GameObject.AddComponent <LockablePropertyMock>(); LockableReferencingConditionMock lockCondition = new LockableReferencingConditionMock(); lockCondition.Data.LockablePropertyMock = new ScenePropertyReference <ILockablePropertyMock>(o1.UniqueName); Step step = new BasicStepBuilder("step").AddCondition(lockCondition).Build(); // When we create a collection referencing this step LockableObjectsCollection collection = new LockableObjectsCollection(step.Data); // Then the lockable property is not in the Manual Unlock List of the collection Assert.IsFalse(collection.IsInManualUnlockList(lockableProperty)); yield return(null); }
public IEnumerator SecondTransitionIsLocked() { // Given a step with two different transitions, // each of them having an own condition with a lockable property which should not be locked at the end of a step. ISceneObject o1 = TestingUtils.CreateSceneObject("o1"); LockablePropertyMock property = o1.GameObject.AddComponent <LockablePropertyMock>(); ISceneObject o2 = TestingUtils.CreateSceneObject("o2"); LockablePropertyMock property2 = o2.GameObject.AddComponent <LockablePropertyMock>(); LockableReferencingConditionMock doNotLockAtEndOfStepCondition1 = new LockableReferencingConditionMock(); doNotLockAtEndOfStepCondition1.Data.LockablePropertyMock = new ScenePropertyReference <ILockablePropertyMock>(o1.UniqueName); doNotLockAtEndOfStepCondition1.LockableProperties = new[] { new LockablePropertyData(property, false) }; LockableReferencingConditionMock doNotLockAtEndOfStepCondition2 = new LockableReferencingConditionMock(); doNotLockAtEndOfStepCondition2.Data.LockablePropertyMock = new ScenePropertyReference <ILockablePropertyMock>(o2.UniqueName); doNotLockAtEndOfStepCondition2.LockableProperties = new[] { new LockablePropertyData(property2, false) }; Step step2 = new BasicStepBuilder("step2").AddCondition(doNotLockAtEndOfStepCondition1).Build(); Step step = new BasicStepBuilder("step").AddCondition(doNotLockAtEndOfStepCondition1).Build(); step.Data.Transitions.Data.Transitions[0].Data.TargetStep = step2; step.Data.Transitions.Data.Transitions.Add(new Transition()); step.Data.Transitions.Data.Transitions[1].Data.Conditions.Add(doNotLockAtEndOfStepCondition2); // When completing only the first transition. LockHandling.Unlock(step.Data, new List <LockablePropertyData>()); step.Data.Transitions.Data.Transitions.First().Autocomplete(); step.Data.Transitions.Data.Transitions.First().Data.IsCompleted = true; LockHandling.Lock(step.Data, new List <LockablePropertyData>()); // Then the lockable property of the second transition is locked, // even though lock at the end of step is set to false. Assert.IsTrue(property2.IsLocked); yield return(null); }
public IEnumerator SecondPropertyGetsLockedAfterNotBeingNeededAnymore() { // Given two steps and two scene objects with each one lockable property // and property 2 (lock at the end of step = true) is referenced only in the first step, // whereas property 1 (lock at the end of step = false) is referenced in both steps. ISceneObject o1 = TestingUtils.CreateSceneObject("o1"); LockablePropertyMock DoNotLockAtEndOfStep = o1.GameObject.AddComponent <LockablePropertyMock>(); ISceneObject o2 = TestingUtils.CreateSceneObject("o2"); LockablePropertyMock lockAtEndOfStep = o2.GameObject.AddComponent <LockablePropertyMock>(); LockableReferencingConditionMock doNotLockAtEndOfStepCondition = new LockableReferencingConditionMock(); doNotLockAtEndOfStepCondition.Data.LockablePropertyMock = new ScenePropertyReference <ILockablePropertyMock>(o1.UniqueName); doNotLockAtEndOfStepCondition.LockableProperties = new[] { new LockablePropertyData(DoNotLockAtEndOfStep, false) }; LockableReferencingConditionMock lockAtEndOfStepCondition = new LockableReferencingConditionMock(); lockAtEndOfStepCondition.Data.LockablePropertyMock = new ScenePropertyReference <ILockablePropertyMock>(o2.UniqueName); lockAtEndOfStepCondition.LockableProperties = new[] { new LockablePropertyData(lockAtEndOfStep, true) }; Step step2 = new BasicStepBuilder("step2").AddCondition(doNotLockAtEndOfStepCondition).Build(); Step step = new BasicStepBuilder("step") .AddCondition(doNotLockAtEndOfStepCondition) .AddCondition(lockAtEndOfStepCondition) .Build(); step.Data.Transitions.Data.Transitions[0].Data.TargetStep = step2; // When executing the locking routine in the first step. LockHandling.Unlock(step.Data, new List <LockablePropertyData>()); step.Data.Transitions.Data.Transitions.First().Autocomplete(); step.Data.Transitions.Data.Transitions.First().Data.IsCompleted = true; LockHandling.Lock(step.Data, new List <LockablePropertyData>()); // Then property 2 is locked in the end of the first step. Assert.IsTrue(lockAtEndOfStep.IsLocked); yield return(null); }