Ejemplo n.º 1
0
        public void RemoveAllChildren()
        {
            VFXModel modelA  = ScriptableObject.CreateInstance <VFXModelA>();
            VFXModel modelB0 = ScriptableObject.CreateInstance <VFXModelB>();
            VFXModel modelB1 = ScriptableObject.CreateInstance <VFXModelB>();
            VFXModel modelB2 = ScriptableObject.CreateInstance <VFXModelB>();

            modelA.AddChild(modelB0);
            modelA.AddChild(modelB1);
            modelA.AddChild(modelB2);

            s_logs.Clear();
            modelA.RemoveAllChildren();

            Assert.AreEqual(0, modelA.GetNbChildren());
            Assert.IsNull(modelB0.GetParent());
            Assert.IsNull(modelB1.GetParent());
            Assert.IsNull(modelB2.GetParent());

            Assert.AreEqual(6, s_logs.Count);
            for (int i = 0; i < 6; i += 2)
            {
                Assert.AreEqual("OnRemoved VFXModelB", s_logs[i]);
                Assert.AreEqual("OnInvalidate VFXModelA kStructureChanged", s_logs[i + 1]);
            }
        }
Ejemplo n.º 2
0
        public void InsertChild()
        {
            VFXModel modelA  = ScriptableObject.CreateInstance <VFXModelA>();
            VFXModel modelB0 = ScriptableObject.CreateInstance <VFXModelB>();
            VFXModel modelB1 = ScriptableObject.CreateInstance <VFXModelB>();
            VFXModel modelB2 = ScriptableObject.CreateInstance <VFXModelB>();

            s_logs.Clear();
            modelA.AddChild(modelB2);
            modelA.AddChild(modelB0, 0);
            modelA.AddChild(modelB1, 1);

            Assert.AreEqual(3, modelA.GetNbChildren(), 3);
            Assert.AreEqual(modelB0, modelA[0]);
            Assert.AreEqual(modelB1, modelA[1]);
            Assert.AreEqual(modelB2, modelA[2]);

            Assert.AreEqual(6, s_logs.Count);
            Assert.AreEqual("OnAdded VFXModelB", s_logs[0]);
            Assert.AreEqual("OnInvalidate VFXModelA kStructureChanged", s_logs[1]);
            Assert.AreEqual("OnAdded VFXModelB", s_logs[2]);
            Assert.AreEqual("OnInvalidate VFXModelA kStructureChanged", s_logs[3]);
            Assert.AreEqual("OnAdded VFXModelB", s_logs[4]);
            Assert.AreEqual("OnInvalidate VFXModelA kStructureChanged", s_logs[5]);
        }
Ejemplo n.º 3
0
        public void AddChild()
        {
            VFXModel modelA = ScriptableObject.CreateInstance <VFXModelA>();
            VFXModel modelB = ScriptableObject.CreateInstance <VFXModelB>();
            VFXModel modelC = ScriptableObject.CreateInstance <VFXModelC>();

            // Test both interfaces
            s_logs.Clear();
            modelA.AddChild(modelB);
            modelC.Attach(modelB);

            Assert.AreEqual(1, modelA.GetNbChildren());
            Assert.AreEqual(modelB, modelA[0]);
            Assert.AreEqual(modelA, modelB.GetParent());

            Assert.AreEqual(1, modelB.GetNbChildren());
            Assert.AreEqual(modelC, modelB[0]);
            Assert.AreEqual(modelB, modelC.GetParent());

            Assert.AreEqual(5, s_logs.Count);
            Assert.AreEqual("OnAdded VFXModelB", s_logs[0]);
            Assert.AreEqual("OnInvalidate VFXModelA kStructureChanged", s_logs[1]);
            Assert.AreEqual("OnAdded VFXModelC", s_logs[2]);
            Assert.AreEqual("OnInvalidate VFXModelB kStructureChanged", s_logs[3]);
            Assert.AreEqual("OnInvalidate VFXModelA kStructureChanged", s_logs[4]);
        }
Ejemplo n.º 4
0
        public void AddChild_OutOfBounds()
        {
            VFXModel modelA = ScriptableObject.CreateInstance <VFXModelA>();
            VFXModel modelB = ScriptableObject.CreateInstance <VFXModelB>();

            s_logs.Clear();
            Assert.Throws <ArgumentException>(() =>
                                              modelA.AddChild(modelB, 2)
                                              );

            Assert.AreEqual(0, modelB.GetNbChildren());
            Assert.IsNull(modelA.GetParent());
            Assert.AreEqual(0, s_logs.Count);
        }
Ejemplo n.º 5
0
        public void ChangeParent()
        {
            VFXModel modelA0 = ScriptableObject.CreateInstance <VFXModelA>();
            VFXModel modelA1 = ScriptableObject.CreateInstance <VFXModelA>();
            VFXModel modelB  = ScriptableObject.CreateInstance <VFXModelB>();

            s_logs.Clear();
            modelA0.AddChild(modelB);
            modelA1.AddChild(modelB);

            Assert.AreEqual(0, modelA0.GetNbChildren());
            Assert.AreEqual(1, modelA1.GetNbChildren());
            Assert.AreEqual(modelA1, modelB.GetParent());

            Assert.AreEqual(6, s_logs.Count);
            Assert.AreEqual("OnAdded VFXModelB", s_logs[0]);
            Assert.AreEqual("OnInvalidate VFXModelA kStructureChanged", s_logs[1]);
            Assert.AreEqual("OnRemoved VFXModelB", s_logs[2]);
            Assert.AreEqual("OnInvalidate VFXModelA kStructureChanged", s_logs[3]);
            Assert.AreEqual("OnAdded VFXModelB", s_logs[4]);
            Assert.AreEqual("OnInvalidate VFXModelA kStructureChanged", s_logs[5]);
        }