public void TheGameObjectWillBeMarkedNotToBeDestroyedOnLevelLoad()
        {
            TestHierarchy h = new TestHierarchy();
            Assert.That(Application.dontDestroyOnLoad, !Contains.Item(h.childOfChild));
            UnityObject.DontDestroyOnLoad(h.childOfChild);

            Assert.That(Application.dontDestroyOnLoad, Contains.Item(h.childOfChild));
        }
        public void TheGameObjectWillBeMarkedNotToBeDestroyedOnLevelLoad()
        {
            TestHierarchy h = new TestHierarchy();

            Assert.That(Application.dontDestroyOnLoad, !Contains.Item(h.childOfChild));
            UnityObject.DontDestroyOnLoad(h.childOfChild);

            Assert.That(Application.dontDestroyOnLoad, Contains.Item(h.childOfChild));
        }
        public void AllOfItsChildrenWillBeMarkedForDestruction()
        {
            TestHierarchy h = new TestHierarchy();

            UnityObject.Destroy(h.root);

            Assert.That(Application.markedForDestruction.Contains(h.child));
            Assert.That(Application.markedForDestruction.Contains(h.childOfChild));
        }
        public void AllOfItsChildrenWillBeMarkedForDestruction()
        {
            TestHierarchy h = new TestHierarchy();

            UnityObject.Destroy(h.root);

            Assert.That(Application.markedForDestruction.Contains(h.child));
            Assert.That(Application.markedForDestruction.Contains(h.childOfChild));
        }
        public void WeWillCloneAParentHierarchy()
        {
            TestHierarchy h = new TestHierarchy();

            GameObject clone = GameObject.Instantiate(h.childOfChild) as GameObject;

            Assert.That(clone.transform.parent, Is.Not.Null);
            Assert.That(clone.transform.parent.transform.parent, Is.Not.Null);
            Assert.That(clone.transform.parent.transform.parent.transform.parent, Is.Null);
        }
Example #6
0
        public void TheIdMapWillContainAMapOfAllChildren()
        {
            TestHierarchy h = new TestHierarchy();
            Dictionary <int, UnityObject> ids = new Dictionary <int, UnityObject>();

            h.root.SetNewId(ids);
            Assert.That(ids.ContainsValue(h.root), Is.True);
            Assert.That(ids.ContainsValue(h.child), Is.True);
            Assert.That(ids.ContainsValue(h.childOfChild), Is.True);
        }
Example #7
0
        public void TheIdMapWillContainAMapOfAllChildren()
        {
            TestHierarchy h = new TestHierarchy();
            Dictionary<int, UnityObject> ids = new Dictionary<int, UnityObject>();

            h.root.SetNewId(ids);
            Assert.That(ids.ContainsValue(h.root), Is.True);
            Assert.That(ids.ContainsValue(h.child), Is.True);
            Assert.That(ids.ContainsValue(h.childOfChild), Is.True);
        }
        public void OnAComponentItsGameObjectWillBeMarkedNotToBeDestroyedOnLevelLoad()
        {
            TestHierarchy h = new TestHierarchy();
            TestComponent tc = new TestComponent();
            h.childOfChild.AddComponent(tc);

            Assert.That(Application.dontDestroyOnLoad, !Contains.Item(h.childOfChild));
            UnityObject.DontDestroyOnLoad(tc);

            Assert.That(Application.dontDestroyOnLoad, Contains.Item(h.childOfChild));
        }
Example #9
0
        public void WeCanSendAMessageUpwards()
        {
            TestHierarchy    h    = new TestHierarchy();
            MessageComponent comp = new MessageComponent();

            h.root.AddComponent(comp);

            h.childOfChild.SendMessageUpwards("MessageMethod");

            Assert.That(comp.messageCalled, Is.True);
        }
        public void OnAComponentItsGameObjectWillBeMarkedNotToBeDestroyedOnLevelLoad()
        {
            TestHierarchy h  = new TestHierarchy();
            TestComponent tc = new TestComponent();

            h.childOfChild.AddComponent(tc);

            Assert.That(Application.dontDestroyOnLoad, !Contains.Item(h.childOfChild));
            UnityObject.DontDestroyOnLoad(tc);

            Assert.That(Application.dontDestroyOnLoad, Contains.Item(h.childOfChild));
        }
        public void TheChildrenWillBeSetIfSettingRecursively()
        {
            TestHierarchy h = new TestHierarchy();
            Assert.That(h.root.active, Is.True);
            Assert.That(h.child.active, Is.True);
            Assert.That(h.childOfChild.active, Is.True);

            h.root.SetActiveRecursively(false);
            Assert.That(h.root.active, Is.False);
            Assert.That(h.child.active, Is.False);
            Assert.That(h.childOfChild.active, Is.False);
        }
        public void TheChildrenWillNotBeAffected()
        {
            TestHierarchy h = new TestHierarchy();
            Assert.That(h.root.active, Is.True);
            Assert.That(h.child.active, Is.True);
            Assert.That(h.childOfChild.active, Is.True);

            h.root.active = false;
            Assert.That(h.root.active, Is.False);
            Assert.That(h.child.active, Is.True);
            Assert.That(h.childOfChild.active, Is.True);
        }
