public void CleanUpEmptiesNodeList()
 {
     var entity = new Entity();
     entity.Add(new Point());
     _family.NewEntity(entity);
     var nodes = _family.NodeList;
     _family.CleanUp();
     Assert.IsNull(nodes.Head);
 }
예제 #2
0
 public void ReleaseFamilyEmptiesNodeList()
 {
     var entity = new Entity();
     entity.Add(new Vector2());
     entity.Add(new Matrix4x4());
     _game.AddEntity(entity);
     var nodes = _game.GetNodeList<MockNode>();
     _game.ReleaseNodeList<MockNode>();
     Assert.IsNull(nodes.Head);
 }
예제 #3
0
파일: GameTests.cs 프로젝트: Aranda/Ash.NET
 public void TestRemoveEntityChecksWithAllFamilies()
 {
     _game.GetNodeList<MockNode>();
     _game.GetNodeList<MockNode2>();
     var entity = new Entity();
     _game.AddEntity(entity);
     _game.RemoveEntity(entity);
     var results = new List<int>
     {
         MockFamily.Instances[0].RemoveEntityCalls,
         MockFamily.Instances[1].RemoveEntityCalls
     };
     Assert.AreEqual(new List<int> { 1, 1 }, results);
 }
예제 #4
0
파일: GameTests.cs 프로젝트: Aranda/Ash.NET
 public void TestComponentAddedChecksWithAllFamilies()
 {
     _game.GetNodeList<MockNode>();
     _game.GetNodeList<MockNode2>();
     var entity = new Entity();
     _game.AddEntity(entity);
     entity.Add(new Point());
     var results = new List<int>
     {
         MockFamily.Instances[0].ComponentAddedCalls,
         MockFamily.Instances[1].ComponentAddedCalls
     };
     Assert.AreEqual(new List<int> { 1, 1 }, results);
 }
        public void CleanUpSetsNextNodeToNull()
        {
            var entities = new List<Entity>();
            for(var i = 0; i < 5; ++i)
            {
                var entity = new Entity();
                entity.Add(new Point());
                entities.Add(entity);
                _family.NewEntity(entity);
            }

            var nodes = _family.NodeList;
            var node = nodes.Head.Next;
            _family.CleanUp();
            Assert.IsNull(node.Next);
        }
        public void NodeListContainsAllMatchingEntities()
        {
            var entities = new List<Entity>();
            for(var i = 0; i < 5; ++i)
            {
                var entity = new Entity();
                entity.Add(new Point());
                entities.Add(entity);
                _family.NewEntity(entity);
                _family.NewEntity(new Entity());
            }

            var nodes = _family.NodeList;
            for (var node = nodes.Head; node != null; node = node.Next)
            {
                entities.RemoveAt(entities.IndexOf(node.Entity));
            }
            Assert.AreEqual(0, entities.Count);
        }
예제 #7
0
        public void FamilyContainsAllMatchingEntities()
        {
            var entities = new List<Entity>();
            for (var i = 0; i < 5; ++i)
            {
                var entity = new Entity();
                entity.Add(new Vector2());
                entity.Add(new Matrix4x4());
                entities.Add(entity);
                _game.AddEntity(entity);
            }

            var nodes = _game.GetNodeList<MockNode>();
            for (var node = nodes.Head; node != null; node = node.Next)
            {
                var index = entities.IndexOf(node.Entity);
                entities.RemoveAt(index);
            }
            Assert.AreEqual(0, entities.Count);
        }
예제 #8
0
        public void FamilyContainsOnlyMatchingEntities()
        {
            var entities = new List<Entity>();
            for (var i = 0; i < 5; ++i)
            {
                var entity = new Entity();
                entity.Add(new Vector2());
                entity.Add(new Matrix4x4());
                entities.Add(entity);
                _game.AddEntity(entity);
            }

            var nodes = _game.GetNodeList<MockNode>();
            var results = new List<bool>();
            for (var node = nodes.Head; node != null; node = node.Next)
            {
                results.Add(entities.Contains(node.Entity));
            }

            Assert.AreEqual(new List<bool> { true, true, true, true, true }, results);
        }
예제 #9
0
        public void TestNodeContainsEntityProperties()
        {
            var entity = new Entity();
            var Vector2 = new Vector2();
            var matrix = new Matrix4x4();
            entity.Add(Vector2);
            entity.Add(matrix);

            var nodes = _game.GetNodeList<MockNode>();
            _game.AddEntity(entity);
            var head = (MockNode)nodes.Head;
            Assert.AreEqual(new List<object> { Vector2, matrix }, new List<object> { head.Vector2, head.Matrix });
        }
예제 #10
0
 public void TestEntityRemovedFromFamilyWhenRemovedFromGameAndFamilyNotAlreadyAccessed()
 {
     var entity = new Entity();
     entity.Add(new Vector2());
     entity.Add(new Matrix4x4());
     _game.AddEntity(entity);
     _game.RemoveEntity(entity);
     var nodes = _game.GetNodeList<MockNode>();
     Assert.IsNull(nodes.Head);
 }
예제 #11
0
 public void TestIncorrectEntityNotAddedToFamilyWhenAccessFamilySecond()
 {
     var entity = new Entity();
     _game.AddEntity(entity);
     var nodes = _game.GetNodeList<MockNode>();
     Assert.IsNull(nodes.Head);
 }
예제 #12
0
 public void TestEntityIsRemovedWhenAccessNodeListFirst()
 {
     var entity = new Entity();
     entity.Add(new Vector2());
     _family.NewEntity(entity);
     var nodes = _family.NodeList;
     _family.RemoveEntity(entity);
     Assert.IsNull(nodes.Head);
 }
 public void TestMatchingEntityIsAddedWhenComponentAdded()
 {
     var nodes = _family.NodeList;
     var entity = new Entity();
     entity.Add(new Point());
     _family.ComponentAddedToEntity(entity, typeof(Point));
     Assert.AreSame(entity, nodes.Head.Entity);
 }
