public static void AddNotTransformBeforeHavingParent() { var rect = new Mux.Markup.RectTransform { BindingContext = 0 }; var beforeHavingParent = new NotTransform(); var afterHavingParent = new NotTransform(); SynchronizationContextWaiter.Execute(() => rect.Add(beforeHavingParent)); Assert.AreEqual(0, beforeHavingParent.BindingContext); Assert.Null(beforeHavingParent.gameObject); Assert.AreEqual(0, beforeHavingParent.awakeCount); var gameObject = new UnityEngine.GameObject(); try { rect.AddToInMainThread(gameObject); Assert.AreEqual(rect.Body.gameObject, beforeHavingParent.gameObject); Assert.AreEqual(0, beforeHavingParent.awakeCount); rect.Add(afterHavingParent); Assert.AreEqual(rect.Body.gameObject, afterHavingParent.gameObject); Assert.AreEqual(0, afterHavingParent.awakeCount); rect.AwakeInMainThread(); Assert.AreEqual(1, beforeHavingParent.awakeCount); Assert.AreEqual(1, afterHavingParent.awakeCount); } finally { UnityEngine.Object.Destroy(gameObject); } }
public static void ClearToDestroyNotTransform() { var source = new Source { Property = 0 }; var notTransform = new NotTransform(); var binding = new Binding("Property", BindingMode.OneWay, null, null, null, source); var rect = new Mux.Markup.RectTransform(); try { notTransform.SetBinding(NotTransform.BindingContextProperty, binding); rect.Add(notTransform); ((IInternalTransform)rect).Clear(); CollectionAssert.IsEmpty(rect); source.Property = 1; Assert.AreEqual(0, notTransform.BindingContext); } finally { rect.Destroy(); } }
public static void AddNotTransformAfterHavingParent() { var gameObject = new UnityEngine.GameObject(); try { var rect = new Mux.Markup.RectTransform { BindingContext = 0 }; rect.AddTo(gameObject); var child = new NotTransform(); SynchronizationContextWaiter.Execute(() => rect.Add(child)); Assert.AreEqual(0, child.BindingContext); Assert.AreEqual(rect.Body.gameObject, child.gameObject); Assert.AreEqual(1, child.awakeCount); } finally { UnityEngine.Object.Destroy(gameObject); } }