コード例 #1
0
ファイル: LockingTests.cs プロジェクト: VaLiuM09/Creator
        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);
        }
コード例 #2
0
ファイル: LockingTests.cs プロジェクト: VaLiuM09/Creator
        public IEnumerator GetLockablePropertiesZeroLockables()
        {
            // Given a scene object with one non-lockable property used by a condition in a transition.
            ISceneObject o1 = TestingUtils.CreateSceneObject("o1");

            o1.GameObject.AddComponent <PropertyMock>();

            ReferencingConditionMock condition = new ReferencingConditionMock();

            condition.Data.PropertyMock = new ScenePropertyReference <PropertyMock>(o1.UniqueName);

            Step       step2      = new BasicStepBuilder("step2").Build();
            Step       step       = new BasicStepBuilder("step").AddCondition(condition).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 no lockable property.
            Assert.IsFalse(transition.GetLockableProperties().Any());

            yield return(null);
        }