예제 #14
0
 public void NewEntity(Entity entity) { NewEntityCalls++; }
예제 #15
0
 public void ComponentAddedToEntity(Entity entity, System.Type componentClass)
 {
     ComponentAddedCalls ++;
 }
 public void TestEntityIsRemovedWhenComponentRemoved()
 {
     var entity = new Entity();
     entity.Add(new Point());
     _family.NewEntity(entity);
     entity.Remove(typeof(Point));
     _family.ComponentRemovedFromEntity(entity, typeof(Point));
     var nodes = _family.NodeList;
     Assert.IsNull(nodes.Head);
 }
 public void TestEntityIsRemovedWhenAccessNodeListSecond()
 {
     var entity = new Entity();
     entity.Add(new Point());
     _family.NewEntity(entity);
     _family.RemoveEntity(entity);
     var nodes = _family.NodeList;
     Assert.IsNull(nodes.Head);
 }
 public void TestNonMatchingEntityIsNotAddedWhenComponentAdded()
 {
     var entity = new Entity();
     entity.Add(new Matrix());
     _family.ComponentAddedToEntity(entity, typeof(Matrix));
     var nodes = _family.NodeList;
     Assert.IsNull(nodes.Head);
 }
 public void TestNonMatchingEntityIsNotAdded()
 {
     var entity = new Entity();
     _family.NewEntity(entity);
     var nodes = _family.NodeList;
     Assert.IsNull(nodes.Head);
 }
 public void TestNodeContainsEntityProperties()
 {
     var entity = new Entity();
     var point = new Point(1,2);
     entity.Add(point);
     _family.NewEntity(entity);
     var nodes = _family.NodeList;
     Assert.AreEqual(point, ((MockNode)nodes.Head).Point);
 }
예제 #21
0
 public void TestMatchingEntityIsAddedWhenAccessNodeListFirst()
 {
     var nodes = _family.NodeList;
     var entity = new Entity();
     entity.Add(new Vector2());
     _family.NewEntity(entity);
     Assert.AreSame(entity, nodes.Head.Entity);
 }
        public void TestNodeContainsEntityProperties()
        {
            var entity = new Entity();
            var point = new Point();
            var matrix = new Matrix();
            entity.Add(point);
            entity.Add(matrix);

            var nodes = _game.GetNodeList<MockNode>();
            _game.AddEntity(entity);
            var head = (MockNode) nodes.Head;
            Assert.AreEqual(new List<object> {point, matrix}, new List<object> {head.Point, head.Matrix});
        }
예제 #23
0
        public void ReleaseFamilySetsNextNodeToNull()
        {
            var entities = new List<Entity>();
            for (var i = 0; i < 5; ++i)
            {
                var entity = new Entity();
                entity.Add(new Vector2());
                entity.Add(new Matrix4x4());
                entities.Add(entity);
                _game.AddEntity(entity);
            }

            var nodes = _game.GetNodeList<MockNode>();
            var node = nodes.Head.Next;
            _game.ReleaseNodeList<MockNode>();
            Assert.IsNull(node.Next);
        }
예제 #24
0
 public void TestCorrectEntityAddedToFamilyWhenComponentsAdded()
 {
     var entity = new Entity();
     _game.AddEntity(entity);
     var nodes = _game.GetNodeList<MockNode>();
     entity.Add(new Vector2());
     entity.Add(new Matrix4x4());
     Assert.AreSame(entity, nodes.Head.Entity);
 }
        public void NodeListContainsOnlyMatchingEntities()
        {
            var entities = new List<Entity>();
            for (var i = 0; i < 5; ++i)
            {
                var entity = new Entity();
                entity.Add(new Point());
                entities.Add(entity);
                _family.NewEntity(entity);
                _family.NewEntity(new Entity());
            }

            var nodes = _family.NodeList;
            var results = new List<bool>();
            for(var node = nodes.Head; node != null; node = node.Next)
            {
                results.Add(entities.Contains(node.Entity));
            }

            Assert.AreEqual(new List<bool> {true, true, true, true, true}, results);
        }
 public void TestMatchingEntityIsAddedWhenAccessNodeListSecond()
 {
     var entity = new Entity();
     entity.Add(new Point());
     _family.NewEntity(entity);
     var nodes = _family.NodeList;
     Assert.AreSame(entity, nodes.Head.Entity);
 }
예제 #27
0
 public void RemoveEntity(Entity entity) { RemoveEntityCalls++; }
예제 #28
0
 public void RemoveAllEntitiesDoesWhatItSays()
 {
     var entity = new Entity();
     entity.Add(new Vector2());
     entity.Add(new Matrix4x4());
     _game.AddEntity(entity);
     entity = new Entity();
     entity.Add(new Vector2());
     entity.Add(new Matrix4x4());
     _game.AddEntity(entity);
     var nodes = _game.GetNodeList<MockNode>();
     _game.RemoveAllEntities();
     Assert.IsNull(nodes.Head);
 }
예제 #29
0
 public void ComponentRemovedFromEntity(Entity entity, System.Type componentClass)
 {
     ComponentRemovedCalls++;
 }
 public void TestEntityRemovedFromFamilyWhenComponentRemovedAndFamilyNotAlreadyAccessed()
 {
     var entity = new Entity();
     entity.Add(new Point());
     entity.Add(new Matrix());
     _game.AddEntity(entity);
     entity.Remove<Point>();
     var nodes = _game.GetNodeList<MockNode>();
     Assert.IsNull(nodes.Head);
 }