public void testEntityHas() { Entity entity = new Entity(); Id id = new Id(); id.Value = 1; entity.Add(id); Assert.AreEqual(entity.Has<Id>(), true); }
public void testEntityGet() { Entity entity = new Entity(); Id id = new Id(); id.Value = 1; entity.Add(id); Assert.AreEqual(entity.Get<Id>(), id); }
public void testEntityNodeList() { Entity entity = new Entity(); Id id = new Id(); id.Value = 1; entity.Add(id); Name name = new Name(); name.Value = "bob"; entity.Add(name); NodeList<TestNode> nodeList = Ash.GetNodeList<TestNode>(); Assert.AreEqual(nodeList.Count, 0); Ash.AddEntity(entity); Assert.AreEqual(nodeList.Count, 1); Ash.RemoveEntity(entity); Assert.AreEqual(nodeList.Count, 0); }
public void testEntityCount() { Entity entity = new Entity(); Id id = new Id(); id.Value = 1; entity.Add(id); Name name = new Name(); name.Value = "bob"; entity.Add(name); int Count = Ash.EntityCount(); Assert.AreEqual(Count, 0); Ash.AddEntity(entity); Count = Ash.EntityCount(); Assert.AreEqual(Count, 1); Ash.RemoveEntity(entity); Count = Ash.EntityCount(); Assert.AreEqual(Count, 0); }
public void testFamilyAs() { Entity entity = new Entity(); NodeList<TestNode> nodeList = Ash.GetNodeList<TestNode>(); Assert.AreEqual(nodeList.Count, 0); bool IsNode = false; IsNode = Ash.Is<TestNode>(entity); Assert.AreEqual(IsNode, false); Id id = new Id(); id.Value = 1; entity.Add(id); IsNode = Ash.Is<TestNode>(entity); Assert.AreEqual(IsNode, false); Ash.AddEntity(entity); IsNode = Ash.Is<TestNode>(entity); Assert.AreEqual(IsNode, false); TestNode node = null; node = Ash.As<TestNode>(entity); Assert.AreEqual(node, null); Name name = new Name(); name.Value = "bob"; entity.Add(name); Assert.AreEqual(nodeList.Count, 1); IsNode = Ash.Is<TestNode>(entity); Assert.AreEqual(IsNode, true); node = Ash.As<TestNode>(entity); Assert.AreNotEqual(node, null); Ash.RemoveEntity(entity); Assert.AreEqual(nodeList.Count, 0); // entity should no longer be in nodeList }
public void testRemoveComponent() { Entity entity = new Entity(); Id id = new Id(); id.Value = 1; entity.Add(id); Name name = new Name(); name.Value = "bob"; entity.Add(name); NodeList<TestNode> nodeList = Ash.GetNodeList<TestNode>(); Ash.AddEntity(entity); //Ash.RemoveEntity(entity); Assert.AreEqual(nodeList.Count, 1); entity.Remove(typeof(Name)); Assert.AreEqual(nodeList.Count, 0); // entity should no longer be in nodeList }