public void Test_World() { IActor parent; using (IWorld world = Root.CreateWorld()) { parent = world.CreateActor(); ReferenceHolder referenceHolder = HandleUtils.TryGetReferenceHolder(parent.Handle); Assert.IsNotNull(world); Assert.AreEqual(world, parent.World); Assert.IsNotNull(referenceHolder); Assert.IsTrue(referenceHolder.IsStrong); Assert.IsFalse(referenceHolder.IsWeak); } Assert.IsTrue(HandleUtils.IsDestroyed(parent.Handle)); }
public void Test_Actor_After_Destroy() { using (IWorld world = Root.CreateWorld()) { IActor puppetActor = world.CreateActor(); IActor actor = world.CreateActor(); actor.Destroy(); Assert.IsTrue(HandleUtils.IsDestroyed(actor.Handle)); Assert.IsNull(HandleUtils.TryGetReferenceHolder(actor.Handle)); // IActor methods can't throw any exception. actor.AddChild(puppetActor); actor.RemoveChild(puppetActor); actor.Destroy(); actor.Detach(); actor.Enabled = true; Assert.IsFalse(actor.Enabled); actor.CreateComponent <TestComponent>(); Assert.IsNull(actor.Clone()); Assert.IsNull(actor.GetComponent <TestComponent>()); Assert.IsNotNull(actor.GetAllComponents()); Assert.AreEqual(0, actor.GetAllComponents().Count); Assert.IsFalse(actor.HasComponent <TestComponent>()); actor.RemoveComponent <TestComponent>(); string testStr = "Actor"; actor.Name = testStr; Assert.AreNotEqual(testStr, actor.Name); Assert.IsTrue(string.IsNullOrEmpty(actor.Name)); Assert.AreEqual(-1, actor.Id); Assert.IsNull(actor.Parent); Assert.IsNull(actor.World); Assert.IsNotNull(actor.Children); Assert.AreEqual(0, actor.Children.Count); } }