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 OtherPropertyLockedAfterManualUnlockFinished() { // Given a scene object with two independent lockable properties which are not referenced by any condition. ISceneObject o1 = TestingUtils.CreateSceneObject("o1"); LockablePropertyMock property = o1.GameObject.AddComponent <LockablePropertyMock>(); LockablePropertyMock property2 = o1.GameObject.AddComponent <LockablePropertyMock>(); EndlessConditionMock condition = new EndlessConditionMock(); Step step2 = new BasicStepBuilder("step").AddCondition(new EndlessConditionMock()).Build(); Step step = new BasicStepBuilder("step").AddCondition(condition).Build(); step.Data.Transitions.Data.Transitions[0].Data.TargetStep = step2; property.SetLocked(true); property2.SetLocked(true); // When we manually unlock one property for one 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> { new LockablePropertyData(property) }); // Then the other property stays locked after the step was completed. Assert.IsTrue(property2.IsLocked); yield return(null); }
public IEnumerator DependencyGetsLocked() { // Given a scene object with one lockable property with dependency. ISceneObject o1 = TestingUtils.CreateSceneObject("o1"); LockablePropertyMock dependency = o1.GameObject.AddComponent <LockablePropertyMock>(); LockablePropertyMockWithDependency propertyWithDependency = o1.GameObject.AddComponent <LockablePropertyMockWithDependency>(); Step step2 = new BasicStepBuilder("step").Build(); Step step = new BasicStepBuilder("step").AddCondition(new EndlessConditionMock()).Build(); step.Data.Transitions.Data.Transitions[0].Data.TargetStep = step2; dependency.SetLocked(true); propertyWithDependency.SetLocked(true); // When we manually unlock the property for one step. LockHandling.Unlock(step.Data, new List <LockablePropertyData> { new LockablePropertyData(propertyWithDependency) }); step.Data.Transitions.Data.Transitions.First().Autocomplete(); step.Data.Transitions.Data.Transitions.First().Data.IsCompleted = true; LockHandling.Lock(step.Data, new List <LockablePropertyData> { new LockablePropertyData(propertyWithDependency) }); // Then after the step the dependent property is also locked again. Assert.IsTrue(dependency.IsLocked); yield return(null); }
public IEnumerator UnlockedAfterManualUnlockStarted() { // Given a scene object with a lockable property which is not referenced by any condition. ISceneObject o1 = TestingUtils.CreateSceneObject("o1"); LockablePropertyMock property = o1.GameObject.AddComponent <LockablePropertyMock>(); EndlessConditionMock condition = new EndlessConditionMock(); Step step2 = new BasicStepBuilder("step").AddCondition(new EndlessConditionMock()).Build(); Step step = new BasicStepBuilder("step").AddCondition(condition).Build(); step.Data.Transitions.Data.Transitions[0].Data.TargetStep = step2; property.SetLocked(true); // When we include the property into the manualUnlocked list of the UnlockPropertiesForStepData method. LockHandling.Unlock(step.Data, new List <LockablePropertyData> { new LockablePropertyData(property) }); // Then the property is not locked. Assert.IsFalse(property.IsLocked); yield return(null); }