Exemplo n.º 1
0
        public void ShowMeshInCollectionsInactiveComponent()
        {
            UnityEventListenerMock shownMock  = new UnityEventListenerMock();
            UnityEventListenerMock hiddenMock = new UnityEventListenerMock();

            subject.Shown.AddListener(shownMock.Listen);
            subject.Hidden.AddListener(hiddenMock.Listen);

            subject.MeshCollections = containingObject.AddComponent <GameObjectMultiRelationObservableList>();

            GameObject childA = GameObject.CreatePrimitive(PrimitiveType.Cube);

            childA.transform.SetParent(containingObject.transform);
            MeshRenderer childARenderer = childA.GetComponent <MeshRenderer>();

            childARenderer.enabled = false;

            GameObject childB = GameObject.CreatePrimitive(PrimitiveType.Cube);

            childB.transform.SetParent(containingObject.transform);
            MeshRenderer childBRenderer = childB.GetComponent <MeshRenderer>();

            childBRenderer.enabled = false;

            GameObjectMultiRelationObservableList.MultiRelation relationA = new GameObjectMultiRelationObservableList.MultiRelation
            {
                Key    = containingObject,
                Values = new List <GameObject>()
                {
                    childA
                }
            };

            subject.MeshCollections.Add(relationA);
            subject.enabled = false;

            Assert.IsFalse(childARenderer.enabled);
            Assert.IsFalse(childBRenderer.enabled);
            Assert.IsFalse(shownMock.Received);
            Assert.IsFalse(hiddenMock.Received);

            subject.ShowMeshInCollections(containingObject);

            Assert.IsFalse(childARenderer.enabled);
            Assert.IsFalse(childBRenderer.enabled);
            Assert.IsFalse(shownMock.Received);
            Assert.IsFalse(hiddenMock.Received);
        }
        public void HasRelationshipInactiveComponent()
        {
            UnityEventListenerMock relationshipFoundMock    = new UnityEventListenerMock();
            UnityEventListenerMock relationshipNotFoundMock = new UnityEventListenerMock();

            subject.RelationshipFound.AddListener(relationshipFoundMock.Listen);
            subject.RelationshipNotFound.AddListener(relationshipNotFoundMock.Listen);

            GameObject keyOne   = new GameObject();
            GameObject valueOne = new GameObject();
            GameObject valueTwo = new GameObject();

            GameObjectMultiRelationObservableList.MultiRelation relationOne = new GameObjectMultiRelationObservableList.MultiRelation
            {
                Key    = keyOne,
                Values = new List <GameObject>()
                {
                    valueOne, valueTwo
                }
            };

            subject.Add(relationOne);

            subject.enabled = false;

            Assert.IsFalse(relationshipFoundMock.Received);
            Assert.IsFalse(relationshipNotFoundMock.Received);

            Assert.IsTrue(subject.HasRelationship(keyOne, out List <GameObject> resultsOne));
            Assert.AreEqual(valueOne, resultsOne[0]);
            Assert.AreEqual(valueTwo, resultsOne[1]);
            Assert.IsFalse(relationshipFoundMock.Received);
            Assert.IsFalse(relationshipNotFoundMock.Received);

            Object.DestroyImmediate(keyOne);
            Object.DestroyImmediate(valueOne);
            Object.DestroyImmediate(valueTwo);
        }