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]); }
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]); } }
public void RemoveChild() { VFXModel modelA = ScriptableObject.CreateInstance <VFXModelA>(); VFXModel modelB = ScriptableObject.CreateInstance <VFXModelB>(); VFXModel modelC = ScriptableObject.CreateInstance <VFXModelC>(); // First add children but don't notify modelB.Attach(modelA, false); modelC.Attach(modelB, false); // Test both interfaces s_logs.Clear(); modelC.Detach(); modelA.RemoveChild(modelB); Assert.AreEqual(0, modelA.GetNbChildren()); Assert.IsNull(modelB.GetParent()); Assert.AreEqual(0, modelB.GetNbChildren()); Assert.IsNull(modelC.GetParent()); Assert.AreEqual(5, s_logs.Count); Assert.AreEqual("OnRemoved VFXModelC", s_logs[0]); Assert.AreEqual("OnInvalidate VFXModelB kStructureChanged", s_logs[1]); Assert.AreEqual("OnInvalidate VFXModelA kStructureChanged", s_logs[2]); Assert.AreEqual("OnRemoved VFXModelB", s_logs[3]); Assert.AreEqual("OnInvalidate VFXModelA kStructureChanged", s_logs[4]); }
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); }
bool ValidateVFXModel(VFXModel model, VFXModel expectedParent) { if (model == null) { LogError("Model error : null. in parent:" + GetVFXModelDesc(expectedParent)); return(false); } if (model.GetParent() != expectedParent) { LogError("Model error : wrong parent. expected:" + GetVFXModelDesc(expectedParent) + " actual:" + GetVFXModelDesc(model.GetParent())); } if (!(model is VFXSlot) && model.GetGraph() != m_Graph) { LogError("Model error : " + GetVFXModelDesc(model) + " wrong graph. expected:" + GetVFXModelDesc(m_Graph) + " actual:" + GetVFXModelDesc(model.GetParent())); } return(true); }
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]); }