Example #13
0
        public void WeWillSetTheIdOfOurChildrensChildrenAndItsComponents()
        {
            TestHierarchy h = new TestHierarchy();

            int id     = h.childOfChild.GetInstanceID();
            int compId = h.childOfChildTrans.GetInstanceID();

            h.root.SetNewId(new Dictionary <int, UnityObject>());

            Assert.That(h.childOfChild.GetInstanceID(), Is.Not.EqualTo(id));
            Assert.That(h.childOfChildTrans.GetInstanceID(), Is.Not.EqualTo(compId));
        }
        public void TheChildrenWillBeSetIfSettingRecursively()
        {
            TestHierarchy h = new TestHierarchy();

            Assert.That(h.root.active, Is.True);
            Assert.That(h.child.active, Is.True);
            Assert.That(h.childOfChild.active, Is.True);

            h.root.SetActiveRecursively(false);
            Assert.That(h.root.active, Is.False);
            Assert.That(h.child.active, Is.False);
            Assert.That(h.childOfChild.active, Is.False);
        }
        public void TheChildrenWillNotBeAffected()
        {
            TestHierarchy h = new TestHierarchy();

            Assert.That(h.root.active, Is.True);
            Assert.That(h.child.active, Is.True);
            Assert.That(h.childOfChild.active, Is.True);

            h.root.active = false;
            Assert.That(h.root.active, Is.False);
            Assert.That(h.child.active, Is.True);
            Assert.That(h.childOfChild.active, Is.True);
        }
Example #16
0
        public void Setup()
        {
            Assert.Inconclusive("This will only work when loading with the intermediate serializer, so we need to do a test like that.");
            h             = new TestHierarchy();
            rootComponent = new TestComponent();
            h.root.AddComponent(rootComponent);

            childComponent = new TestComponent();
            h.child.AddComponent(childComponent);

            childOfChildComponent = new TestComponent();
            h.childOfChild.AddComponent(childOfChildComponent);
        }
Example #17
0
        public void WeCanBroadcastAMessage()
        {
            TestHierarchy    h     = new TestHierarchy();
            MessageComponent comp  = new MessageComponent();
            MessageComponent comp1 = new MessageComponent();

            h.child.AddComponent(comp);
            h.childOfChild.AddComponent(comp1);

            h.root.BroadcastMessage("MessageMethod");

            Assert.That(comp.messageCalled, Is.True);
            Assert.That(comp1.messageCalled, Is.True);
        }
        public void WeWillCloneAParentHierarchyByComponent()
        {
            TestHierarchy h = new TestHierarchy();

            TestComponent comp = new TestComponent();

            h.childOfChild.AddComponent(comp);

            TestComponent clone = GameObject.Instantiate(comp) as TestComponent;

            Assert.That(clone, Is.Not.Null);
            Assert.That(clone.transform.parent, Is.Not.Null);
            Assert.That(clone.transform.parent.transform.parent, Is.Not.Null);
            Assert.That(clone.transform.parent.transform.parent.transform.parent, Is.Null);
        }
Example #19
0
        public void WeWillFixReferencesInTheHierarchy()
        {
            TestHierarchy        h       = new TestHierarchy();
            TestComponent        testCmp = new TestComponent(true);
            TestComponent        newCmp  = new TestComponent();
            ReferencingComponent cmp     = new ReferencingComponent()
            {
                reference = testCmp
            };

            h.childOfChild.AddComponent(cmp);
            Dictionary <int, UnityObject> dict = new Dictionary <int, UnityObject>();

            dict.Add(testCmp.GetInstanceID(), newCmp);

            h.root.FixReferences(dict);

            Assert.That(cmp.reference, Is.SameAs(newCmp));
        }
        public void WeWillCloneAParentHierarchyByComponent()
        {
            TestHierarchy h = new TestHierarchy();

            TestComponent comp = new TestComponent();
            h.childOfChild.AddComponent(comp);

            TestComponent clone = GameObject.Instantiate(comp) as TestComponent;
            Assert.That(clone, Is.Not.Null);
            Assert.That(clone.transform.parent, Is.Not.Null);
            Assert.That(clone.transform.parent.transform.parent, Is.Not.Null);
            Assert.That(clone.transform.parent.transform.parent.transform.parent, Is.Null);
        }
        public void WeWillCloneAParentHierarchy()
        {
            TestHierarchy h = new TestHierarchy();

            GameObject clone = GameObject.Instantiate(h.childOfChild) as GameObject;
            Assert.That(clone.transform.parent, Is.Not.Null);
            Assert.That(clone.transform.parent.transform.parent, Is.Not.Null);
            Assert.That(clone.transform.parent.transform.parent.transform.parent, Is.Null);
        }
Example #22
0
        public void WeWillSetTheIdOfOurChildrensChildrenAndItsComponents()
        {
            TestHierarchy h = new TestHierarchy();

            int id = h.childOfChild.GetInstanceID();
            int compId = h.childOfChildTrans.GetInstanceID();
            h.root.SetNewId(new Dictionary<int, UnityObject>());

            Assert.That(h.childOfChild.GetInstanceID(), Is.Not.EqualTo(id));
            Assert.That(h.childOfChildTrans.GetInstanceID(), Is.Not.EqualTo(compId));
        }
Example #23
0
        public void Setup()
        {
            Assert.Inconclusive("This will only work when loading with the intermediate serializer, so we need to do a test like that.");
            h = new TestHierarchy();
            rootComponent = new TestComponent();
            h.root.AddComponent(rootComponent);

            childComponent = new TestComponent();
            h.child.AddComponent(childComponent);

            childOfChildComponent = new TestComponent();
            h.childOfChild.AddComponent(childOfChildComponent);
        }