Beispiel #1
0
        public void UpdateEntityTest()
        {
            var        ctx      = new SimulationContext(true);
            Random     random   = new Random();
            EntityPool pool     = new EntityPool(ctx);
            var        entities = CreateEntities(ctx.LocalSpace, 3);

            foreach (var e in entities)
            {
                Assert.IsTrue(pool.Insert(e));
            }

            for (int i = 0; i < 10; i++)
            {
                Entity old   = entities[0];
                Entity moved = Relocate(old);
                Assert.IsTrue(pool.Contains(old.ID));
                Assert.IsTrue(pool.UpdateEntity(entities[0], moved), "Update moved entity " + i);
                Assert.IsFalse(pool.Contains(old.ID));
                entities[0] = moved;
                Assert.AreEqual(pool.Count, entities.Count);
                foreach (var e in entities)
                {
                    Assert.IsTrue(pool.Contains(e.ID.Guid));
                    Assert.IsTrue(pool.Contains(e.ID));
                }
            }
        }